b793f97b0138eb982b52972eae08c88f0b0bc052
[bertos.git] / mware / sprintf_test.c
1 #include "sprintf.c"
2 #include "formatwr.c"
3
4 #include <assert.h> /* assert() */
5 #include <string.h> /* strcmp() */
6
7
8 int main(UNUSED_ARG(int, argc), UNUSED_ARG(char **,argv))
9 {
10         char buf[256];
11         static const char test_string[] = "Hello, world!\n";
12         static const pgm_char test_string_pgm[] = "Hello, world!\n";
13
14         snprintf(buf, sizeof buf, "%s", test_string);
15         assert(strcmp(buf, test_string) == 0);
16
17         snprintf(buf, sizeof buf, "%S", test_string_pgm);
18         assert(strcmp(buf, test_string_pgm) == 0);
19
20         snprintf(buf, sizeof buf, "%s", NULL);
21         assert(strcmp(buf, "<NULL>") == 0);
22
23         snprintf(buf, sizeof buf, "%d", 12345);
24         assert(strcmp(buf, "12345") == 0);
25
26         snprintf(buf, sizeof buf, "%ld", 123456789L);
27         assert(strcmp(buf, "123456789") == 0);
28
29         snprintf(buf, sizeof buf, "%lu", 4294967295UL);
30         assert(strcmp(buf, "4294967295") == 0);
31
32         return 0;
33 }