1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-23 17:34:34 +03:00

r8346: added a sprintf test suite for ejs

This commit is contained in:
Andrew Tridgell 2005-07-12 05:58:41 +00:00 committed by Gerald (Jerry) Carter
parent 6d416656a0
commit 14af014410

22
testprogs/ejs/sprintf.js Executable file
View File

@ -0,0 +1,22 @@
#!/usr/bin/env smbscript
/*
test sprintf function
*/
function check_result(s, v)
{
if (s != v) {
println("expected '" + v + "' but got '" + s + "'");
}
assert(s == v);
}
check_result(sprintf("%d", 7), "7");
check_result(sprintf("%04d", 42), "0042");
check_result(sprintf("my string=%7.2s", "foo%7"), "my string= fo");
check_result(sprintf("blah=0x%*x", 4, 19), "blah=0x 13");
check_result(sprintf("blah=0x%0*x", 4, 19), "blah=0x0013");
check_result(sprintf("blah=%.0f", 1032), "blah=1032");
check_result(sprintf("%4.2f%%", 72.32), "72.32%");
println("ALL OK");