Ignore:
Timestamp:
Feb 3, 2006 3:23:28 PM (18 years ago)
Author:
bennylp
Message:

Added gcov-report build target and fixed bug in string test under gcov

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjlib/src/pjlib-test/string.c

    r126 r136  
    2222#include <pj/os.h> 
    2323#include "test.h" 
     24 
     25#define THIS_FILE       "string.c" 
    2426 
    2527/** 
     
    6567#define UL_VALUE        3456789012UL 
    6668 
     69#if 1 
     70/* See if both integers have the same sign */ 
     71PJ_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 */ 
     81PJ_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 
    6790static int stricmp_test(void) 
    6891{ 
     
    7699                s2.ptr=S2; s2.slen=S2?len:0; \ 
    77100                pj_get_timestamp(&t1); \ 
    78                 if (pj_stricmp(&s1,&s2)!=res) return code; \ 
     101                if (C(pj_stricmp(&s1,&s2),res)) return code; \ 
    79102                pj_get_timestamp(&t2); \ 
    80103                pj_sub_timestamp(&t2, &t1); \ 
    81104                pj_add_timestamp(&e1, &t2); \ 
    82105                pj_get_timestamp(&t1); \ 
    83                 if (pj_stricmp_alnum(&s1,&s2)!=res) return code-1; \ 
     106                if (C(pj_stricmp_alnum(&s1,&s2),res)) return code-1; \ 
    84107                pj_get_timestamp(&t2); \ 
    85108                pj_sub_timestamp(&t2, &t1); \ 
    86109                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; \ 
    90113            } while (0) 
    91114 
     
    115138    STRTEST( 0, "a",buf+0,-510); 
    116139    STRTEST( 0, "a",buf+1,-512); 
    117     STRTEST( -1, "0", "P", -514); 
     140    STRTEST( -1, "O", "P", -514); 
    118141    STRTEST(-1, NULL, "a", -516); 
    119142    STRTEST(1, "a", NULL, -518); 
     
    228251                s1.ptr=S1; s1.slen=S1?len:0; \ 
    229252                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 code-1; \ 
    232                 if (pj_strncmp(&s1,&s2,len)!=res) return code-2; \ 
    233                 if (pj_strncmp2(&s1,S2,len)!=res) return code-3; \ 
     253                if (C(pj_strcmp(&s1,&s2),res)) return code; \ 
     254                if (C(pj_strcmp2(&s1,S2),res)) return code-1; \ 
     255                if (C(pj_strncmp(&s1,&s2,len),res)) return code-2; \ 
     256                if (C(pj_strncmp2(&s1,S2,len),res)) return code-3; \ 
    234257            } while (0) 
    235258 
Note: See TracChangeset for help on using the changeset viewer.