added a primitive dictionary file loader. needs more work
This commit is contained in:
parent
f9970ef086
commit
61483e294a
@ -170,6 +170,7 @@ typedef qse_wchar_t* (*qse_wcssubst_t) (
|
||||
#define QSE_STRTONUM(value,nptr,endptr,base) do {\
|
||||
int __ston_f = 0, __ston_v; \
|
||||
const qse_char_t* __ston_ptr = nptr; \
|
||||
int __ston_base = base; \
|
||||
for (;;) { \
|
||||
qse_char_t __ston_c = *__ston_ptr; \
|
||||
if (__ston_c == QSE_T(' ') || \
|
||||
@ -178,8 +179,15 @@ typedef qse_wchar_t* (*qse_wcssubst_t) (
|
||||
else if (__ston_c == QSE_T('+')) { __ston_ptr++; } \
|
||||
break; \
|
||||
} \
|
||||
for (value = 0; (__ston_v = QSE_CHARTONUM(*__ston_ptr, base)) < base; __ston_ptr++) { \
|
||||
value = value * base + __ston_v; \
|
||||
if (base == 0) { \
|
||||
if (*__ston_ptr == QSE_T('0')) { \
|
||||
if (*(__ston_ptr + 1) == QSE_T('x') || *(__ston_ptr + 1) == QSE_T('X')) { __ston_base = 16; __ston_ptr += 2; } \
|
||||
else { __ston_base = 8; __ston_ptr++; } \
|
||||
} \
|
||||
else __ston_base = 10; \
|
||||
} \
|
||||
for (value = 0; (__ston_v = QSE_CHARTONUM(*__ston_ptr, __ston_base)) < __ston_base; __ston_ptr++) { \
|
||||
value = value * __ston_base + __ston_v; \
|
||||
} \
|
||||
if (endptr) *((const qse_char_t**)endptr) = __ston_ptr; \
|
||||
if (__ston_f > 0) value *= -1; \
|
||||
@ -190,7 +198,7 @@ typedef qse_wchar_t* (*qse_wcssubst_t) (
|
||||
int __ston_f = 0, __ston_v; \
|
||||
const qse_char_t* __ston_ptr = nptr; \
|
||||
const qse_char_t* __ston_end = __ston_ptr + len; \
|
||||
value = 0; \
|
||||
int __ston_base = base; \
|
||||
while (__ston_ptr < __ston_end) { \
|
||||
qse_char_t __ston_c = *__ston_ptr; \
|
||||
if (__ston_c == QSE_T(' ') || __ston_c == QSE_T('\t')) { \
|
||||
@ -200,9 +208,15 @@ typedef qse_wchar_t* (*qse_wcssubst_t) (
|
||||
else if (__ston_c == QSE_T('+')) { __ston_ptr++; } \
|
||||
break; \
|
||||
} \
|
||||
for (value = 0; __ston_ptr < __ston_end && \
|
||||
(__ston_v = QSE_CHARTONUM(*__ston_ptr, base)) != base; __ston_ptr++) { \
|
||||
value = value * base + __ston_v; \
|
||||
if (base == 0) { \
|
||||
if (__ston_ptr < __ston_end && *__ston_ptr == QSE_T('0')) { \
|
||||
if ((__ston_ptr < __ston_end - 1) && (*(__ston_ptr + 1) == QSE_T('x') || *(__ston_ptr + 1) == QSE_T('X'))) { __ston_base = 16; __ston_ptr += 2; } \
|
||||
else { __ston_base = 8; __ston_ptr++; } \
|
||||
} \
|
||||
else __ston_base = 10; \
|
||||
} \
|
||||
for (value = 0; __ston_ptr < __ston_end && (__ston_v = QSE_CHARTONUM(*__ston_ptr, __ston_base)) != __ston_base; __ston_ptr++) { \
|
||||
value = value * __ston_base + __ston_v; \
|
||||
} \
|
||||
if (endptr) *((const qse_char_t**)endptr) = __ston_ptr; \
|
||||
if (__ston_f > 0) value *= -1; \
|
||||
@ -218,6 +232,7 @@ typedef qse_wchar_t* (*qse_wcssubst_t) (
|
||||
#define QSE_MBSTONUM(value,nptr,endptr,base) do {\
|
||||
int __ston_f = 0, __ston_v; \
|
||||
const qse_mchar_t* __ston_ptr = nptr; \
|
||||
int __ston_base = base; \
|
||||
for (;;) { \
|
||||
qse_mchar_t __ston_c = *__ston_ptr; \
|
||||
if (__ston_c == QSE_MT(' ') || \
|
||||
@ -226,8 +241,15 @@ typedef qse_wchar_t* (*qse_wcssubst_t) (
|
||||
else if (__ston_c == QSE_MT('+')) { __ston_ptr++; } \
|
||||
break; \
|
||||
} \
|
||||
for (value = 0; (__ston_v = QSE_MCHARTONUM(*__ston_ptr, base)) < base; __ston_ptr++) { \
|
||||
value = value * base + __ston_v; \
|
||||
if (base == 0) { \
|
||||
if (*__ston_ptr == QSE_MT('0')) { \
|
||||
if (*(__ston_ptr + 1) == QSE_MT('x') || *(__ston_ptr + 1) == QSE_MT('X')) { __ston_base = 16; __ston_ptr += 2; } \
|
||||
else { __ston_base = 8; __ston_ptr++; } \
|
||||
} \
|
||||
else __ston_base = 10; \
|
||||
} \
|
||||
for (value = 0; (__ston_v = QSE_MCHARTONUM(*__ston_ptr, __ston_base)) < __ston_base; __ston_ptr++) { \
|
||||
value = value * __ston_base + __ston_v; \
|
||||
} \
|
||||
if (endptr) *((const qse_mchar_t**)endptr) = __ston_ptr; \
|
||||
if (__ston_f > 0) value *= -1; \
|
||||
@ -238,7 +260,7 @@ typedef qse_wchar_t* (*qse_wcssubst_t) (
|
||||
int __ston_f = 0, __ston_v; \
|
||||
const qse_mchar_t* __ston_ptr = nptr; \
|
||||
const qse_mchar_t* __ston_end = __ston_ptr + len; \
|
||||
value = 0; \
|
||||
int __ston_base = base; \
|
||||
while (__ston_ptr < __ston_end) { \
|
||||
qse_mchar_t __ston_c = *__ston_ptr; \
|
||||
if (__ston_c == QSE_MT(' ') || __ston_c == QSE_MT('\t')) { \
|
||||
@ -248,9 +270,15 @@ typedef qse_wchar_t* (*qse_wcssubst_t) (
|
||||
else if (__ston_c == QSE_MT('+')) { __ston_ptr++; } \
|
||||
break; \
|
||||
} \
|
||||
for (value = 0; __ston_ptr < __ston_end && \
|
||||
(__ston_v = QSE_MCHARTONUM(*__ston_ptr, base)) != base; __ston_ptr++) { \
|
||||
value = value * base + __ston_v; \
|
||||
if (base == 0) { \
|
||||
if (__ston_ptr < __ston_end && *__ston_ptr == QSE_MT('0')) { \
|
||||
if ((__ston_ptr < __ston_end - 1) && (*(__ston_ptr + 1) == QSE_MT('x') || *(__ston_ptr + 1) == QSE_MT('X'))) { __ston_base = 16; __ston_ptr += 2; } \
|
||||
else { __ston_base = 8; __ston_ptr++; } \
|
||||
} \
|
||||
else __ston_base = 10; \
|
||||
} \
|
||||
for (value = 0; __ston_ptr < __ston_end && (__ston_v = QSE_MCHARTONUM(*__ston_ptr, __ston_base)) != __ston_base; __ston_ptr++) { \
|
||||
value = value * __ston_base + __ston_v; \
|
||||
} \
|
||||
if (endptr) *((const qse_mchar_t**)endptr) = __ston_ptr; \
|
||||
if (__ston_f > 0) value *= -1; \
|
||||
@ -266,6 +294,7 @@ typedef qse_wchar_t* (*qse_wcssubst_t) (
|
||||
#define QSE_WCSTONUM(value,nptr,endptr,base) do {\
|
||||
int __ston_f = 0, __ston_v; \
|
||||
const qse_wchar_t* __ston_ptr = nptr; \
|
||||
int __ston_base = base; \
|
||||
for (;;) { \
|
||||
qse_wchar_t __ston_c = *__ston_ptr; \
|
||||
if (__ston_c == QSE_WT(' ') || \
|
||||
@ -274,8 +303,15 @@ typedef qse_wchar_t* (*qse_wcssubst_t) (
|
||||
else if (__ston_c == QSE_WT('+')) { __ston_ptr++; } \
|
||||
break; \
|
||||
} \
|
||||
for (value = 0; (__ston_v = QSE_WCHARTONUM(*__ston_ptr, base)) < base; __ston_ptr++) { \
|
||||
value = value * base + __ston_v; \
|
||||
if (base == 0) { \
|
||||
if (*__ston_ptr == QSE_WT('0')) { \
|
||||
if (*(__ston_ptr + 1) == QSE_WT('x') || *(__ston_ptr + 1) == QSE_WT('X')) { __ston_base = 16; __ston_ptr += 2; } \
|
||||
else { __ston_base = 8; __ston_ptr++; } \
|
||||
} \
|
||||
else __ston_base = 10; \
|
||||
} \
|
||||
for (value = 0; (__ston_v = QSE_WCHARTONUM(*__ston_ptr, __ston_base)) < __ston_base; __ston_ptr++) { \
|
||||
value = value * __ston_base + __ston_v; \
|
||||
} \
|
||||
if (endptr) *((const qse_wchar_t**)endptr) = __ston_ptr; \
|
||||
if (__ston_f > 0) value *= -1; \
|
||||
@ -286,7 +322,7 @@ typedef qse_wchar_t* (*qse_wcssubst_t) (
|
||||
int __ston_f = 0, __ston_v; \
|
||||
const qse_wchar_t* __ston_ptr = nptr; \
|
||||
const qse_wchar_t* __ston_end = __ston_ptr + len; \
|
||||
value = 0; \
|
||||
int __ston_base = base; \
|
||||
while (__ston_ptr < __ston_end) { \
|
||||
qse_wchar_t __ston_c = *__ston_ptr; \
|
||||
if (__ston_c == QSE_WT(' ') || __ston_c == QSE_WT('\t')) { \
|
||||
@ -296,9 +332,15 @@ typedef qse_wchar_t* (*qse_wcssubst_t) (
|
||||
else if (__ston_c == QSE_WT('+')) { __ston_ptr++; } \
|
||||
break; \
|
||||
} \
|
||||
for (value = 0; __ston_ptr < __ston_end && \
|
||||
(__ston_v = QSE_WCHARTONUM(*__ston_ptr, base)) != base; __ston_ptr++) { \
|
||||
value = value * base + __ston_v; \
|
||||
if (base == 0) { \
|
||||
if (__ston_ptr < __ston_end && *__ston_ptr == QSE_WT('0')) { \
|
||||
if ((__ston_ptr < __ston_end - 1) && (*(__ston_ptr + 1) == QSE_WT('x') || *(__ston_ptr + 1) == QSE_WT('X'))) { __ston_base = 16; __ston_ptr += 2; } \
|
||||
else { __ston_base = 8; __ston_ptr++; } \
|
||||
} \
|
||||
else __ston_base = 10; \
|
||||
} \
|
||||
for (value = 0; __ston_ptr < __ston_end && (__ston_v = QSE_WCHARTONUM(*__ston_ptr, __ston_base)) != __ston_base; __ston_ptr++) { \
|
||||
value = value * __ston_base + __ston_v; \
|
||||
} \
|
||||
if (endptr) *((const qse_wchar_t**)endptr) = __ston_ptr; \
|
||||
if (__ston_f > 0) value *= -1; \
|
||||
|
@ -30,6 +30,33 @@
|
||||
#include <qse/types.h>
|
||||
#include <qse/macros.h>
|
||||
|
||||
enum qse_raddic_opt_t
|
||||
{
|
||||
QSE_RADDIC_TRAIT
|
||||
};
|
||||
typedef enum qse_raddic_opt_t qse_raddic_opt_t;
|
||||
|
||||
enum qse_raddic_trait_t
|
||||
{
|
||||
QSE_RADDIC_ALLOW_CONST_WITHOUT_ATTR = (1 << 0)
|
||||
};
|
||||
typedef enum qse_raddic_trait_t qse_raddic_trait_t;
|
||||
|
||||
enum qse_raddic_errnum_t
|
||||
{
|
||||
QSE_RADDIC_ENOERR,
|
||||
QSE_RADDIC_EOTHER,
|
||||
QSE_RADDIC_ENOIMPL,
|
||||
QSE_RADDIC_ESYSERR,
|
||||
QSE_RADDIC_EINTERN,
|
||||
QSE_RADDIC_ENOMEM,
|
||||
QSE_RADDIC_EINVAL,
|
||||
QSE_RADDIC_ENOENT,
|
||||
QSE_RADDIC_EEXIST,
|
||||
QSE_RADDIC_ESYNERR
|
||||
};
|
||||
typedef enum qse_raddic_errnum_t qse_raddic_errnum_t;
|
||||
|
||||
#define QSE_RADDIC_ATTR_TYPE_STRING 0
|
||||
#define QSE_RADDIC_ATTR_TYPE_INTEGER 1
|
||||
#define QSE_RADDIC_ATTR_TYPE_IPADDR 2
|
||||
@ -66,7 +93,7 @@ typedef struct qse_raddic_attr_flags_t qse_raddic_attr_flags_t;
|
||||
typedef struct qse_raddic_attr_t qse_raddic_attr_t;
|
||||
struct qse_raddic_attr_t
|
||||
{
|
||||
int attr;
|
||||
qse_uint32_t attr;
|
||||
int type;
|
||||
int vendor;
|
||||
qse_raddic_attr_flags_t flags;
|
||||
@ -77,7 +104,7 @@ struct qse_raddic_attr_t
|
||||
typedef struct qse_raddic_const_t qse_raddic_const_t;
|
||||
struct qse_raddic_const_t
|
||||
{
|
||||
int attr; /* vendor + attribute-value */
|
||||
qse_uint32_t attr; /* vendor + attribute-value */
|
||||
int value;
|
||||
qse_raddic_const_t* nextc;
|
||||
qse_char_t name[1];
|
||||
@ -96,9 +123,9 @@ struct qse_raddic_vendor_t
|
||||
|
||||
typedef struct qse_raddic_t qse_raddic_t;
|
||||
|
||||
#define QSE_RADDIC_ATTR_MAKE(vendor,value) ((((vendor) & 0xFFFF) << 8) | (value))
|
||||
#define QSE_RADDIC_ATTR_VENDOR(attr) (((attr) >> 8) & 0xFFFF)
|
||||
#define QSE_RADDIC_ATTR_VALUE(attr) ((attr) & 0xFF)
|
||||
#define QSE_RADDIC_ATTR_MAKE(vendor,value) ((((vendor) & 0xFFFFu) << 16) | (value))
|
||||
#define QSE_RADDIC_ATTR_VENDOR(attr) (((attr) >> 16) & 0xFFFFu)
|
||||
#define QSE_RADDIC_ATTR_VALUE(attr) ((attr) & 0xFFFFu)
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
@ -113,6 +140,47 @@ QSE_EXPORT void qse_raddic_close (
|
||||
qse_raddic_t* dic
|
||||
);
|
||||
|
||||
QSE_EXPORT int qse_raddic_getopt (
|
||||
qse_raddic_t* raddic,
|
||||
qse_raddic_opt_t id,
|
||||
void* value
|
||||
);
|
||||
|
||||
QSE_EXPORT int qse_raddic_setopt (
|
||||
qse_raddic_t* raddic,
|
||||
qse_raddic_opt_t id,
|
||||
const void* value
|
||||
);
|
||||
|
||||
QSE_EXPORT qse_raddic_errnum_t qse_raddic_geterrnum (
|
||||
qse_raddic_t* dic
|
||||
);
|
||||
|
||||
QSE_EXPORT const qse_char_t* qse_raddic_geterrmsg (
|
||||
qse_raddic_t* dic
|
||||
);
|
||||
|
||||
QSE_EXPORT void qse_raddic_seterrnum (
|
||||
qse_raddic_t* dic,
|
||||
qse_raddic_errnum_t errnum
|
||||
);
|
||||
|
||||
QSE_EXPORT void qse_raddic_seterrfmt (
|
||||
qse_raddic_t* dic,
|
||||
qse_raddic_errnum_t errnum,
|
||||
const qse_char_t* fmt,
|
||||
...
|
||||
);
|
||||
|
||||
QSE_EXPORT void qse_raddic_clear (
|
||||
qse_raddic_t* dic
|
||||
);
|
||||
|
||||
QSE_EXPORT int qse_raddic_load (
|
||||
qse_raddic_t* dic,
|
||||
const qse_char_t* path
|
||||
);
|
||||
|
||||
QSE_EXPORT qse_raddic_vendor_t* qse_raddic_findvendorbyname (
|
||||
qse_raddic_t* dic,
|
||||
const qse_char_t* name
|
||||
@ -149,7 +217,7 @@ QSE_EXPORT qse_raddic_attr_t* qse_raddic_findattrbyname (
|
||||
|
||||
QSE_EXPORT qse_raddic_attr_t* qse_raddic_findattrbyvalue (
|
||||
qse_raddic_t* dic,
|
||||
int attr
|
||||
qse_uint32_t attr
|
||||
);
|
||||
|
||||
QSE_EXPORT qse_raddic_attr_t* qse_raddic_addattr (
|
||||
@ -172,16 +240,15 @@ QSE_EXPORT int qse_raddic_deleteattrbyvalue (
|
||||
);
|
||||
|
||||
|
||||
|
||||
QSE_EXPORT qse_raddic_const_t* qse_raddic_findconstbyname (
|
||||
qse_raddic_t* dic,
|
||||
int attr,
|
||||
qse_uint32_t attr,
|
||||
const qse_char_t* name
|
||||
);
|
||||
|
||||
QSE_EXPORT qse_raddic_const_t* qse_raddic_findconstbyvalue (
|
||||
qse_raddic_t* dic,
|
||||
int attr,
|
||||
qse_uint32_t attr,
|
||||
int value
|
||||
);
|
||||
|
||||
@ -194,13 +261,13 @@ QSE_EXPORT qse_raddic_const_t* qse_raddic_addconst (
|
||||
|
||||
QSE_EXPORT int qse_raddic_deleteconstbyname (
|
||||
qse_raddic_t* dic,
|
||||
int attr,
|
||||
qse_uint32_t attr,
|
||||
const qse_char_t* name
|
||||
);
|
||||
|
||||
QSE_EXPORT int qse_raddic_deleteconstbyvalue (
|
||||
qse_raddic_t* dic,
|
||||
int attr,
|
||||
qse_uint32_t attr,
|
||||
int value
|
||||
);
|
||||
|
||||
|
@ -340,9 +340,15 @@ int qse_htl_init (qse_htl_t* ht, qse_mmgr_t* mmgr, int keysize)
|
||||
}
|
||||
|
||||
void qse_htl_fini (qse_htl_t* ht)
|
||||
{
|
||||
qse_htl_clear (ht);
|
||||
QSE_MMGR_FREE (ht->mmgr, ht->buckets);
|
||||
}
|
||||
|
||||
void qse_htl_clear (qse_htl_t* ht)
|
||||
{
|
||||
int i;
|
||||
qse_htl_node_t *node, *next;
|
||||
qse_htl_node_t* node, * next;
|
||||
|
||||
/*
|
||||
* Walk over the buckets, freeing them all.
|
||||
@ -363,9 +369,10 @@ void qse_htl_fini (qse_htl_t* ht)
|
||||
}
|
||||
}
|
||||
|
||||
QSE_MMGR_FREE (ht->mmgr, ht->buckets);
|
||||
QSE_MEMSET (ht->buckets, 0, sizeof(*ht->buckets) * ht->num_buckets);
|
||||
ht->buckets[0] = &ht->null;
|
||||
ht->num_elements = 0;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
/*
|
||||
|
1314
qse/lib/rad/raddic.c
1314
qse/lib/rad/raddic.c
File diff suppressed because it is too large
Load Diff
@ -34,7 +34,7 @@ static qse_size_t hash_item (qse_htl_t* htl, const void* data)
|
||||
{
|
||||
item_t* item = (item_t*)data;
|
||||
//return item->a + 123445;
|
||||
return qse_genhash (&item->a, QSE_SIZEOF(item->a));
|
||||
return qse_genhash32 (&item->a, QSE_SIZEOF(item->a));
|
||||
}
|
||||
|
||||
static int comp_item (qse_htl_t* htl, const void* data1, const void* data2)
|
||||
@ -135,6 +135,7 @@ static int test2 ()
|
||||
item_t x;
|
||||
qse_htl_t* htl;
|
||||
qse_htl_node_t* np;
|
||||
int count = 0;
|
||||
|
||||
htl = qse_htl_open (QSE_MMGR_GETDFL(), 0, QSE_SIZEOF(x));
|
||||
if (htl == QSE_NULL)
|
||||
@ -148,6 +149,7 @@ static int test2 ()
|
||||
qse_htl_setcopier (htl, copy_item);
|
||||
qse_htl_setfreeer (htl, free_item);
|
||||
|
||||
again:
|
||||
for (x.a = 9; x.a < 20; x.a++)
|
||||
{
|
||||
x.x = x.a * 10;
|
||||
@ -195,6 +197,15 @@ static int test2 ()
|
||||
|
||||
qse_printf (QSE_T("total %lu items\n"), (unsigned long)qse_htl_getsize(htl));
|
||||
qse_htl_walk (htl, walk2, QSE_NULL);
|
||||
|
||||
qse_htl_clear (htl);
|
||||
if (count == 0)
|
||||
{
|
||||
count++;
|
||||
qse_printf (QSE_T("<<<TRAYING AGAIN ....>>>\n"));
|
||||
goto again;
|
||||
}
|
||||
|
||||
qse_htl_close (htl);
|
||||
return 0;
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
#include <qse/cmn/str.h>
|
||||
#include <qse/rad/raddic.h>
|
||||
#include <qse/si/sio.h>
|
||||
#include <string.h>
|
||||
|
||||
#define R(f) \
|
||||
do { \
|
||||
@ -9,41 +10,40 @@
|
||||
if (f() == -1) return -1; \
|
||||
} while (0)
|
||||
|
||||
#define FAIL(msg) qse_printf(QSE_T("FAILURE in %hs line %d - %hs\n"), __func__, __LINE__, msg)
|
||||
#define FAIL(msg) qse_printf(QSE_T("FAILURE in %hs line %d - %s\n"), __func__, __LINE__, msg)
|
||||
#define _assert(test,msg) do { if (!(test)) { FAIL(msg); return -1; } } while(0)
|
||||
#define _verify(test) do { int r=test(); tests_run++; if(r) return r; } while(0)
|
||||
|
||||
static int test1 ()
|
||||
{
|
||||
qse_raddic_t* dic;
|
||||
qse_raddic_vendor_t* vendor, * v;
|
||||
qse_raddic_attr_t* attr, * a;
|
||||
qse_raddic_vendor_t* vendor, * v;
|
||||
int i;
|
||||
|
||||
dic = qse_raddic_open (QSE_MMGR_GETDFL(), 0);
|
||||
_assert (dic != QSE_NULL, "unable to create a radius dictionary");
|
||||
_assert (dic != QSE_NULL, QSE_T("unable to create a radius dictionary"));
|
||||
|
||||
vendor = qse_raddic_addvendor (dic, QSE_T("abiyo.net"), 12365);
|
||||
_assert (vendor != QSE_NULL, "unable to add the first vendor");
|
||||
_assert (vendor->vendorpec == 12365, "the vendor value is not 12365");
|
||||
_assert (qse_strcasecmp(vendor->name, QSE_T("abiyo.net")) == 0, "the vendor name is not abiyo.net");
|
||||
_assert (vendor != QSE_NULL, QSE_T("unable to add the first vendor"));
|
||||
_assert (vendor->vendorpec == 12365, QSE_T("the vendor value is not 12365"));
|
||||
_assert (qse_strcasecmp(vendor->name, QSE_T("abiyo.net")) == 0, QSE_T("the vendor name is not abiyo.net"));
|
||||
|
||||
vendor = qse_raddic_addvendor (dic, QSE_T("abiyo.net"), 99999);
|
||||
_assert (vendor == QSE_NULL, "a duplicate name must not be allowed");
|
||||
_assert (vendor == QSE_NULL, QSE_T("a duplicate name must not be allowed"));
|
||||
|
||||
vendor = qse_raddic_addvendor (dic, QSE_T("abiyo-aliased.net"), 12365);
|
||||
_assert (vendor != QSE_NULL, "unable to add a duplicate id");
|
||||
_assert (vendor != QSE_NULL, QSE_T("unable to add a duplicate id"));
|
||||
|
||||
vendor = qse_raddic_findvendorbyname (dic, QSE_T("Abiyo.Net"));
|
||||
_assert (vendor != QSE_NULL && vendor->vendorpec == 12365, "unable to find a vendor named Abiyo.Net");
|
||||
_assert (vendor != QSE_NULL && vendor->vendorpec == 12365, QSE_T("unable to find a vendor named Abiyo.Net"));
|
||||
|
||||
vendor = qse_raddic_findvendorbyvalue (dic, 12365);
|
||||
_assert (vendor != QSE_NULL && vendor->vendorpec == 12365, "unable to find a vendor of value 12365");
|
||||
_assert (qse_strcasecmp(vendor->name, QSE_T("abiyo-aliased.net")) == 0, "unable to find a vendor of value 12365");
|
||||
_assert (vendor != QSE_NULL && vendor->vendorpec == 12365, QSE_T("unable to find a vendor of value 12365"));
|
||||
_assert (qse_strcasecmp(vendor->name, QSE_T("abiyo-aliased.net")) == 0, QSE_T("unable to find a vendor of value 12365"));
|
||||
|
||||
vendor = qse_raddic_findvendorbyname (dic, QSE_T("Abiyo-aliased.Net"));
|
||||
_assert (vendor != QSE_NULL && vendor->vendorpec == 12365, "unable to find a vendor named Abiyo-aliased.Net");
|
||||
_assert (qse_strcasecmp(vendor->name, QSE_T("abiyo-aliased.net")) == 0, "unable to find a vendor of value 12365");
|
||||
_assert (vendor != QSE_NULL && vendor->vendorpec == 12365, QSE_T("unable to find a vendor named Abiyo-aliased.Net"));
|
||||
_assert (qse_strcasecmp(vendor->name, QSE_T("abiyo-aliased.net")) == 0, QSE_T("unable to find a vendor of value 12365"));
|
||||
|
||||
#define COUNT1 600
|
||||
#define COUNT2 700
|
||||
@ -53,9 +53,9 @@ static int test1 ()
|
||||
qse_char_t tmp[64];
|
||||
qse_strxfmt(tmp, QSE_COUNTOF(tmp), QSE_T("test-%d"), i);
|
||||
vendor = qse_raddic_addvendor (dic, tmp, i);
|
||||
_assert (vendor != QSE_NULL, "unable to add a vendor");
|
||||
_assert (vendor->vendorpec == i, "wrong vendor value");
|
||||
_assert (qse_strcasecmp(vendor->name, tmp) == 0, "wrong vendor name");
|
||||
_assert (vendor != QSE_NULL, QSE_T("unable to add a vendor"));
|
||||
_assert (vendor->vendorpec == i, QSE_T("wrong vendor value"));
|
||||
_assert (qse_strcasecmp(vendor->name, tmp) == 0, QSE_T("wrong vendor name"));
|
||||
}
|
||||
|
||||
for (i = 1; i < COUNT1; i++)
|
||||
@ -63,9 +63,9 @@ static int test1 ()
|
||||
qse_char_t tmp[64];
|
||||
qse_strxfmt(tmp, QSE_COUNTOF(tmp), QSE_T("test-%d"), i);
|
||||
vendor = qse_raddic_findvendorbyname (dic, tmp);
|
||||
_assert (vendor != QSE_NULL, "unable to find a vendor");
|
||||
_assert (vendor->vendorpec == i, "wrong vendor value");
|
||||
_assert (qse_strcasecmp(vendor->name, tmp) == 0, "wrong vendor name");
|
||||
_assert (vendor != QSE_NULL, QSE_T("unable to find a vendor"));
|
||||
_assert (vendor->vendorpec == i, QSE_T("wrong vendor value"));
|
||||
_assert (qse_strcasecmp(vendor->name, tmp) == 0, QSE_T("wrong vendor name"));
|
||||
}
|
||||
|
||||
for (i = 1; i < COUNT1; i++)
|
||||
@ -73,9 +73,9 @@ static int test1 ()
|
||||
qse_char_t tmp[64];
|
||||
qse_strxfmt(tmp, QSE_COUNTOF(tmp), QSE_T("test-%d"), i);
|
||||
vendor = qse_raddic_findvendorbyvalue (dic, i);
|
||||
_assert (vendor != QSE_NULL, "unable to find a vendor");
|
||||
_assert (vendor->vendorpec == i, "wrong vendor value");
|
||||
_assert (qse_strcasecmp(vendor->name, tmp) == 0, "wrong vendor name");
|
||||
_assert (vendor != QSE_NULL, QSE_T("unable to find a vendor"));
|
||||
_assert (vendor->vendorpec == i, QSE_T("wrong vendor value"));
|
||||
_assert (qse_strcasecmp(vendor->name, tmp) == 0, QSE_T("wrong vendor name"));
|
||||
}
|
||||
|
||||
for (i = COUNT1; i < COUNT2; i++)
|
||||
@ -84,12 +84,12 @@ static int test1 ()
|
||||
qse_strxfmt(tmp, QSE_COUNTOF(tmp), QSE_T("test-%d"), i);
|
||||
vendor = qse_raddic_addvendor (dic, tmp, COUNT1);
|
||||
// insert different items with the same value
|
||||
_assert (vendor != QSE_NULL, "unable to add a vendor");
|
||||
_assert (vendor->vendorpec == COUNT1, "wrong vendor value");
|
||||
_assert (qse_strcasecmp(vendor->name, tmp) == 0, "wrong vendor name");
|
||||
_assert (vendor != QSE_NULL, QSE_T("unable to add a vendor"));
|
||||
_assert (vendor->vendorpec == COUNT1, QSE_T("wrong vendor value"));
|
||||
_assert (qse_strcasecmp(vendor->name, tmp) == 0, QSE_T("wrong vendor name"));
|
||||
|
||||
v = qse_raddic_findvendorbyvalue (dic, COUNT1);
|
||||
_assert (vendor == v, "unable to find a last added vendor by value");
|
||||
_assert (vendor == v, QSE_T("unable to find a last added vendor by value"));
|
||||
}
|
||||
|
||||
for (i = COUNT1; i < COUNT2 - 1; i++)
|
||||
@ -100,24 +100,24 @@ static int test1 ()
|
||||
qse_strxfmt(tmp, QSE_COUNTOF(tmp), QSE_T("test-%d"), i);
|
||||
|
||||
n = qse_raddic_deletevendorbyname (dic, tmp);
|
||||
_assert (n == 0, "unable to delete a vendor");
|
||||
_assert (n == 0, QSE_T("unable to delete a vendor"));
|
||||
|
||||
v = qse_raddic_findvendorbyname (dic, tmp);
|
||||
_assert (v == QSE_NULL, "vendor found errorenously");
|
||||
_assert (v == QSE_NULL, QSE_T("vendor found errorenously"));
|
||||
|
||||
if (i == COUNT2 - 1)
|
||||
{
|
||||
v = qse_raddic_findvendorbyvalue (dic, COUNT1);
|
||||
_assert (v == QSE_NULL, "vendor of COUNT1 found errorenously");
|
||||
_assert (v == QSE_NULL, QSE_T("vendor of COUNT1 found errorenously"));
|
||||
}
|
||||
else
|
||||
{
|
||||
qse_strxfmt(tmp, QSE_COUNTOF(tmp), QSE_T("test-%d"), i + 1);
|
||||
v = qse_raddic_findvendorbyname (dic, tmp);
|
||||
_assert (v != QSE_NULL && v->vendorpec == COUNT1 && qse_strcasecmp(tmp, v->name) == 0, "unable to find an expected vendor");
|
||||
_assert (v != QSE_NULL && v->vendorpec == COUNT1 && qse_strcasecmp(tmp, v->name) == 0, QSE_T("unable to find an expected vendor"));
|
||||
|
||||
v = qse_raddic_findvendorbyvalue (dic, COUNT1);
|
||||
_assert (v != QSE_NULL && v->vendorpec == COUNT1, "unable to find the vendor of COUNT1");
|
||||
_assert (v != QSE_NULL && v->vendorpec == COUNT1, QSE_T("unable to find the vendor of COUNT1"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -128,7 +128,7 @@ static int test1 ()
|
||||
|
||||
qse_strxfmt(tmp, QSE_COUNTOF(tmp), QSE_T("test-%d"), i);
|
||||
n = qse_raddic_deletevendorbyname (dic, tmp);
|
||||
_assert (n == 0, "unable to delete a vendor");
|
||||
_assert (n == 0, QSE_T("unable to delete a vendor"));
|
||||
}
|
||||
|
||||
for (i = 1; i < COUNT1; i++)
|
||||
@ -136,31 +136,31 @@ static int test1 ()
|
||||
qse_char_t tmp[64];
|
||||
qse_strxfmt(tmp, QSE_COUNTOF(tmp), QSE_T("test-%d"), i);
|
||||
v = qse_raddic_addvendor (dic, tmp, i);
|
||||
_assert (v != QSE_NULL && v->vendorpec == i, "unable to add a vendor");
|
||||
_assert (v != QSE_NULL && v->vendorpec == i, QSE_T("unable to add a vendor"));
|
||||
|
||||
qse_strxfmt(tmp, QSE_COUNTOF(tmp), QSE_T("testx-%d"), i);
|
||||
v = qse_raddic_addvendor (dic, tmp, i);
|
||||
_assert (v != QSE_NULL && v->vendorpec == i, "unable to add a vendor");
|
||||
_assert (v != QSE_NULL && v->vendorpec == i, QSE_T("unable to add a vendor"));
|
||||
|
||||
qse_strxfmt(tmp, QSE_COUNTOF(tmp), QSE_T("testy-%d"), i);
|
||||
v = qse_raddic_addvendor (dic, tmp, i);
|
||||
_assert (v != QSE_NULL && v->vendorpec == i, "unable to add a vendor");
|
||||
_assert (v != QSE_NULL && v->vendorpec == i, QSE_T("unable to add a vendor"));
|
||||
}
|
||||
|
||||
for (i = 1; i < COUNT1; i++)
|
||||
{
|
||||
int n;
|
||||
n = qse_raddic_deletevendorbyvalue (dic, i);
|
||||
_assert (n == 0, "unable to delete a vendor by value");
|
||||
_assert (n == 0, QSE_T("unable to delete a vendor by value"));
|
||||
|
||||
n = qse_raddic_deletevendorbyvalue (dic, i);
|
||||
_assert (n == 0, "unable to delete a vendor by value");
|
||||
_assert (n == 0, QSE_T("unable to delete a vendor by value"));
|
||||
|
||||
n = qse_raddic_deletevendorbyvalue (dic, i);
|
||||
_assert (n == 0, "unable to delete a vendor by value");
|
||||
_assert (n == 0, QSE_T("unable to delete a vendor by value"));
|
||||
|
||||
n = qse_raddic_deletevendorbyvalue (dic, i);
|
||||
_assert (n <= -1, "erroreneously successful vendor deletion by value");
|
||||
_assert (n <= -1, QSE_T("erroreneously successful vendor deletion by value"));
|
||||
}
|
||||
|
||||
qse_raddic_close (dic);
|
||||
@ -177,7 +177,7 @@ static int test2 ()
|
||||
int i, j;
|
||||
|
||||
dic = qse_raddic_open (QSE_MMGR_GETDFL(), 0);
|
||||
_assert (dic != QSE_NULL, "unable to create a radius dictionary");
|
||||
_assert (dic != QSE_NULL, QSE_T("unable to create a radius dictionary"));
|
||||
|
||||
memset (&f, 0, QSE_SIZEOF(f));
|
||||
|
||||
@ -188,9 +188,9 @@ static int test2 ()
|
||||
qse_char_t tmp[64];
|
||||
qse_strxfmt(tmp, QSE_COUNTOF(tmp), QSE_T("test-%d-%d"), j, i);
|
||||
attr = qse_raddic_addattr (dic, tmp, j, QSE_RADDIC_ATTR_TYPE_STRING, i, &f);
|
||||
_assert (attr != QSE_NULL, "unable to add an attribute");
|
||||
_assert (attr->attr == QSE_RADDIC_ATTR_MAKE(j, i), "wrong attr value");
|
||||
_assert (qse_strcasecmp(attr->name, tmp) == 0, "wrong attr name");
|
||||
_assert (attr != QSE_NULL, QSE_T("unable to add an attribute"));
|
||||
_assert (attr->attr == QSE_RADDIC_ATTR_MAKE(j, i), QSE_T("wrong attr value"));
|
||||
_assert (qse_strcasecmp(attr->name, tmp) == 0, QSE_T("wrong attr name"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -201,14 +201,14 @@ static int test2 ()
|
||||
qse_char_t tmp[64];
|
||||
qse_strxfmt(tmp, QSE_COUNTOF(tmp), QSE_T("test-%d-%d"), j, i);
|
||||
attr = qse_raddic_findattrbyname (dic, tmp);
|
||||
_assert (attr != QSE_NULL, "unable to find an attribute");
|
||||
_assert (attr->attr == QSE_RADDIC_ATTR_MAKE(j, i), "wrong attr value");
|
||||
_assert (qse_strcasecmp(attr->name, tmp) == 0, "wrong attr name");
|
||||
_assert (attr != QSE_NULL, QSE_T("unable to find an attribute"));
|
||||
_assert (attr->attr == QSE_RADDIC_ATTR_MAKE(j, i), QSE_T("wrong attr value"));
|
||||
_assert (qse_strcasecmp(attr->name, tmp) == 0, QSE_T("wrong attr name"));
|
||||
|
||||
attr = qse_raddic_findattrbyvalue (dic, QSE_RADDIC_ATTR_MAKE(j, i));
|
||||
_assert (attr != QSE_NULL, "unable to find an attribute");
|
||||
_assert (attr->attr == QSE_RADDIC_ATTR_MAKE(j, i), "wrong attr value");
|
||||
_assert (qse_strcasecmp(attr->name, tmp) == 0, "wrong attr name");
|
||||
_assert (attr != QSE_NULL, QSE_T("unable to find an attribute"));
|
||||
_assert (attr->attr == QSE_RADDIC_ATTR_MAKE(j, i), QSE_T("wrong attr value"));
|
||||
_assert (qse_strcasecmp(attr->name, tmp) == 0, QSE_T("wrong attr name"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -219,15 +219,15 @@ static int test2 ()
|
||||
qse_char_t tmp[64];
|
||||
qse_strxfmt(tmp, QSE_COUNTOF(tmp), QSE_T("testx-%d-%d"), j, i);
|
||||
attr = qse_raddic_addattr (dic, tmp, j, QSE_RADDIC_ATTR_TYPE_STRING, i, &f);
|
||||
_assert (attr != QSE_NULL, "unable to add an attribute");
|
||||
_assert (attr->attr == QSE_RADDIC_ATTR_MAKE(j, i), "wrong attr value");
|
||||
_assert (qse_strcasecmp(attr->name, tmp) == 0, "wrong attr name");
|
||||
_assert (attr != QSE_NULL, QSE_T("unable to add an attribute"));
|
||||
_assert (attr->attr == QSE_RADDIC_ATTR_MAKE(j, i), QSE_T("wrong attr value"));
|
||||
_assert (qse_strcasecmp(attr->name, tmp) == 0, QSE_T("wrong attr name"));
|
||||
|
||||
qse_strxfmt(tmp, QSE_COUNTOF(tmp), QSE_T("testy-%d-%d"), j, i);
|
||||
attr = qse_raddic_addattr (dic, tmp, j, QSE_RADDIC_ATTR_TYPE_STRING, i, &f);
|
||||
_assert (attr != QSE_NULL, "unable to add an attribute");
|
||||
_assert (attr->attr == QSE_RADDIC_ATTR_MAKE(j, i), "wrong attr value");
|
||||
_assert (qse_strcasecmp(attr->name, tmp) == 0, "wrong attr name");
|
||||
_assert (attr != QSE_NULL, QSE_T("unable to add an attribute"));
|
||||
_assert (attr->attr == QSE_RADDIC_ATTR_MAKE(j, i), QSE_T("wrong attr value"));
|
||||
_assert (qse_strcasecmp(attr->name, tmp) == 0, QSE_T("wrong attr name"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -241,34 +241,34 @@ static int test2 ()
|
||||
qse_strxfmt(tmpy, QSE_COUNTOF(tmpy), QSE_T("testy-%d-%d"), j, i);
|
||||
|
||||
attr = qse_raddic_findattrbyname (dic, tmp);
|
||||
_assert (attr != QSE_NULL, "unable to add an attribute");
|
||||
_assert (attr->attr == QSE_RADDIC_ATTR_MAKE(j, i), "wrong attr value");
|
||||
_assert (qse_strcasecmp(attr->name, tmp) == 0, "wrong attr name");
|
||||
_assert (attr != QSE_NULL, QSE_T("unable to add an attribute"));
|
||||
_assert (attr->attr == QSE_RADDIC_ATTR_MAKE(j, i), QSE_T("wrong attr value"));
|
||||
_assert (qse_strcasecmp(attr->name, tmp) == 0, QSE_T("wrong attr name"));
|
||||
|
||||
attr = qse_raddic_findattrbyname (dic, tmpx);
|
||||
_assert (attr != QSE_NULL, "unable to add an attribute");
|
||||
_assert (attr->attr == QSE_RADDIC_ATTR_MAKE(j, i), "wrong attr value");
|
||||
_assert (qse_strcasecmp(attr->name, tmpx) == 0, "wrong attr name");
|
||||
_assert (attr != QSE_NULL, QSE_T("unable to add an attribute"));
|
||||
_assert (attr->attr == QSE_RADDIC_ATTR_MAKE(j, i), QSE_T("wrong attr value"));
|
||||
_assert (qse_strcasecmp(attr->name, tmpx) == 0, QSE_T("wrong attr name"));
|
||||
|
||||
attr = qse_raddic_findattrbyname (dic, tmpy);
|
||||
_assert (attr != QSE_NULL, "unable to add an attribute");
|
||||
_assert (attr->attr == QSE_RADDIC_ATTR_MAKE(j, i), "wrong attr value");
|
||||
_assert (qse_strcasecmp(attr->name, tmpy) == 0, "wrong attr name");
|
||||
_assert (attr != QSE_NULL, QSE_T("unable to add an attribute"));
|
||||
_assert (attr->attr == QSE_RADDIC_ATTR_MAKE(j, i), QSE_T("wrong attr value"));
|
||||
_assert (qse_strcasecmp(attr->name, tmpy) == 0, QSE_T("wrong attr name"));
|
||||
|
||||
attr = qse_raddic_findattrbyvalue (dic, QSE_RADDIC_ATTR_MAKE(j, i));
|
||||
_assert (attr != QSE_NULL, "unable to add an attribute");
|
||||
_assert (attr->attr == QSE_RADDIC_ATTR_MAKE(j, i), "wrong attr value");
|
||||
_assert (qse_strcasecmp(attr->name, tmpy) == 0, "wrong attr name");
|
||||
_assert (attr != QSE_NULL, QSE_T("unable to add an attribute"));
|
||||
_assert (attr->attr == QSE_RADDIC_ATTR_MAKE(j, i), QSE_T("wrong attr value"));
|
||||
_assert (qse_strcasecmp(attr->name, tmpy) == 0, QSE_T("wrong attr name"));
|
||||
|
||||
_assert (attr->nexta != QSE_NULL, "unable to find an old attribute");
|
||||
_assert (attr->nexta->attr == QSE_RADDIC_ATTR_MAKE(j, i), "wrong attr value");
|
||||
_assert (qse_strcasecmp(attr->nexta->name, tmpx) == 0, "wrong attr name");
|
||||
_assert (attr->nexta != QSE_NULL, QSE_T("unable to find an old attribute"));
|
||||
_assert (attr->nexta->attr == QSE_RADDIC_ATTR_MAKE(j, i), QSE_T("wrong attr value"));
|
||||
_assert (qse_strcasecmp(attr->nexta->name, tmpx) == 0, QSE_T("wrong attr name"));
|
||||
|
||||
_assert (attr->nexta->nexta != QSE_NULL, "unable to find an old attribute");
|
||||
_assert (attr->nexta->nexta->attr == QSE_RADDIC_ATTR_MAKE(j, i), "wrong attr value");
|
||||
_assert (qse_strcasecmp(attr->nexta->nexta->name, tmp) == 0, "wrong attr name");
|
||||
_assert (attr->nexta->nexta != QSE_NULL, QSE_T("unable to find an old attribute"));
|
||||
_assert (attr->nexta->nexta->attr == QSE_RADDIC_ATTR_MAKE(j, i), QSE_T("wrong attr value"));
|
||||
_assert (qse_strcasecmp(attr->nexta->nexta->name, tmp) == 0, QSE_T("wrong attr name"));
|
||||
|
||||
_assert (attr->nexta->nexta->nexta == QSE_NULL, "wrong attribute chian");
|
||||
_assert (attr->nexta->nexta->nexta == QSE_NULL, QSE_T("wrong attribute chian"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -281,7 +281,7 @@ static int test2 ()
|
||||
|
||||
qse_strxfmt(tmp, QSE_COUNTOF(tmp), QSE_T("testx-%d-%d"), j, i);
|
||||
n = qse_raddic_deleteattrbyname (dic, tmp);
|
||||
_assert (n == 0, "erroreneous attribute deletion failure by name");
|
||||
_assert (n == 0, QSE_T("erroreneous attribute deletion failure by name"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -295,28 +295,28 @@ static int test2 ()
|
||||
qse_strxfmt(tmpy, QSE_COUNTOF(tmpy), QSE_T("testy-%d-%d"), j, i);
|
||||
|
||||
attr = qse_raddic_findattrbyname (dic, tmp);
|
||||
_assert (attr != QSE_NULL, "unable to add an attribute");
|
||||
_assert (attr->attr == QSE_RADDIC_ATTR_MAKE(j, i), "wrong attr value");
|
||||
_assert (qse_strcasecmp(attr->name, tmp) == 0, "wrong attr name");
|
||||
_assert (attr != QSE_NULL, QSE_T("unable to add an attribute"));
|
||||
_assert (attr->attr == QSE_RADDIC_ATTR_MAKE(j, i), QSE_T("wrong attr value"));
|
||||
_assert (qse_strcasecmp(attr->name, tmp) == 0, QSE_T("wrong attr name"));
|
||||
|
||||
attr = qse_raddic_findattrbyname (dic, tmpx);
|
||||
_assert (attr == QSE_NULL, "errorneous search success");
|
||||
_assert (attr == QSE_NULL, QSE_T("errorneous search success"));
|
||||
|
||||
attr = qse_raddic_findattrbyname (dic, tmpy);
|
||||
_assert (attr != QSE_NULL, "unable to add an attribute");
|
||||
_assert (attr->attr == QSE_RADDIC_ATTR_MAKE(j, i), "wrong attr value");
|
||||
_assert (qse_strcasecmp(attr->name, tmpy) == 0, "wrong attr name");
|
||||
_assert (attr != QSE_NULL, QSE_T("unable to add an attribute"));
|
||||
_assert (attr->attr == QSE_RADDIC_ATTR_MAKE(j, i), QSE_T("wrong attr value"));
|
||||
_assert (qse_strcasecmp(attr->name, tmpy) == 0, QSE_T("wrong attr name"));
|
||||
|
||||
attr = qse_raddic_findattrbyvalue (dic, QSE_RADDIC_ATTR_MAKE(j, i));
|
||||
_assert (attr != QSE_NULL, "unable to add an attribute");
|
||||
_assert (attr->attr == QSE_RADDIC_ATTR_MAKE(j, i), "wrong attr value");
|
||||
_assert (qse_strcasecmp(attr->name, tmpy) == 0, "wrong attr name");
|
||||
_assert (attr != QSE_NULL, QSE_T("unable to add an attribute"));
|
||||
_assert (attr->attr == QSE_RADDIC_ATTR_MAKE(j, i), QSE_T("wrong attr value"));
|
||||
_assert (qse_strcasecmp(attr->name, tmpy) == 0, QSE_T("wrong attr name"));
|
||||
|
||||
_assert (attr->nexta != QSE_NULL, "unable to find an old attribute");
|
||||
_assert (attr->nexta->attr == QSE_RADDIC_ATTR_MAKE(j, i), "wrong attr value");
|
||||
_assert (qse_strcasecmp(attr->nexta->name, tmp) == 0, "wrong attr name");
|
||||
_assert (attr->nexta != QSE_NULL, QSE_T("unable to find an old attribute"));
|
||||
_assert (attr->nexta->attr == QSE_RADDIC_ATTR_MAKE(j, i), QSE_T("wrong attr value"));
|
||||
_assert (qse_strcasecmp(attr->nexta->name, tmp) == 0, QSE_T("wrong attr name"));
|
||||
|
||||
_assert (attr->nexta->nexta == QSE_NULL, "wrong attribute chian");
|
||||
_assert (attr->nexta->nexta == QSE_NULL, QSE_T("wrong attribute chian"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -324,13 +324,13 @@ static int test2 ()
|
||||
{
|
||||
int n;
|
||||
n = qse_raddic_deleteattrbyvalue (dic, QSE_RADDIC_ATTR_MAKE(0, 0));
|
||||
_assert (n == 0, "errorneous deletion failure by value");
|
||||
_assert (n == 0, QSE_T("errorneous deletion failure by value"));
|
||||
|
||||
n = qse_raddic_deleteattrbyvalue (dic, QSE_RADDIC_ATTR_MAKE(0, 0));
|
||||
_assert (n == 0, "errorneous deletion failure by value");
|
||||
_assert (n == 0, QSE_T("errorneous deletion failure by value"));
|
||||
|
||||
n = qse_raddic_deleteattrbyvalue (dic, QSE_RADDIC_ATTR_MAKE(0, 0));
|
||||
_assert (n <= -1, "errorneous deletion success by value");
|
||||
_assert (n <= -1, QSE_T("errorneous deletion success by value"));
|
||||
}
|
||||
|
||||
|
||||
@ -342,9 +342,9 @@ static int test2 ()
|
||||
qse_strxfmt(attrstr, QSE_COUNTOF(attrstr), QSE_T("test-%d-%d"), j, i);
|
||||
qse_strxfmt(constr, QSE_COUNTOF(constr), QSE_T("const-%d-%d"), j, i);
|
||||
con = qse_raddic_addconst (dic, constr, attrstr, 10);
|
||||
_assert (con != QSE_NULL, "unable to add an constant");
|
||||
_assert (con->value == 10, "wrong constant value");
|
||||
_assert (qse_strcasecmp(con->name, constr) == 0, "wrong constant name");
|
||||
_assert (con != QSE_NULL, QSE_T("unable to add an constant"));
|
||||
_assert (con->value == 10, QSE_T("wrong constant value"));
|
||||
_assert (qse_strcasecmp(con->name, constr) == 0, QSE_T("wrong constant name"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -356,14 +356,14 @@ static int test2 ()
|
||||
qse_strxfmt(constr, QSE_COUNTOF(constr), QSE_T("const-%d-%d"), j, i);
|
||||
|
||||
con = qse_raddic_findconstbyname (dic, QSE_RADDIC_ATTR_MAKE(j, i), constr);
|
||||
_assert (con != QSE_NULL, "unable to find an constant");
|
||||
_assert (con->attr == QSE_RADDIC_ATTR_MAKE(j, i), "wrong constant value");
|
||||
_assert (con->value == 10, "wrong constant value");
|
||||
_assert (con != QSE_NULL, QSE_T("unable to find an constant"));
|
||||
_assert (con->attr == QSE_RADDIC_ATTR_MAKE(j, i), QSE_T("wrong constant value"));
|
||||
_assert (con->value == 10, QSE_T("wrong constant value"));
|
||||
|
||||
con = qse_raddic_findconstbyvalue (dic, QSE_RADDIC_ATTR_MAKE(j, i), 10);
|
||||
_assert (con != QSE_NULL, "unable to find an constant");
|
||||
_assert (con->value == 10, "wrong constant value");
|
||||
_assert (con->attr == QSE_RADDIC_ATTR_MAKE(j, i), "wrong constant value");
|
||||
_assert (con != QSE_NULL, QSE_T("unable to find an constant"));
|
||||
_assert (con->value == 10, QSE_T("wrong constant value"));
|
||||
_assert (con->attr == QSE_RADDIC_ATTR_MAKE(j, i), QSE_T("wrong constant value"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -371,30 +371,50 @@ static int test2 ()
|
||||
{
|
||||
int n;
|
||||
n = qse_raddic_deleteconstbyname (dic, QSE_RADDIC_ATTR_MAKE(1,1), QSE_T("const-1-1"));
|
||||
_assert (n == 0, "errorneous constant deletion failure");
|
||||
_assert (n == 0, QSE_T("errorneous constant deletion failure"));
|
||||
|
||||
n = qse_raddic_deleteconstbyname (dic, QSE_RADDIC_ATTR_MAKE(1,1), QSE_T("const-1-1"));
|
||||
_assert (n <= -1, "errorneous constant deletion success");
|
||||
_assert (n <= -1, QSE_T("errorneous constant deletion success"));
|
||||
|
||||
n = qse_raddic_deleteconstbyvalue (dic, QSE_RADDIC_ATTR_MAKE(2,2), 20);
|
||||
_assert (n <= -1, "errorneous constant deletion success");
|
||||
_assert (n <= -1, QSE_T("errorneous constant deletion success"));
|
||||
|
||||
n = qse_raddic_deleteconstbyvalue (dic, QSE_RADDIC_ATTR_MAKE(2,2), 10);
|
||||
_assert (n == 0, "errorneous constant deletion success");
|
||||
_assert (n == 0, QSE_T("errorneous constant deletion success"));
|
||||
|
||||
n = qse_raddic_deleteconstbyvalue (dic, QSE_RADDIC_ATTR_MAKE(2,2), 10);
|
||||
_assert (n <= -1, "errorneous constant deletion success");
|
||||
_assert (n <= -1, QSE_T("errorneous constant deletion success"));
|
||||
}
|
||||
|
||||
qse_raddic_close (dic);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int test3 ()
|
||||
{
|
||||
qse_raddic_t* dic;
|
||||
int n, trait;
|
||||
|
||||
dic = qse_raddic_open (QSE_MMGR_GETDFL(), 0);
|
||||
_assert (dic != QSE_NULL, QSE_T("unable to create a radius dictionary"));
|
||||
|
||||
trait = QSE_RADDIC_ALLOW_CONST_WITHOUT_ATTR;
|
||||
n = qse_raddic_setopt (dic, QSE_RADDIC_TRAIT, &trait);
|
||||
_assert (n == 0, QSE_T("cannot set trait"));
|
||||
|
||||
n = qse_raddic_load (dic, QSE_T("dictionary"));
|
||||
_assert (n == 0, qse_raddic_geterrmsg(dic));
|
||||
|
||||
qse_raddic_close (dic);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main ()
|
||||
{
|
||||
qse_open_stdsios ();
|
||||
R (test1);
|
||||
R (test2);
|
||||
R (test3);
|
||||
qse_close_stdsios ();
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user