Very rudimental test for sprintf() and friends.
authorbernie <bernie@38d2e660-2303-0410-9eaa-f027e97ec537>
Fri, 18 Feb 2005 12:34:48 +0000 (12:34 +0000)
committerbernie <bernie@38d2e660-2303-0410-9eaa-f027e97ec537>
Fri, 18 Feb 2005 12:34:48 +0000 (12:34 +0000)
git-svn-id: https://src.develer.com/svnoss/bertos/trunk@377 38d2e660-2303-0410-9eaa-f027e97ec537

mware/sprintf_test.c [new file with mode: 0755]

diff --git a/mware/sprintf_test.c b/mware/sprintf_test.c
new file mode 100755 (executable)
index 0000000..b793f97
--- /dev/null
@@ -0,0 +1,33 @@
+#include "sprintf.c"
+#include "formatwr.c"
+
+#include <assert.h> /* assert() */
+#include <string.h> /* strcmp() */
+
+
+int main(UNUSED_ARG(int, argc), UNUSED_ARG(char **,argv))
+{
+       char buf[256];
+       static const char test_string[] = "Hello, world!\n";
+       static const pgm_char test_string_pgm[] = "Hello, world!\n";
+
+       snprintf(buf, sizeof buf, "%s", test_string);
+       assert(strcmp(buf, test_string) == 0);
+
+       snprintf(buf, sizeof buf, "%S", test_string_pgm);
+       assert(strcmp(buf, test_string_pgm) == 0);
+
+       snprintf(buf, sizeof buf, "%s", NULL);
+       assert(strcmp(buf, "<NULL>") == 0);
+
+       snprintf(buf, sizeof buf, "%d", 12345);
+       assert(strcmp(buf, "12345") == 0);
+
+       snprintf(buf, sizeof buf, "%ld", 123456789L);
+       assert(strcmp(buf, "123456789") == 0);
+
+       snprintf(buf, sizeof buf, "%lu", 4294967295UL);
+       assert(strcmp(buf, "4294967295") == 0);
+
+       return 0;
+}