6 const char *strings[]={
7 /* some simple stuff */
9 "100", "1000", "10000", "100000", "1000000",
10 "10000000", "100000000", "1000000000",
14 "-100", "-1000", "-10000", "-100000", "-1000000",
15 "-10000000", "-100000000", "-1000000000",
18 "a", "b", "f", "g", "z",
21 "0x0", "0x1", "0xa", "0xf", "0x10",
24 "00", "01", "07", "08", "0a", "010",
29 /* check overflow cases: (for 32 bit) */
62 int n_tests=sizeof(strings)/sizeof(strings[0]);
64 void do_test(int base);
65 void do_utest(int base);
67 int main(int argc,char *argv[])
84 void do_test(int base)
90 for(i=0;i<n_tests;i++){
91 n=strtol(strings[i],&endptr,base);
92 printf("strtol(\"%s\",%d) len=%lu res=%ld\n",
93 strings[i],base,(unsigned long)(endptr-strings[i]),n);
97 void do_utest(int base)
103 for(i=0;i<n_tests;i++){
104 n=strtoul(strings[i],&endptr,base);
105 printf("strtoul(\"%s\",%d) len=%lu res=%lu\n",
106 strings[i],base,(unsigned long)(endptr-strings[i]),n);