From: bernie Date: Fri, 18 Feb 2005 12:34:48 +0000 (+0000) Subject: Very rudimental test for sprintf() and friends. X-Git-Tag: 1.0.0~864 X-Git-Url: https://codewiz.org/gitweb?a=commitdiff_plain;ds=sidebyside;h=955809a5fea19ac29e086605a2338ec6d3e3e32d;p=bertos.git Very rudimental test for sprintf() and friends. git-svn-id: https://src.develer.com/svnoss/bertos/trunk@377 38d2e660-2303-0410-9eaa-f027e97ec537 --- diff --git a/mware/sprintf_test.c b/mware/sprintf_test.c new file mode 100755 index 00000000..b793f97b --- /dev/null +++ b/mware/sprintf_test.c @@ -0,0 +1,33 @@ +#include "sprintf.c" +#include "formatwr.c" + +#include /* assert() */ +#include /* 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, "") == 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; +}