summaryrefslogtreecommitdiff
path: root/testprogs/ejs
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2005-07-12 05:58:41 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:20:09 -0500
commit9370fca5dd014520b0c8970e55d33907921be518 (patch)
treeea8e27d21d6f4acee0944af0c898fd5d8ebaa829 /testprogs/ejs
parent08b78230d21d44da77a96d07bb86800894f6afcc (diff)
downloadsamba-9370fca5dd014520b0c8970e55d33907921be518.tar.gz
samba-9370fca5dd014520b0c8970e55d33907921be518.tar.bz2
samba-9370fca5dd014520b0c8970e55d33907921be518.zip
r8346: added a sprintf test suite for ejs
(This used to be commit 14af014410a9971d447aafe00640407698f63d7f)
Diffstat (limited to 'testprogs/ejs')
-rwxr-xr-xtestprogs/ejs/sprintf.js22
1 files changed, 22 insertions, 0 deletions
diff --git a/testprogs/ejs/sprintf.js b/testprogs/ejs/sprintf.js
new file mode 100755
index 0000000000..34df4f9a42
--- /dev/null
+++ b/testprogs/ejs/sprintf.js
@@ -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");