59 |
int l = pairlist_length(pl1); |
int l = pairlist_length(pl1); |
60 |
CU_TEST(l==3); |
CU_TEST(l==3); |
61 |
CU_TEST(3==pairlist_append_unique(pl1,"C","value4")); |
CU_TEST(3==pairlist_append_unique(pl1,"C","value4")); |
62 |
|
CU_TEST(4==pairlist_append_unique(pl1,"F","value7")); |
63 |
void *old; |
void *old; |
64 |
old = pairlist_set(pl1,"C","value5"); |
old = pairlist_set(pl1,"C","value5"); |
65 |
CU_TEST(strcmp(old,"value3")==0); |
CU_TEST(strcmp(old,"value3")==0); |
75 |
teardown(); |
teardown(); |
76 |
MEMUSED(0); |
MEMUSED(0); |
77 |
} |
} |
78 |
|
|
79 |
//------------------------ |
//------------------------ |
80 |
|
|
81 |
|
static void test_clear(void){ |
82 |
|
setup(); |
83 |
|
struct pairlist_t *pl1 = pairlist_create(10); |
84 |
|
pairlist_append(pl1,"A","value1"); |
85 |
|
pairlist_append(pl1,"B","value2"); |
86 |
|
pairlist_append(pl1,"C","value3"); |
87 |
|
CU_TEST(3==pairlist_length(pl1)); |
88 |
|
pairlist_clear(pl1); |
89 |
|
CU_TEST(0==pairlist_length(pl1)); |
90 |
|
pairlist_destroy(pl1); |
91 |
|
teardown(); |
92 |
|
} |
93 |
|
|
94 |
|
//------------------------ |
95 |
|
|
96 |
|
static void test_vad(void){ |
97 |
|
setup(); |
98 |
|
struct pairlist_t *pl1 = pairlist_create(10); |
99 |
|
pairlist_append(pl1,"A","value1"); |
100 |
|
pairlist_append(pl1,"B","value2"); |
101 |
|
pairlist_append(pl1,"C","value3"); |
102 |
|
CU_TEST(3==pairlist_length(pl1)); |
103 |
|
|
104 |
|
struct gl_list_t *vl = pairlist_values_and_destroy(pl1); |
105 |
|
|
106 |
|
CU_TEST(3==gl_length(vl)); |
107 |
|
CU_TEST(0==strcmp((char *)gl_fetch(vl,1),"value1")); |
108 |
|
CU_TEST(0==strcmp((char *)gl_fetch(vl,2),"value2")); |
109 |
|
CU_TEST(0==strcmp((char *)gl_fetch(vl,3),"value3")); |
110 |
|
gl_destroy(vl); |
111 |
|
|
112 |
|
teardown(); |
113 |
|
} |
114 |
|
|
115 |
|
|
116 |
/*===========================================================================*/ |
/*===========================================================================*/ |
117 |
/* Registration information */ |
/* Registration information */ |
118 |
|
|
119 |
|
|
120 |
#define TESTS(T) \ |
#define TESTS(T) \ |
121 |
T(createdestroy) \ |
T(createdestroy) \ |
122 |
T(setappend) |
T(setappend) \ |
123 |
|
T(clear) \ |
124 |
|
T(vad) |
125 |
|
|
126 |
REGISTER_TESTS_SIMPLE(general_pairlist, TESTS); |
REGISTER_TESTS_SIMPLE(general_pairlist, TESTS); |
127 |
|
|