X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=support%2Fregression%2Ftests%2Fzeropad.c;h=e04bb8848dc1d7d890d29c4e989f1b79774b47ce;hb=84fb81b57dc769b19740a964732b4c6ea7f5ad29;hp=299be534f478e8a8954ce82e488b03beae2788ac;hpb=5716b14e4fb0d350bfae21840c5bdcf0483505bb;p=fw%2Fsdcc diff --git a/support/regression/tests/zeropad.c b/support/regression/tests/zeropad.c index 299be534..e04bb884 100644 --- a/support/regression/tests/zeropad.c +++ b/support/regression/tests/zeropad.c @@ -8,8 +8,11 @@ #if defined __GNUC__ #define FLEXARRAY (__GNUC__ >= 3) + //since g fails on GCC 2.95.4 on alpha and I don't know how to detect alpha... + #define TEST_G (__GNUC__ >= 3) #else #define FLEXARRAY 1 + #define TEST_G 1 #endif #include @@ -22,17 +25,32 @@ typedef unsigned int size_t; # define xdata # define code #endif +#if defined(SDCC_hc08) +# define idata +#endif + +const char *string1 = "\x00\x01"; +const char string2[] = "\x00\x01"; + +#ifndef PORT_HOST +#pragma disable_warning 147 //no warning about excess initializers (W_EXCESS_INITIALIZERS) +//array will be truncated but warning will be suppressed +//if truncation is incorrect, other ASSERTs will fail with high probability +char STORAGE trunc[2] = {'a', 'b', 'c'}; +#endif char STORAGE array[5] = {'a', 'b', 'c'}; -struct w { - char a; - int b; -} STORAGE g[3] = { - {'x', 1}, - {'y'}, - {'z', 3} -}; +#if TEST_G + struct w { + char a; + int b; + } STORAGE g[3] = { + {'x', 1}, + {'y'}, + {'z', 3} + }; +#endif struct x { short a; @@ -59,13 +77,18 @@ struct y STORAGE incompletestruct = { void testZeropad(void) { + ASSERT(string1[1] == '\x01'); + ASSERT(string2[1] == '\x01'); + ASSERT(array[2] == 'c'); ASSERT(array[4] == 0); +#if TEST_G ASSERT(g[1].a == 'y'); ASSERT(g[1].b == 0); ASSERT(g[2].a == 'z'); ASSERT(g[2].b == 3); +#endif ASSERT(teststruct[0].b[1] == 2); ASSERT(teststruct[0].b[5] == 0);