r9230: Star out passwords and add confim text input for provisioning.
[kai/samba.git] / testprogs / ejs / sprintf.js
1 #!/usr/bin/env smbscript
2 /*
3         test sprintf function
4 */
5
6 string_init(local);
7
8 function check_result(s, v)
9 {
10         if (s != v) {
11                 println("expected '" + v + "' but got '" + s + "'");
12         }
13         assert(s == v);
14 }
15
16 function xprintf()
17 {
18         return "XX{" + vsprintf(arguments) + "}XX";
19 }
20
21 check_result(sprintf("%d", 7), "7");
22 check_result(sprintf("%04d", 42), "0042");
23 check_result(sprintf("my string=%7.2s", "foo%7"), "my string=     fo");
24 check_result(sprintf("blah=0x%*x", 4, 19), "blah=0x  13");
25 check_result(sprintf("blah=0x%0*x", 4, 19), "blah=0x0013");
26 check_result(sprintf("blah=%.0f", 1032), "blah=1032");
27 check_result(sprintf("%4.2f%%", 72.32), "72.32%");
28
29 check_result(xprintf("%4.2f%% and %s", 72.32, "foo"),"XX{72.32% and foo}XX");
30
31 println("ALL OK");