2 * Acess2 C Library (Test)
3 * - By John Hodge (thePowersGang)
10 #include <utest_common.h>
12 #define TST(_name, exp, fmt, val...) do { \
14 snprintf(buf, sizeof(buf), fmt, ##val); \
15 if( strcmp(buf, exp) != 0 ) { \
16 fprintf(stderr, "FAIL: exp '%s' != got '%s'\n", exp, buf);\
21 int main(int argc, char *argv[])
23 TST("None", "Hello World!\n", "Hello World!\n");
24 TST("String", "teststring", "%s", "teststring");
25 TST("String", "tests", "%.5s", "teststring");
26 TST("String", " tests", "%10.5s", "teststring");
27 TST("String", "tests ", "%-10.5s", "teststring");
29 TST("Integer", "1234", "%i", 1234);
30 TST("Integer", "1234", "%d", 1234);
31 TST("Integer", "1234", "%u", 1234);
33 TST("Float", "3.141593", "%f", 3.1415926535);
34 TST("Float", "10.000000", "%f", 10.0);
35 TST("Float", "-0.000000", "%f", -0.0);
36 TST("Float", "3.1415926535", "%.10f", 3.1415926535);
37 TST("Float", "3.141593e+00", "%e", 3.1415926535);
38 TST("Float", "3.14159", "%g", 3.1415926535);
39 TST("Float", "1.000000E+09", "%E", 1000000000.00);
40 TST("Float", "0x1p+4", "%a", 16.0);
41 TST("Float", "0x1p+10", "%a", 1024.0);
42 TST("Float", "0x1.ff8p+9", "%a", 1023.0);
43 TST("Float", "0X1.DCD65P+29", "%A", 1000000000.00);