Changeset 136 for pjproject/trunk/pjlib/src/pjlibtest/string.c
 Timestamp:
 Feb 3, 2006 3:23:28 PM (19 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

pjproject/trunk/pjlib/src/pjlibtest/string.c
r126 r136 22 22 #include <pj/os.h> 23 23 #include "test.h" 24 25 #define THIS_FILE "string.c" 24 26 25 27 /** … … 65 67 #define UL_VALUE 3456789012UL 66 68 69 #if 1 70 /* See if both integers have the same sign */ 71 PJ_INLINE(int) cmp(const char *expr, int i, int j) 72 { 73 i = !((i>0 && j>0)  (i<0 && j<0)  (i==0 && j==0)); 74 if (i) { 75 PJ_LOG(3,(THIS_FILE," error: %s: expecting %d, got %d", expr, j, i)); 76 } 77 return i; 78 } 79 #else 80 /* For strict comparison, must be equal */ 81 PJ_INLINE(int) cmp(const char *expr, int i, int j) 82 { 83 PJ_UNUSED_ARG(expr); 84 return i!=j; 85 } 86 #endif 87 88 #define C(expr, res) cmp(#expr, expr, res) 89 67 90 static int stricmp_test(void) 68 91 { … … 76 99 s2.ptr=S2; s2.slen=S2?len:0; \ 77 100 pj_get_timestamp(&t1); \ 78 if ( pj_stricmp(&s1,&s2)!=res) return code; \101 if (C(pj_stricmp(&s1,&s2),res)) return code; \ 79 102 pj_get_timestamp(&t2); \ 80 103 pj_sub_timestamp(&t2, &t1); \ 81 104 pj_add_timestamp(&e1, &t2); \ 82 105 pj_get_timestamp(&t1); \ 83 if ( pj_stricmp_alnum(&s1,&s2)!=res) return code1; \106 if (C(pj_stricmp_alnum(&s1,&s2),res)) return code1; \ 84 107 pj_get_timestamp(&t2); \ 85 108 pj_sub_timestamp(&t2, &t1); \ 86 109 pj_add_timestamp(&e2, &t2); \ 87 if ( pj_stricmp2(&s1,S2)!=res) return code*10; \88 if ( pj_strnicmp(&s1,&s2,len)!=res) return code*100; \89 if ( pj_strnicmp2(&s1,S2,len)!=res) return code*1000; \110 if (C(pj_stricmp2(&s1,S2),res)) return code*10; \ 111 if (C(pj_strnicmp(&s1,&s2,len),res)) return code*100; \ 112 if (C(pj_strnicmp2(&s1,S2,len),res)) return code*1000; \ 90 113 } while (0) 91 114 … … 115 138 STRTEST( 0, "a",buf+0,510); 116 139 STRTEST( 0, "a",buf+1,512); 117 STRTEST( 1, " 0", "P", 514);140 STRTEST( 1, "O", "P", 514); 118 141 STRTEST(1, NULL, "a", 516); 119 142 STRTEST(1, "a", NULL, 518); … … 228 251 s1.ptr=S1; s1.slen=S1?len:0; \ 229 252 s2.ptr=S2; s2.slen=S2?len:0; \ 230 if ( pj_strcmp(&s1,&s2)!=res) return code; \231 if ( pj_strcmp2(&s1,S2)!=res) return code1; \232 if ( pj_strncmp(&s1,&s2,len)!=res) return code2; \233 if ( pj_strncmp2(&s1,S2,len)!=res) return code3; \253 if (C(pj_strcmp(&s1,&s2),res)) return code; \ 254 if (C(pj_strcmp2(&s1,S2),res)) return code1; \ 255 if (C(pj_strncmp(&s1,&s2,len),res)) return code2; \ 256 if (C(pj_strncmp2(&s1,S2,len),res)) return code3; \ 234 257 } while (0) 235 258
Note: See TracChangeset
for help on using the changeset viewer.