Main Page | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

check_octstr.c File Reference

#include <string.h>
#include "gwlib/gwlib.h"

Include dependency graph for check_octstr.c:

Include dependency graph

Go to the source code of this file.

Functions

int signof (int n)
void check_comparisons (void)
int main (void)


Function Documentation

void check_comparisons void   )  [static]
 

Definition at line 74 of file check_octstr.c.

References octstr_case_compare(), octstr_compare(), octstr_create, octstr_destroy(), panic, and signof().

Referenced by main().

00075 {
00076     static const char *tab[] = {
00077     "",
00078     "a",
00079     "ab",
00080     "abc",
00081     "abcåäö",
00082     "ABCÅÄÖ",
00083     };
00084     static const int n = sizeof(tab) / sizeof(tab[0]);
00085     int i, j;
00086     int sign_str, sign_oct;
00087     Octstr *os1, *os2;
00088     
00089     for (i = 0; i < n; ++i) {
00090     os1 = octstr_create(tab[i]);
00091         for (j = 0; j < n; ++j) {
00092         os2 = octstr_create(tab[j]);
00093 
00094         sign_str = signof(strcmp(tab[i], tab[j]));
00095         sign_oct = signof(octstr_compare(os1, os2));
00096         if (sign_str != sign_oct)
00097             panic(0, "strcmp (%d) and octstr_compare (%d) differ for "
00098               "`%s' and `%s'", sign_str, sign_oct, tab[i], tab[j]);
00099 
00100         sign_str = signof(strcasecmp(tab[i], tab[j]));
00101         sign_oct = signof(octstr_case_compare(os1, os2));
00102         if (sign_str != sign_oct)
00103             panic(0, "strcasecmp (%d) and octstr_case_compare (%d) "
00104               "differ for `%s' and `%s'", sign_str, sign_oct,
00105               tab[i], tab[j]);
00106         
00107         octstr_destroy(os2);
00108     }
00109     octstr_destroy(os1);
00110     }
00111 }

Here is the call graph for this function:

int main void   ) 
 

Definition at line 114 of file check_octstr.c.

References check_comparisons(), GW_INFO, gwlib_init(), gwlib_shutdown(), and log_set_output_level().

00115 {
00116     gwlib_init();
00117     log_set_output_level(GW_INFO);
00118     check_comparisons();
00119     gwlib_shutdown();
00120     return 0;
00121 }

Here is the call graph for this function:

int signof int  n  )  [static]
 

Definition at line 65 of file check_octstr.c.

Referenced by check_comparisons().

00066 {
00067     if (n < 0)
00068         return -1;
00069     if (n == 0)
00070         return 0;
00071     return 1;
00072 }

See file LICENSE for details about the license agreement for using, modifying, copying or deriving work from this software.