#include <string.h>
#include "gwlib/gwlib.h"
Go to the source code of this file.
◆ check_comparisons()
static 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().
76 static const char *tab[] = {
81 "abcåäö ,
"ABCÅÄÖ",
};
static const int n = sizeof(tab) / sizeof(tab[0]);
int i, j;
int sign_str, sign_oct;
Octstr *os1, *os2;
for (i = 0; i < n; ++i) {
os1 = octstr_create(tab[i]);
for (j = 0; j < n; ++j) {
os2 = octstr_create(tab[j]);
sign_str = signof(strcmp(tab[i], tab[j]));
sign_oct = signof(octstr_compare(os1, os2));
if (sign_str != sign_oct)
panic(0, "strcmp (%d) and octstr_compare (%d) differ for "
"`%s' and `%s'", sign_str, sign_oct, tab[i], tab[j]);
sign_str = signof(strcasecmp(tab[i], tab[j]));
sign_oct = signof(octstr_case_compare(os1, os2));
if (sign_str != sign_oct)
panic(0, "strcasecmp (%d) and octstr_case_compare (%d) "
"differ for `%s' and `%s'", sign_str, sign_oct,
tab[i], tab[j]);
octstr_destroy(os2);
}
octstr_destroy(os1);
}
}
",
82 "ABCÅÄÖ ,
};
static const int n = sizeof(tab) / sizeof(tab[0]);
int i, j;
int sign_str, sign_oct;
Octstr *os1, *os2;
for (i = 0; i < n; ++i) {
os1 = octstr_create(tab[i]);
for (j = 0; j < n; ++j) {
os2 = octstr_create(tab[j]);
sign_str = signof(strcmp(tab[i], tab[j]));
sign_oct = signof(octstr_compare(os1, os2));
if (sign_str != sign_oct)
panic(0, "strcmp (%d) and octstr_compare (%d) differ for "
"`%s' and `%s'", sign_str, sign_oct, tab[i], tab[j]);
sign_str = signof(strcasecmp(tab[i], tab[j]));
sign_oct = signof(octstr_case_compare(os1, os2));
if (sign_str != sign_oct)
panic(0, "strcasecmp (%d) and octstr_case_compare (%d) "
"differ for `%s' and `%s'", sign_str, sign_oct,
tab[i], tab[j]);
octstr_destroy(os2);
}
octstr_destroy(os1);
}
}
",
84 static const int n =
sizeof(tab) /
sizeof(tab[0]);
86 int sign_str, sign_oct;
89 for (i = 0; i < n; ++i) {
91 for (j = 0; j < n; ++j) {
94 sign_str =
signof(strcmp(tab[i], tab[j]));
96 if (sign_str != sign_oct)
97 panic(0,
"strcmp (%d) and octstr_compare (%d) differ for " 98 "`%s' and `%s'", sign_str, sign_oct, tab[i], tab[j]);
100 sign_str =
signof(strcasecmp(tab[i], tab[j]));
102 if (sign_str != sign_oct)
103 panic(0,
"strcasecmp (%d) and octstr_case_compare (%d) " 104 "differ for `%s' and `%s'", sign_str, sign_oct,
int octstr_case_compare(const Octstr *os1, const Octstr *os2)
void octstr_destroy(Octstr *ostr)
#define octstr_create(cstr)
int octstr_compare(const Octstr *ostr1, const Octstr *ostr2)
◆ main()
◆ signof()
static int signof |
( |
int |
n | ) |
|
|
static |