diff options
Diffstat (limited to 'src/set/test_set_union_copy.c')
-rw-r--r-- | src/set/test_set_union_copy.c | 65 |
1 files changed, 46 insertions, 19 deletions
diff --git a/src/set/test_set_union_copy.c b/src/set/test_set_union_copy.c index 83a5862dd..c887a8958 100644 --- a/src/set/test_set_union_copy.c +++ b/src/set/test_set_union_copy.c | |||
@@ -115,7 +115,8 @@ check_count_iter (void *cls, | |||
115 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 115 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
116 | "Expected count (what: %s) to be %u, but it's actually %u\n", | 116 | "Expected count (what: %s) to be %u, but it's actually %u\n", |
117 | ci_cls->what, | 117 | ci_cls->what, |
118 | ci_cls->expected_count, ci_cls->ongoing_count); | 118 | ci_cls->expected_count, |
119 | ci_cls->ongoing_count); | ||
119 | ret = 1; | 120 | ret = 1; |
120 | GNUNET_SCHEDULER_shutdown (); | 121 | GNUNET_SCHEDULER_shutdown (); |
121 | return GNUNET_NO; | 122 | return GNUNET_NO; |
@@ -123,8 +124,13 @@ check_count_iter (void *cls, | |||
123 | ci_cls->cont (ci_cls->cont_cls); | 124 | ci_cls->cont (ci_cls->cont_cls); |
124 | return GNUNET_NO; | 125 | return GNUNET_NO; |
125 | } | 126 | } |
127 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
128 | "Set `%s' has element %.*s\n", | ||
129 | ci_cls->what, | ||
130 | (int) element->size, | ||
131 | (const char *) element->data); | ||
126 | 132 | ||
127 | ci_cls->ongoing_count += 1; | 133 | ci_cls->ongoing_count++; |
128 | return GNUNET_YES; | 134 | return GNUNET_YES; |
129 | } | 135 | } |
130 | 136 | ||
@@ -138,6 +144,10 @@ check_count (struct GNUNET_SET_Handle *set, | |||
138 | { | 144 | { |
139 | struct CountIterClosure *ci_cls = GNUNET_new (struct CountIterClosure); | 145 | struct CountIterClosure *ci_cls = GNUNET_new (struct CountIterClosure); |
140 | 146 | ||
147 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
148 | "Checking count of %s\n", | ||
149 | what); | ||
150 | |||
141 | ci_cls->expected_count = expected_count; | 151 | ci_cls->expected_count = expected_count; |
142 | ci_cls->ongoing_count = 0; | 152 | ci_cls->ongoing_count = 0; |
143 | ci_cls->cont = cont; | 153 | ci_cls->cont = cont; |
@@ -163,7 +173,7 @@ check_new_set_count (void *cls) | |||
163 | { | 173 | { |
164 | check_count (set2, | 174 | check_count (set2, |
165 | "new set", | 175 | "new set", |
166 | 4, | 176 | 3, |
167 | &test_done, | 177 | &test_done, |
168 | NULL); | 178 | NULL); |
169 | } | 179 | } |
@@ -173,15 +183,23 @@ static void | |||
173 | copy_done (void *cls, | 183 | copy_done (void *cls, |
174 | struct GNUNET_SET_Handle *new_set) | 184 | struct GNUNET_SET_Handle *new_set) |
175 | { | 185 | { |
176 | printf ("copy done\n"); | 186 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
187 | "copy done\n"); | ||
177 | set2 = new_set; | 188 | set2 = new_set; |
178 | remove_element_str (set2, "spam"); | 189 | remove_element_str (set2, |
179 | add_element_str (set2, "new1"); | 190 | "k5555"); |
180 | add_element_str (set2, "new2"); | 191 | add_element_str (set2, |
181 | remove_element_str (set2, "new2"); | 192 | "n66666"); |
182 | remove_element_str (set2, "new3"); | 193 | add_element_str (set2, |
194 | "new2butremoved"); | ||
195 | remove_element_str (set2, | ||
196 | "new2butremoved"); | ||
197 | remove_element_str (set2, | ||
198 | "new3justremoved"); | ||
183 | // Check that set1 didn't change. | 199 | // Check that set1 didn't change. |
184 | check_count (set1, "old set", 3, | 200 | check_count (set1, |
201 | "old set", | ||
202 | 3, | ||
185 | &check_new_set_count, | 203 | &check_new_set_count, |
186 | NULL); | 204 | NULL); |
187 | } | 205 | } |
@@ -190,7 +208,8 @@ copy_done (void *cls, | |||
190 | static void | 208 | static void |
191 | test_copy (void *cls) | 209 | test_copy (void *cls) |
192 | { | 210 | { |
193 | printf ("about to copy\n"); | 211 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
212 | "about to copy\n"); | ||
194 | GNUNET_SET_copy_lazy (set1, | 213 | GNUNET_SET_copy_lazy (set1, |
195 | ©_done, | 214 | ©_done, |
196 | NULL); | 215 | NULL); |
@@ -246,17 +265,25 @@ run (void *cls, | |||
246 | &local_id); | 265 | &local_id); |
247 | 266 | ||
248 | set1 = GNUNET_SET_create (cfg, GNUNET_SET_OPERATION_UNION); | 267 | set1 = GNUNET_SET_create (cfg, GNUNET_SET_OPERATION_UNION); |
249 | add_element_str (set1, "foo"); | 268 | add_element_str (set1, |
250 | add_element_str (set1, "bar"); | 269 | "333"); |
270 | add_element_str (set1, | ||
271 | "k444"); | ||
251 | /* duplicate -- ignored */ | 272 | /* duplicate -- ignored */ |
252 | add_element_str (set1, "bar"); | 273 | add_element_str (set1, |
253 | remove_element_str (set1, "foo"); | 274 | "k444"); |
275 | remove_element_str (set1, | ||
276 | "333"); | ||
254 | /* non-existent -- ignored */ | 277 | /* non-existent -- ignored */ |
255 | remove_element_str (set1, "nonexist1"); | 278 | remove_element_str (set1, |
256 | add_element_str (set1, "spam"); | 279 | "999999999"); |
280 | add_element_str (set1, | ||
281 | "k5555"); | ||
257 | /* duplicate -- ignored */ | 282 | /* duplicate -- ignored */ |
258 | remove_element_str (set1, "foo"); | 283 | remove_element_str (set1, |
259 | add_element_str (set1, "eggs"); | 284 | "333"); |
285 | add_element_str (set1, | ||
286 | "k2"); | ||
260 | 287 | ||
261 | check_count (set1, | 288 | check_count (set1, |
262 | "initial test", | 289 | "initial test", |