Groonga 3.0.9 Source Code Document
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
test-hash-cursor.c
Go to the documentation of this file.
1 /* -*- c-basic-offset: 2; coding: utf-8 -*- */
2 /*
3  Copyright (C) 2008-2012 Kouhei Sutou <kou@clear-code.com>
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Lesser General Public
7  License version 2.1 as published by the Free Software Foundation.
8 
9  This library is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  Lesser General Public License for more details.
13 
14  You should have received a copy of the GNU Lesser General Public
15  License along with this library; if not, write to the Free Software
16  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18 
19 #include "test-hash.h"
20 
21 void data_next_with_no_entry(void);
22 void test_next_with_no_entry(gconstpointer data);
23 void data_next_with_one_entry(void);
24 void test_next_with_one_entry(gconstpointer data);
26 void test_next_with_multi_entries(gconstpointer data);
27 void data_value(void);
28 void test_value(gconstpointer data);
29 void data_delete(void);
30 void test_delete(gconstpointer data);
31 
32 static GList *keys;
33 static GList *keys_and_values;
34 
35 void
37 {
38  startup_hash_common();
39 }
40 
41 void
43 {
44  shutdown_hash_common();
45 }
46 
47 void
48 cut_setup(void)
49 {
50  setup_hash_common("hash-cursor");
51 
52  keys = NULL;
53  keys_and_values = NULL;
54 
57 
58  sample_value = NULL;
59 }
60 
61 static void
62 keys_free(void)
63 {
64  if (keys) {
65  gcut_list_string_free(keys);
66  keys = NULL;
67  }
68 }
69 
70 static void
71 keys_and_values_free(void)
72 {
73  if (keys_and_values) {
74  gcut_list_string_free(keys_and_values);
75  keys_and_values = NULL;
76  }
77 }
78 
79 void
81 {
82  keys_free();
83  keys_and_values_free();
84  teardown_hash_common();
85 }
86 
87 static GList *
88 retrieve_all_keys(void)
89 {
90  grn_id id;
91 
92  keys_free();
93 
94  id = grn_hash_cursor_next(context, cursor);
95  while (id != GRN_ID_NIL) {
96  void *key;
97  GString *null_terminated_key;
98  int size;
99 
100  size = grn_hash_cursor_get_key(context, cursor, &key);
101  null_terminated_key = g_string_new_len(key, size);
102  keys = g_list_append(keys, g_string_free(null_terminated_key, FALSE));
103  id = grn_hash_cursor_next(context, cursor);
104  }
105 
106  return keys;
107 }
108 
109 static GList *
110 retrieve_all_keys_and_values(void)
111 {
112  grn_id id;
113 
114  keys_and_values_free();
115 
116  id = grn_hash_cursor_next(context, cursor);
117  while (id != GRN_ID_NIL) {
118  int length;
119  void *key, *value;
120  GString *null_terminated_key, *null_terminated_value;
121 
122  length = grn_hash_cursor_get_key(context, cursor, &key);
123  null_terminated_key = g_string_new_len(key, length);
124  keys_and_values = g_list_append(keys_and_values,
125  g_string_free(null_terminated_key, FALSE));
126 
127  length = grn_hash_cursor_get_value(context, cursor, &value);
128  null_terminated_value = g_string_new_len(value, length);
129  keys_and_values = g_list_append(keys_and_values,
130  g_string_free(null_terminated_value, FALSE));
131 
132  id = grn_hash_cursor_next(context, cursor);
133  }
134 
135  return keys_and_values;
136 }
137 
138 typedef struct cursor_test_data
139 {
143 
144 static cursor_test_data *test_data_new(GList *expected_strings,
145  grn_test_set_parameters_func set_parameters,
146  ...) G_GNUC_NULL_TERMINATED;
147 static cursor_test_data *
148 test_data_new(GList *expected_strings,
149  grn_test_set_parameters_func set_parameters,
150  ...)
151 {
152  cursor_test_data *test_data;
153  va_list args;
154 
155  test_data = g_new0(cursor_test_data, 1);
156  test_data->expected_strings = expected_strings;
157 
158  va_start(args, set_parameters);
159  test_data->set_parameters_funcs = NULL;
160  while (set_parameters) {
161  test_data->set_parameters_funcs =
162  g_list_append(test_data->set_parameters_funcs, set_parameters);
163  set_parameters = va_arg(args, grn_test_set_parameters_func);
164  }
165  va_end(args);
166 
167  return test_data;
168 }
169 
170 static void
171 test_data_set_parameters(const cursor_test_data *test_data)
172 {
173  GList *node;
174 
175  for (node = test_data->set_parameters_funcs;
176  node;
177  node = g_list_next(node)) {
178  grn_test_set_parameters_func set_parameters_func = node->data;
179  set_parameters_func();
180  }
181 }
182 
183 static void
184 test_data_free(cursor_test_data *test_data)
185 {
186  gcut_list_string_free(test_data->expected_strings);
187  g_list_free(test_data->set_parameters_funcs);
188  g_free(test_data);
189 }
190 
191 static void
192 set_ascending(void)
193 {
195 }
196 
197 static void
198 set_descending(void)
199 {
201 }
202 
203 static void
204 add_next_with_no_entry_data(const gchar *additional_label,
205  grn_test_set_parameters_func set_parameters_funcs)
206 {
207  cut_add_data(cut_take_printf("ascending%s", additional_label),
208  test_data_new(NULL, set_ascending, set_parameters_funcs, NULL),
209  test_data_free,
210  cut_take_printf("descending%s", additional_label),
211  test_data_new(NULL, set_descending, set_parameters_funcs, NULL),
212  test_data_free);
213 }
214 
215 void
217 {
218  add_next_with_no_entry_data("", NULL);
219  add_next_with_no_entry_data(" - tiny", set_tiny_flags);
220 }
221 
222 void
223 test_next_with_no_entry(gconstpointer data)
224 {
225  const cursor_test_data *test_data = data;
226 
227  test_data_set_parameters(test_data);
228 
231  gcut_assert_equal_list_string(NULL, retrieve_all_keys());
232 }
233 
234 static void
235 add_next_with_one_entry_data(const gchar *additional_label,
236  grn_test_set_parameters_func set_parameters_funcs)
237 {
238  cut_add_data(cut_take_printf("ascending%s", additional_label),
239  test_data_new(gcut_list_string_new("セナ", NULL),
240  set_ascending, set_parameters_funcs, NULL),
241  test_data_free,
242  cut_take_printf("descending%s", additional_label),
243  test_data_new(gcut_list_string_new("セナ", NULL),
244  set_descending, set_parameters_funcs, NULL),
245  test_data_free);
246 }
247 
248 void
250 {
251  add_next_with_one_entry_data("", NULL);
252  add_next_with_one_entry_data(" - tiny", set_tiny_flags);
253 }
254 
255 void
256 test_next_with_one_entry(gconstpointer data)
257 {
258  const cursor_test_data *test_data = data;
259  const gchar key[] = "セナ";
260 
261  test_data_set_parameters(test_data);
262 
264 
266 
268  gcut_assert_equal_list_string(test_data->expected_strings,
269  retrieve_all_keys());
270 }
271 
272 static void
273 set_max(void)
274 {
275  const gchar max[] = "セナ + Ruby";
276  grn_test_hash_factory_set_cursor_max(factory, max, strlen(max));
277 }
278 
279 static void
280 set_max_low(void)
281 {
282  const gchar max[] = "ナセナセ";
283  grn_test_hash_factory_set_cursor_max(factory, max, strlen(max));
284 }
285 
286 static void
287 set_max_nonexistence(void)
288 {
289  const gchar max[] = "Hyper Estraier";
290  grn_test_hash_factory_set_cursor_max(factory, max, strlen(max));
291 }
292 
293 static void
294 set_min(void)
295 {
296  const gchar min[] = "ナセナセ";
297  grn_test_hash_factory_set_cursor_min(factory, min, strlen(min));
298 }
299 
300 static void
301 set_min_high(void)
302 {
303  const gchar min[] = "セナ + Ruby";
304  grn_test_hash_factory_set_cursor_min(factory, min, strlen(min));
305 }
306 
307 static void
308 set_min_nonexistence(void)
309 {
310  const gchar min[] = "Hyper Estraier";
311  grn_test_hash_factory_set_cursor_min(factory, min, strlen(min));
312 }
313 
314 static void
315 set_gt(void)
316 {
318 }
319 
320 static void
321 set_lt(void)
322 {
324 }
325 
326 static void
327 add_data_ascending(const gchar *additional_label,
328  grn_test_set_parameters_func set_parameters_funcs)
329 {
330  cut_add_data(cut_take_printf("ascending%s", additional_label),
331  test_data_new(gcut_list_string_new("セナ",
332  "ナセナセ",
333  "Groonga",
334  "セナ + Ruby",
335  "セナセナ",
336  NULL),
337  set_ascending, set_parameters_funcs, NULL),
338  test_data_free);
339 
340  cut_add_data(cut_take_printf("ascending - max%s", additional_label),
341  test_data_new(gcut_list_string_new("セナ",
342  "ナセナセ",
343  "Groonga",
344  "セナ + Ruby",
345  NULL),
346  set_ascending, set_max, set_parameters_funcs, NULL),
347  test_data_free,
348  cut_take_printf("ascending - max - gt%s", additional_label),
349  test_data_new(gcut_list_string_new("セナ",
350  "ナセナセ",
351  "Groonga",
352  "セナ + Ruby",
353  NULL),
354  set_ascending, set_max, set_gt,
355  set_parameters_funcs, NULL),
356  test_data_free,
357  cut_take_printf("ascending - max - lt%s", additional_label),
358  test_data_new(gcut_list_string_new("セナ",
359  "ナセナセ",
360  "Groonga",
361  NULL),
362  set_ascending, set_max, set_lt,
363  set_parameters_funcs, NULL),
364  test_data_free,
365  cut_take_printf("ascending - max - gt - lt%s", additional_label),
366  test_data_new(gcut_list_string_new("セナ",
367  "ナセナセ",
368  "Groonga",
369  NULL),
370  set_ascending, set_max, set_gt, set_lt,
371  set_parameters_funcs, NULL),
372  test_data_free);
373 
374  cut_add_data(cut_take_printf("ascending - min%s", additional_label),
375  test_data_new(gcut_list_string_new("ナセナセ",
376  "Groonga",
377  "セナ + Ruby",
378  "セナセナ",
379  NULL),
380  set_ascending, set_min,
381  set_parameters_funcs, NULL),
382  test_data_free,
383  cut_take_printf("ascending - min - gt%s", additional_label),
384  test_data_new(gcut_list_string_new("Groonga",
385  "セナ + Ruby",
386  "セナセナ",
387  NULL),
388  set_ascending, set_min, set_gt,
389  set_parameters_funcs, NULL),
390  test_data_free,
391  cut_take_printf("ascending - min - lt%s", additional_label),
392  test_data_new(gcut_list_string_new("ナセナセ",
393  "Groonga",
394  "セナ + Ruby",
395  "セナセナ",
396  NULL),
397  set_ascending, set_min, set_lt,
398  set_parameters_funcs, NULL),
399  test_data_free,
400  cut_take_printf("ascending - min - gt - lt%s", additional_label),
401  test_data_new(gcut_list_string_new("Groonga",
402  "セナ + Ruby",
403  "セナセナ",
404  NULL),
405  set_ascending, set_min, set_gt, set_lt,
406  set_parameters_funcs, NULL),
407  test_data_free);
408 
409  cut_add_data(cut_take_printf("ascending - max - min%s", additional_label),
410  test_data_new(gcut_list_string_new("ナセナセ",
411  "Groonga",
412  "セナ + Ruby",
413  NULL),
414  set_ascending, set_max, set_min,
415  set_parameters_funcs, NULL),
416  test_data_free,
417  cut_take_printf("ascending - max - min - gt%s", additional_label),
418  test_data_new(gcut_list_string_new("Groonga",
419  "セナ + Ruby",
420  NULL),
421  set_ascending, set_max, set_min, set_gt,
422  set_parameters_funcs, NULL),
423  test_data_free,
424  cut_take_printf("ascending - max - min - lt%s", additional_label),
425  test_data_new(gcut_list_string_new("ナセナセ",
426  "Groonga",
427  NULL),
428  set_ascending, set_max, set_min, set_lt,
429  set_parameters_funcs, NULL),
430  test_data_free,
431  cut_take_printf("ascending - max - min - gt - lt%s",
432  additional_label),
433  test_data_new(gcut_list_string_new("Groonga",
434  NULL),
435  set_ascending, set_max, set_min, set_gt,
436  set_lt, set_parameters_funcs, NULL),
437  test_data_free);
438 
439  cut_add_data(cut_take_printf("ascending - high-min%s", additional_label),
440  test_data_new(gcut_list_string_new("セナ + Ruby",
441  "セナセナ",
442  NULL),
443  set_ascending, set_min_high, set_parameters_funcs,
444  NULL),
445  test_data_free,
446  cut_take_printf("ascending - low-max%s", additional_label),
447  test_data_new(gcut_list_string_new("セナ",
448  "ナセナセ",
449  NULL),
450  set_ascending, set_max_low, set_parameters_funcs,
451  NULL),
452  test_data_free,
453  cut_take_printf("ascending - high-min - low-max%s",
454  additional_label),
455  test_data_new(NULL,
456  set_ascending, set_min_high, set_max_low,
457  set_parameters_funcs, NULL),
458  test_data_free);
459 
460  cut_add_data(cut_take_printf("ascending - nonexistence-min%s",
461  additional_label),
462  test_data_new(NULL,
463  set_ascending, set_min_nonexistence,
464  set_parameters_funcs, NULL),
465  test_data_free,
466  cut_take_printf("ascending - nonexistence-max%s",
467  additional_label),
468  test_data_new(NULL,
469  set_ascending, set_max_nonexistence,
470  set_parameters_funcs, NULL),
471  test_data_free,
472  cut_take_printf("ascending - nonexistence-min - "
473  "nonexistence-max%s", additional_label),
474  test_data_new(NULL,
475  set_ascending, set_min_nonexistence,
476  set_max_nonexistence, set_parameters_funcs, NULL),
477  test_data_free);
478 }
479 
480 static void
481 add_data_descending(const gchar *additional_label,
482  grn_test_set_parameters_func set_parameters_funcs)
483 {
484  cut_add_data(cut_take_printf("descending%s", additional_label),
485  test_data_new(gcut_list_string_new("セナセナ",
486  "セナ + Ruby",
487  "Groonga",
488  "ナセナセ",
489  "セナ",
490  NULL),
491  set_descending, set_parameters_funcs, NULL),
492  test_data_free);
493 
494  cut_add_data(cut_take_printf("descending - max%s", additional_label),
495  test_data_new(gcut_list_string_new("セナ + Ruby",
496  "Groonga",
497  "ナセナセ",
498  "セナ",
499  NULL),
500  set_descending, set_max, set_parameters_funcs,
501  NULL),
502  test_data_free,
503  cut_take_printf("descending - max - gt%s", additional_label),
504  test_data_new(gcut_list_string_new("セナ + Ruby",
505  "Groonga",
506  "ナセナセ",
507  "セナ",
508  NULL),
509  set_descending, set_max, set_gt,
510  set_parameters_funcs, NULL),
511  test_data_free,
512  cut_take_printf("descending - max - lt%s", additional_label),
513  test_data_new(gcut_list_string_new("Groonga",
514  "ナセナセ",
515  "セナ",
516  NULL),
517  set_descending, set_max, set_lt,
518  set_parameters_funcs, NULL),
519  test_data_free,
520  cut_take_printf("descending - max - gt - lt%s", additional_label),
521  test_data_new(gcut_list_string_new("Groonga",
522  "ナセナセ",
523  "セナ",
524  NULL),
525  set_descending, set_max, set_gt, set_lt,
526  set_parameters_funcs, NULL),
527  test_data_free);
528 
529  cut_add_data(cut_take_printf("descending - min%s", additional_label),
530  test_data_new(gcut_list_string_new("セナセナ",
531  "セナ + Ruby",
532  "Groonga",
533  "ナセナセ",
534  NULL),
535  set_descending, set_min, set_parameters_funcs,
536  NULL),
537  test_data_free,
538  cut_take_printf("descending - min - gt%s", additional_label),
539  test_data_new(gcut_list_string_new("セナセナ",
540  "セナ + Ruby",
541  "Groonga",
542  NULL),
543  set_descending, set_min, set_gt,
544  set_parameters_funcs, NULL),
545  test_data_free,
546  cut_take_printf("descending - min - lt%s", additional_label),
547  test_data_new(gcut_list_string_new("セナセナ",
548  "セナ + Ruby",
549  "Groonga",
550  "ナセナセ",
551  NULL),
552  set_descending, set_min, set_lt,
553  set_parameters_funcs, NULL),
554  test_data_free,
555  cut_take_printf("descending - min - gt - lt%s", additional_label),
556  test_data_new(gcut_list_string_new("セナセナ",
557  "セナ + Ruby",
558  "Groonga",
559  NULL),
560  set_descending, set_min, set_gt, set_lt,
561  set_parameters_funcs, NULL),
562  test_data_free);
563 
564  cut_add_data(cut_take_printf("descending - max - min%s", additional_label),
565  test_data_new(gcut_list_string_new("セナ + Ruby",
566  "Groonga",
567  "ナセナセ",
568  NULL),
569  set_descending, set_max, set_min,
570  set_parameters_funcs, NULL),
571  test_data_free,
572  cut_take_printf("descending - max - min - gt%s",
573  additional_label),
574  test_data_new(gcut_list_string_new("セナ + Ruby",
575  "Groonga",
576  NULL),
577  set_descending, set_max, set_min, set_gt,
578  set_parameters_funcs, NULL),
579  test_data_free,
580  cut_take_printf("descending - max - min - lt%s",
581  additional_label),
582  test_data_new(gcut_list_string_new("Groonga",
583  "ナセナセ",
584  NULL),
585  set_descending, set_max, set_min, set_lt,
586  set_parameters_funcs, NULL),
587  test_data_free,
588  cut_take_printf("descending - max - min - gt - lt%s",
589  additional_label),
590  test_data_new(gcut_list_string_new("Groonga",
591  NULL),
592  set_descending, set_max, set_min, set_gt,
593  set_lt, set_parameters_funcs, NULL),
594  test_data_free);
595 
596  cut_add_data(cut_take_printf("descending - high-min%s",
597  additional_label),
598  test_data_new(gcut_list_string_new("セナセナ",
599  "セナ + Ruby",
600  NULL),
601  set_descending, set_min_high,
602  set_parameters_funcs, NULL),
603  test_data_free,
604  cut_take_printf("descending - low-max%s",
605  additional_label),
606  test_data_new(gcut_list_string_new("ナセナセ",
607  "セナ",
608  NULL),
609  set_descending, set_max_low,
610  set_parameters_funcs, NULL),
611  test_data_free,
612  cut_take_printf("descending - high-min - low-max%s",
613  additional_label),
614  test_data_new(NULL,
615  set_descending, set_min_high, set_max_low,
616  set_parameters_funcs, NULL),
617  test_data_free);
618 
619  cut_add_data(cut_take_printf("descending - nonexistence-min%s",
620  additional_label),
621  test_data_new(NULL,
622  set_descending, set_min_nonexistence,
623  set_parameters_funcs, NULL),
624  test_data_free,
625  cut_take_printf("descending - nonexistence-max%s",
626  additional_label),
627  test_data_new(NULL,
628  set_descending, set_max_nonexistence,
629  set_parameters_funcs, NULL),
630  test_data_free,
631  cut_take_printf("descending - nonexistence-min - "
632  "nonexistence-max%s", additional_label),
633  test_data_new(NULL,
634  set_descending, set_min_nonexistence,
635  set_max_nonexistence, set_parameters_funcs, NULL),
636  test_data_free);
637 }
638 
639 void
641 {
642  add_data_ascending("", NULL);
643  add_data_descending("", NULL);
644 
645  add_data_ascending(" - tiny", set_tiny_flags);
646  add_data_descending(" - tiny", set_tiny_flags);
647 }
648 
649 void
650 test_next_with_multi_entries(gconstpointer data)
651 {
652  const cursor_test_data *test_data = data;
653  const gchar key1[] = "セナ";
654  const gchar key2[] = "ナセナセ";
655  const gchar key3[] = "Groonga";
656  const gchar key4[] = "セナ + Ruby";
657  const gchar key5[] = "セナセナ";
658 
659  test_data_set_parameters(test_data);
660 
662 
663  cut_assert_lookup_add(key1);
664  cut_assert_lookup_add(key2);
665  cut_assert_lookup_add(key3);
666  cut_assert_lookup_add(key4);
667  cut_assert_lookup_add(key5);
668 
670  gcut_assert_equal_list_string(test_data->expected_strings,
671  retrieve_all_keys());
672 }
673 
674 static void
675 set_value_size(void)
676 {
677  grn_test_hash_factory_set_value_size(factory, strlen("上書きされた値 -"));
678 }
679 
680 static void
681 add_value_data(const gchar *additional_label,
682  grn_test_set_parameters_func set_parameters_funcs)
683 {
684  cut_add_data(cut_take_printf("default%s", additional_label),
685  test_data_new(gcut_list_string_new("セナ",
686  "",
687  "ナセナセ",
688  "VALUE2",
689  "Groonga",
690  "",
691  "セナ + Ruby",
692  "",
693  /* should be set two values */
694  "セナセナ",
695  "上書きされた値 -",
696  NULL),
697  set_ascending, set_value_size,
698  set_parameters_funcs, NULL),
699  test_data_free);
700 }
701 
702 void
704 {
705  add_value_data("", NULL);
706  add_value_data(" - tiny", set_tiny_flags);
707 }
708 
709 void
710 test_value(gconstpointer data)
711 {
712  const cursor_test_data *test_data = data;
713  const gchar key1[] = "セナ";
714  const gchar key2[] = "ナセナセ";
715  const gchar key3[] = "Groonga";
716  const gchar key4[] = "セナ + Ruby";
717  const gchar key5[] = "セナセナ";
718  gchar value2[] = "VALUE2";
719  gchar value4_1[] = "Groonga";
720  gchar value4_2[] = "るびい";
721  gchar value5_1[] = "上書きされる値 - overridden value";
722  gchar value5_2[] = "上書きされた値 - override value";
723 
724  test_data_set_parameters(test_data);
725 
727 
728  cut_assert_lookup_add(key1);
729  cut_assert_lookup_add(key2);
730  cut_assert_lookup_add(key3);
731  cut_assert_lookup_add(key4);
732  cut_assert_lookup_add(key5);
733 
735  while (grn_hash_cursor_next(context, cursor) != GRN_ID_NIL) {
736  void *key;
737  const gchar *null_terminated_key;
738  int size;
739 
740  size = grn_hash_cursor_get_key(context, cursor, &key);
741  null_terminated_key = cut_take_strndup(key, size);
742  if (g_str_equal(null_terminated_key, key2)) {
744  } else if (g_str_equal(null_terminated_key, key4)) {
745  grn_hash_cursor_set_value(context, cursor, value4_1, GRN_OBJ_INCR);
746  grn_hash_cursor_set_value(context, cursor, value4_2, GRN_OBJ_INCR);
747  } else if (g_str_equal(null_terminated_key, key5)) {
748  grn_hash_cursor_set_value(context, cursor, value5_1, GRN_OBJ_SET);
749  grn_hash_cursor_set_value(context, cursor, value5_2, GRN_OBJ_SET);
750  }
751  }
752 
754  gcut_assert_equal_list_string(test_data->expected_strings,
755  retrieve_all_keys_and_values());
756 }
757 
758 static void
759 add_delete_data(const gchar *additional_label,
760  grn_test_set_parameters_func set_parameters_funcs)
761 {
762  cut_add_data(cut_take_printf("default%s", additional_label),
763  test_data_new(gcut_list_string_new("ナセナセ",
764  "Groonga",
765  "セナ + Ruby",
766  NULL),
767  set_ascending, set_parameters_funcs, NULL),
768  test_data_free);
769 }
770 
771 void
773 {
774  add_delete_data("", NULL);
775 
776  add_delete_data(" - tiny", set_tiny_flags);
777 }
778 
779 void
780 test_delete(gconstpointer data)
781 {
782  const cursor_test_data *test_data = data;
783  const gchar key1[] = "セナ";
784  const gchar key2[] = "ナセナセ";
785  const gchar key3[] = "Groonga";
786  const gchar key4[] = "セナ + Ruby";
787  const gchar key5[] = "セナセナ";
788 
789  test_data_set_parameters(test_data);
790 
792 
793  cut_assert_lookup_add(key1);
794  cut_assert_lookup_add(key2);
795  cut_assert_lookup_add(key3);
796  cut_assert_lookup_add(key4);
797  cut_assert_lookup_add(key5);
798 
800  while (grn_hash_cursor_next(context, cursor) != GRN_ID_NIL) {
801  void *key;
802  const gchar *null_terminated_key;
803  int size;
804 
805  size = grn_hash_cursor_get_key(context, cursor, &key);
806  null_terminated_key = cut_take_strndup(key, size);
807  if (g_str_equal(null_terminated_key, key1) ||
808  g_str_equal(null_terminated_key, key5)) {
809  grn_hash_cursor_delete(context, cursor, NULL);
810  }
811  }
812 
814  gcut_assert_equal_list_string(test_data->expected_strings,
815  retrieve_all_keys());
816 }