Changeset 1397 for pjproject/trunk/pjlib/src/pjlib-test/string.c
- Timestamp:
- Jun 28, 2007 12:50:10 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjlib/src/pjlib-test/string.c
r1266 r1397 72 72 PJ_INLINE(int) cmp(const char *expr, int i, int j) 73 73 { 74 i = !((i>0 && j>0) || (i<0 && j<0) || (i==0 && j==0));75 if ( i) {74 int r = !((i>0 && j>0) || (i<0 && j<0) || (i==0 && j==0)); 75 if (r) { 76 76 PJ_LOG(3,(THIS_FILE," error: %s: expecting %d, got %d", expr, j, i)); 77 77 } 78 return i;78 return r; 79 79 } 80 80 #else … … 95 95 * pj_strnicmp2(). 96 96 */ 97 #define STRTEST(res, S1,S2,code) \97 #define STRTEST(res,res2,S1,S2,code) \ 98 98 do { \ 99 99 s1.ptr=S1; s1.slen=(S1)?len:0; \ … … 109 109 pj_sub_timestamp(&t2, &t1); \ 110 110 pj_add_timestamp(&e2, &t2); \ 111 if (C(pj_stricmp2(&s1,S2),res )) return code*10; \111 if (C(pj_stricmp2(&s1,S2),res2)) return code*10; \ 112 112 if (C(pj_strnicmp(&s1,&s2,len),res)) return code*100; \ 113 113 if (C(pj_strnicmp2(&s1,S2,len),res)) return code*1000; \ … … 128 128 /* Compare empty strings. */ 129 129 len=0; 130 STRTEST( 0, "","",-500);131 STRTEST( 0, SNULL,"",-502);132 STRTEST( 0, "",SNULL,-504);133 STRTEST( 0, SNULL,SNULL,-506);134 STRTEST( 0, "hello","world",-508);130 STRTEST( 0, 0, "","",-500); 131 STRTEST( 0, 0, SNULL,"",-502); 132 STRTEST( 0, 0, "",SNULL,-504); 133 STRTEST( 0, 0, SNULL,SNULL,-506); 134 STRTEST( 0, -1, "hello","world",-508); 135 135 136 136 /* equal, length=1 … … 139 139 buf = "a""A"; 140 140 len=1; 141 STRTEST( 0, "a",buf+0,-510);142 STRTEST( 0, "a",buf+1,-512);143 STRTEST( -1, "O", "P", -514);144 STRTEST(-1, SNULL, "a", -516);145 STRTEST( 1, "a", SNULL, -518);141 STRTEST( 0, -1, "a",buf+0,-510); 142 STRTEST( 0, 0, "a",buf+1,-512); 143 STRTEST(-1, -1, "O", "P", -514); 144 STRTEST(-1, -1, SNULL, "a", -516); 145 STRTEST( 1, 1, "a", SNULL, -518); 146 146 147 147 /* equal, length=2 … … 150 150 buf = "aa""Aa""aA""AA"; 151 151 len=2; 152 STRTEST( 0, "aa",buf+0,-520);153 STRTEST( 0, "aa",buf+2,-522);154 STRTEST( 0, "aa",buf+4,-524);155 STRTEST( 0, "aa",buf+6,-524);152 STRTEST( 0, -1, "aa",buf+0,-520); 153 STRTEST( 0, -1, "aa",buf+2,-522); 154 STRTEST( 0, -1, "aa",buf+4,-524); 155 STRTEST( 0, 0, "aa",buf+6,-524); 156 156 157 157 /* equal, length=3 … … 160 160 buf = "aaa""Aaa""aAa""aaA""AAa""aAA""AaA""AAA"; 161 161 len=3; 162 STRTEST( 0, "aaa",buf+0,-530);163 STRTEST( 0, "aaa",buf+3,-532);164 STRTEST( 0, "aaa",buf+6,-534);165 STRTEST( 0, "aaa",buf+9,-536);166 STRTEST( 0, "aaa",buf+12,-538);167 STRTEST( 0, "aaa",buf+15,-540);168 STRTEST( 0, "aaa",buf+18,-542);169 STRTEST( 0, "aaa",buf+21,-534);162 STRTEST( 0, -1, "aaa",buf+0,-530); 163 STRTEST( 0, -1, "aaa",buf+3,-532); 164 STRTEST( 0, -1, "aaa",buf+6,-534); 165 STRTEST( 0, -1, "aaa",buf+9,-536); 166 STRTEST( 0, -1, "aaa",buf+12,-538); 167 STRTEST( 0, -1, "aaa",buf+15,-540); 168 STRTEST( 0, -1, "aaa",buf+18,-542); 169 STRTEST( 0, 0, "aaa",buf+21,-534); 170 170 171 171 /* equal, length=4 */ 172 172 len=4; 173 STRTEST( 0, "aaaa","aaaa",-540);174 STRTEST( 0, "aaaa","Aaaa",-542);175 STRTEST( 0, "aaaa","aAaa",-544);176 STRTEST( 0, "aaaa","aaAa",-546);177 STRTEST( 0, "aaaa","aaaA",-548);178 STRTEST( 0, "aaaa","AAaa",-550);179 STRTEST( 0, "aaaa","aAAa",-552);180 STRTEST( 0, "aaaa","aaAA",-554);181 STRTEST( 0, "aaaa","AaAa",-556);182 STRTEST( 0, "aaaa","aAaA",-558);183 STRTEST( 0, "aaaa","AaaA",-560);184 STRTEST( 0, "aaaa","AAAa",-562);185 STRTEST( 0, "aaaa","aAAA",-564);186 STRTEST( 0, "aaaa","AAaA",-566);187 STRTEST( 0, "aaaa","AaAA",-568);188 STRTEST( 0, "aaaa","AAAA",-570);173 STRTEST( 0, 0, "aaaa","aaaa",-540); 174 STRTEST( 0, 0, "aaaa","Aaaa",-542); 175 STRTEST( 0, 0, "aaaa","aAaa",-544); 176 STRTEST( 0, 0, "aaaa","aaAa",-546); 177 STRTEST( 0, 0, "aaaa","aaaA",-548); 178 STRTEST( 0, 0, "aaaa","AAaa",-550); 179 STRTEST( 0, 0, "aaaa","aAAa",-552); 180 STRTEST( 0, 0, "aaaa","aaAA",-554); 181 STRTEST( 0, 0, "aaaa","AaAa",-556); 182 STRTEST( 0, 0, "aaaa","aAaA",-558); 183 STRTEST( 0, 0, "aaaa","AaaA",-560); 184 STRTEST( 0, 0, "aaaa","AAAa",-562); 185 STRTEST( 0, 0, "aaaa","aAAA",-564); 186 STRTEST( 0, 0, "aaaa","AAaA",-566); 187 STRTEST( 0, 0, "aaaa","AaAA",-568); 188 STRTEST( 0, 0, "aaaa","AAAA",-570); 189 189 190 190 /* equal, length=5 */ 191 191 buf = "aaaAa""AaaaA""AaAaA""AAAAA"; 192 192 len=5; 193 STRTEST( 0, "aaaaa",buf+0,-580);194 STRTEST( 0, "aaaaa",buf+5,-582);195 STRTEST( 0, "aaaaa",buf+10,-584);196 STRTEST( 0, "aaaaa",buf+15,-586);193 STRTEST( 0, -1, "aaaaa",buf+0,-580); 194 STRTEST( 0, -1, "aaaaa",buf+5,-582); 195 STRTEST( 0, -1, "aaaaa",buf+10,-584); 196 STRTEST( 0, 0, "aaaaa",buf+15,-586); 197 197 198 198 /* not equal, length=1 */ 199 199 len=1; 200 STRTEST( -1, "a", "b", -600);200 STRTEST( -1, -1, "a", "b", -600); 201 201 202 202 /* not equal, length=2 */ 203 203 buf = "ab""ba"; 204 204 len=2; 205 STRTEST( -1, "aa", buf+0, -610);206 STRTEST( -1, "aa", buf+2, -612);205 STRTEST( -1, -1, "aa", buf+0, -610); 206 STRTEST( -1, -1, "aa", buf+2, -612); 207 207 208 208 /* not equal, length=3 */ 209 209 buf = "aab""aba""baa"; 210 210 len=3; 211 STRTEST( -1, "aaa", buf+0, -620);212 STRTEST( -1, "aaa", buf+3, -622);213 STRTEST( -1, "aaa", buf+6, -624);211 STRTEST( -1, -1, "aaa", buf+0, -620); 212 STRTEST( -1, -1, "aaa", buf+3, -622); 213 STRTEST( -1, -1, "aaa", buf+6, -624); 214 214 215 215 /* not equal, length=4 */ 216 216 buf = "aaab""aaba""abaa""baaa"; 217 217 len=4; 218 STRTEST( -1, "aaaa", buf+0, -630);219 STRTEST( -1, "aaaa", buf+4, -632);220 STRTEST( -1, "aaaa", buf+8, -634);221 STRTEST( -1, "aaaa", buf+12, -636);218 STRTEST( -1, -1, "aaaa", buf+0, -630); 219 STRTEST( -1, -1, "aaaa", buf+4, -632); 220 STRTEST( -1, -1, "aaaa", buf+8, -634); 221 STRTEST( -1, -1, "aaaa", buf+12, -636); 222 222 223 223 /* not equal, length=5 */ 224 224 buf="aaaab""aaaba""aabaa""abaaa""baaaa"; 225 225 len=5; 226 STRTEST( -1, "aaaaa", buf+0, -640);227 STRTEST( -1, "aaaaa", buf+5, -642);228 STRTEST( -1, "aaaaa", buf+10, -644);229 STRTEST( -1, "aaaaa", buf+15, -646);230 STRTEST( -1, "aaaaa", buf+20, -648);226 STRTEST( -1, -1, "aaaaa", buf+0, -640); 227 STRTEST( -1, -1, "aaaaa", buf+5, -642); 228 STRTEST( -1, -1, "aaaaa", buf+10, -644); 229 STRTEST( -1, -1, "aaaaa", buf+15, -646); 230 STRTEST( -1, -1, "aaaaa", buf+20, -648); 231 231 232 232 zero.u32.hi = zero.u32.lo = 0;
Note: See TracChangeset
for help on using the changeset viewer.