X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Usermode%2FLibraries%2Flibc.so_src%2FTEST_strtoi.c;h=cf2d2698ebc24649157adce39fcdeb84c4973ad8;hb=db55040ba8814edf681d4ccc12ad8955d8aa404a;hp=62f2e695fa2d84738ef5fd0ef0e52987d59e3208;hpb=0b3db65a6c3babf70808360b455f9b9e1886655f;p=tpg%2Facess2.git diff --git a/Usermode/Libraries/libc.so_src/TEST_strtoi.c b/Usermode/Libraries/libc.so_src/TEST_strtoi.c index 62f2e695..cf2d2698 100644 --- a/Usermode/Libraries/libc.so_src/TEST_strtoi.c +++ b/Usermode/Libraries/libc.so_src/TEST_strtoi.c @@ -18,14 +18,20 @@ char *end;\ errno = 0;\ t ret = strto##class(in, &end, base); \ - if( ret != exp ) \ + if( ret != exp ) { \ fprintf(stderr, "FAIL strto"#class"('%s') != "#exp" (act "fmt")\n", in, ret);\ - if( end != in+ofs ) \ + exit(1); \ + } \ + if( end != in+ofs ) { \ fprintf(stderr, "FAIL strto"#class"('%s') returned wrong end: %p (+%zi) instead of %p (+%zi)\n",\ in,end,end-in,in+ofs,(size_t)ofs);\ - if( exp_errno != errno ) \ + exit(1); \ + } \ + if( exp_errno != errno ) { \ fprintf(stderr, "FAIL strto"#class"('%s') returned wrong errno, exp '%s', got '%s'\n",\ in, strerror(exp_errno), strerror(errno));\ + exit(1); \ + } \ }while(0) #define PRIMEBUF(fmt, val) buf_len = snprintf(buf, sizeof(buf), fmt, val) @@ -41,6 +47,8 @@ int main(int argc, char *argv[]) TST(unsigned long long, ull, 0, "01234567", 01234567, "%llo", 8, 0); TST(unsigned long long, ull, 0, "1234567", 1234567, "%lld", 7, 0); TST(long long, ll, 0, "-1", -1, "%lld", 2, 0); // -1 + TST(long long, ll, 0, "100113", 100113, "%lld", strlen(in), 0); + TST(long long, ll, 0, "0x101", 0x101, "0x%llx", strlen(in), 0); // Invalid strings TST(unsigned long long, ull, 0, "0x", 0, "%llx", 1, 0); // Single 0