35 static GList *keys_and_values;
40 setup_trie_common(
"patricia-trie-cursor");
43 keys_and_values = NULL;
54 gcut_list_string_free(keys);
60 keys_and_values_free(
void)
62 if (keys_and_values) {
63 gcut_list_string_free(keys_and_values);
64 keys_and_values = NULL;
72 keys_and_values_free();
73 teardown_trie_common();
77 retrieve_all_keys(
void)
85 retrieve_all_keys_and_values(
void)
87 keys_and_values_free();
90 return keys_and_values;
95 ...) G_GNUC_NULL_TERMINATED;
97 test_data_new(GList *expected_strings,
104 va_start(args, set_parameters);
105 test_data = trie_test_data_newv(NULL, NULL, NULL,
GRN_SUCCESS,
106 expected_strings, NULL,
107 set_parameters, &args);
116 trie_test_data_free(test_data);
134 cut_add_data(
"ascending",
135 test_data_new(NULL, set_ascending, NULL),
138 test_data_new(NULL, set_ascending, set_sis, NULL),
141 test_data_new(NULL, set_descending, NULL),
144 test_data_new(NULL, set_descending, set_sis, NULL),
153 trie_test_data_set_parameters(test_data);
157 gcut_assert_equal_list_string(NULL, retrieve_all_keys());
163 cut_add_data(
"ascending",
164 test_data_new(gcut_list_string_new(
"セナ", NULL),
165 set_ascending, NULL),
168 test_data_new(gcut_list_string_new(
"セナ",
"ナ", NULL),
169 set_ascending, set_sis, NULL),
172 test_data_new(gcut_list_string_new(
"セナ", NULL),
173 set_descending, NULL),
176 test_data_new(gcut_list_string_new(
"ナ",
"セナ", NULL),
177 set_descending, set_sis, NULL),
185 const gchar key[] =
"セナ";
187 trie_test_data_set_parameters(test_data);
195 retrieve_all_keys());
201 default_cursor_max = g_strdup(
"セナセナ");
202 default_cursor_max_size = strlen(default_cursor_max);
208 default_cursor_max = g_strdup(
"セナ");
209 default_cursor_max_size = strlen(default_cursor_max);
215 default_cursor_min = g_strdup(
"セナ");
216 default_cursor_min_size = strlen(default_cursor_min);
222 default_cursor_min = g_strdup(
"セナセナ");
223 default_cursor_min_size = strlen(default_cursor_min);
239 add_data_ascending(
void)
241 cut_add_data(
"ascending",
242 test_data_new(gcut_list_string_new(
"Groonga",
248 set_ascending, NULL),
251 test_data_new(gcut_list_string_new(
"Groonga",
256 set_ascending, set_max, NULL),
258 "ascending - max - gt",
259 test_data_new(gcut_list_string_new(
"Groonga",
264 set_ascending, set_max, set_gt, NULL),
266 "ascending - max - lt",
267 test_data_new(gcut_list_string_new(
"Groonga",
271 set_ascending, set_max, set_lt, NULL),
273 "ascending - max - gt - lt",
274 test_data_new(gcut_list_string_new(
"Groonga",
278 set_ascending, set_max, set_gt, set_lt, NULL),
281 test_data_new(gcut_list_string_new(
"セナ",
286 set_ascending, set_min, NULL),
288 "ascending - min - gt",
289 test_data_new(gcut_list_string_new(
"セナ + Ruby",
293 set_ascending, set_min, set_gt, NULL),
295 "ascending - min - lt",
296 test_data_new(gcut_list_string_new(
"セナ",
301 set_ascending, set_min, set_lt, NULL),
303 "ascending - min - gt - lt",
304 test_data_new(gcut_list_string_new(
"セナ + Ruby",
308 set_ascending, set_min, set_gt, set_lt, NULL),
310 "ascending - max - min",
311 test_data_new(gcut_list_string_new(
"セナ",
315 set_ascending, set_max, set_min, NULL),
317 "ascending - max - min - gt",
318 test_data_new(gcut_list_string_new(
"セナ + Ruby",
321 set_ascending, set_max, set_min, set_gt,
324 "ascending - max - min - lt",
325 test_data_new(gcut_list_string_new(
"セナ",
328 set_ascending, set_max, set_min, set_lt,
331 "ascending - max - min - gt - lt",
332 test_data_new(gcut_list_string_new(
"セナ + Ruby",
334 set_ascending, set_max, set_min, set_gt,
337 "ascending - high-min",
338 test_data_new(gcut_list_string_new(
"セナセナ",
341 set_ascending, set_min_high, NULL),
343 "ascending - low-max",
344 test_data_new(gcut_list_string_new(
"Groonga",
347 set_ascending, set_max_low, NULL),
349 "ascending - high-min - low-max",
351 set_ascending, set_min_high, set_max_low, NULL),
356 add_data_ascending_sis(
void)
358 cut_add_data(
"ascending - sis",
359 test_data_new(gcut_list_string_new(
"Groonga",
371 set_ascending, set_sis, NULL),
373 "ascending - max - sis",
374 test_data_new(gcut_list_string_new(
"Groonga",
381 set_ascending, set_max, set_sis, NULL),
383 "ascending - max - gt - sis",
384 test_data_new(gcut_list_string_new(
"Groonga",
391 set_ascending, set_max, set_gt, set_sis, NULL),
393 "ascending - max - lt - sis",
394 test_data_new(gcut_list_string_new(
"Groonga",
400 set_ascending, set_max, set_lt, set_sis, NULL),
402 "ascending - max - gt - lt - sis",
403 test_data_new(gcut_list_string_new(
"Groonga",
409 set_ascending, set_max, set_gt, set_lt, set_sis,
412 "ascending - min - sis",
413 test_data_new(gcut_list_string_new(
"セナ",
423 set_ascending, set_min, set_sis, NULL),
425 "ascending - min - gt - sis",
426 test_data_new(gcut_list_string_new(
"セナ + Ruby",
435 set_ascending, set_min, set_gt, set_sis, NULL),
437 "ascending - min - lt - sis",
438 test_data_new(gcut_list_string_new(
"セナ",
448 set_ascending, set_min, set_lt, set_sis, NULL),
450 "ascending - min - gt - lt - sis",
451 test_data_new(gcut_list_string_new(
"セナ + Ruby",
460 set_ascending, set_min, set_gt, set_lt,
463 "ascending - max - min - sis",
464 test_data_new(gcut_list_string_new(
"セナ",
469 set_ascending, set_max, set_min, set_sis,
472 "ascending - max - min - gt - sis",
473 test_data_new(gcut_list_string_new(
"セナ + Ruby",
477 set_ascending, set_max, set_min, set_gt,
480 "ascending - max - min - lt - sis",
481 test_data_new(gcut_list_string_new(
"セナ",
485 set_ascending, set_max, set_min, set_lt,
488 "ascending - max - min - gt - lt - sis",
489 test_data_new(gcut_list_string_new(
"セナ + Ruby",
492 set_ascending, set_max, set_min, set_gt,
493 set_lt, set_sis, NULL),
495 "ascending - high-min - sis",
496 test_data_new(gcut_list_string_new(
"セナセナ",
503 set_ascending, set_min_high, set_sis, NULL),
505 "ascending - low-max - sis",
506 test_data_new(gcut_list_string_new(
"Groonga",
510 set_ascending, set_max_low, set_sis, NULL),
512 "ascending - high-min - low-max - sis",
514 set_ascending, set_min_high, set_max_low, set_sis,
520 add_data_descending(
void)
522 cut_add_data(
"descending",
523 test_data_new(gcut_list_string_new(
"ナセナセ",
529 set_descending, NULL),
532 test_data_new(gcut_list_string_new(
"セナセナ",
537 set_descending, set_max, NULL),
539 "descending - max - gt",
540 test_data_new(gcut_list_string_new(
"セナセナ",
545 set_descending, set_max, set_gt, NULL),
547 "descending - max - lt",
548 test_data_new(gcut_list_string_new(
"セナ + Ruby",
552 set_descending, set_max, set_lt, NULL),
554 "descending - max - gt - lt",
555 test_data_new(gcut_list_string_new(
"セナ + Ruby",
559 set_descending, set_max, set_gt, set_lt, NULL),
562 test_data_new(gcut_list_string_new(
"ナセナセ",
567 set_descending, set_min, NULL),
569 "descending - min - gt",
570 test_data_new(gcut_list_string_new(
"ナセナセ",
574 set_descending, set_min, set_gt, NULL),
576 "descending - min - lt",
577 test_data_new(gcut_list_string_new(
"ナセナセ",
582 set_descending, set_min, set_lt, NULL),
584 "descending - min - gt - lt",
585 test_data_new(gcut_list_string_new(
"ナセナセ",
589 set_descending, set_min, set_gt, set_lt, NULL),
591 "descending - max - min",
592 test_data_new(gcut_list_string_new(
"セナセナ",
596 set_descending, set_max, set_min, NULL),
598 "descending - max - min - gt",
599 test_data_new(gcut_list_string_new(
"セナセナ",
602 set_descending, set_max, set_min, set_gt,
605 "descending - max - min - lt",
606 test_data_new(gcut_list_string_new(
"セナ + Ruby",
609 set_descending, set_max, set_min, set_lt,
612 "descending - max - min - gt - lt",
613 test_data_new(gcut_list_string_new(
"セナ + Ruby",
615 set_descending, set_max, set_min, set_gt,
618 "descending - high-min",
619 test_data_new(gcut_list_string_new(
"ナセナセ",
622 set_descending, set_min_high, NULL),
624 "descending - low-max",
625 test_data_new(gcut_list_string_new(
"セナ",
628 set_descending, set_max_low, NULL),
630 "descending - high-min - low-max",
632 set_descending, set_min_high, set_max_low, NULL),
637 add_data_descending_sis(
void)
639 cut_add_data(
"descending - sis",
640 test_data_new(gcut_list_string_new(
"ナセナセ",
652 set_descending, set_sis, NULL),
654 "descending - max - sis",
655 test_data_new(gcut_list_string_new(
"セナセナ",
662 set_descending, set_max, set_sis, NULL),
664 "descending - max - gt - sis",
665 test_data_new(gcut_list_string_new(
"セナセナ",
672 set_descending, set_max, set_gt, set_sis,
675 "descending - max - lt - sis",
676 test_data_new(gcut_list_string_new(
"セナセ",
682 set_descending, set_max, set_lt, set_sis,
685 "descending - max - gt - lt - sis",
686 test_data_new(gcut_list_string_new(
"セナセ",
692 set_descending, set_max, set_gt, set_lt,
695 "descending - min - sis",
696 test_data_new(gcut_list_string_new(
"ナセナセ",
706 set_descending, set_min, set_sis, NULL),
708 "descending - min - gt - sis",
709 test_data_new(gcut_list_string_new(
"ナセナセ",
718 set_descending, set_min, set_gt, set_sis,
721 "descending - min - lt - sis",
722 test_data_new(gcut_list_string_new(
"ナセナセ",
732 set_descending, set_min, set_lt, set_sis,
735 "descending - min - gt - lt - sis",
736 test_data_new(gcut_list_string_new(
"ナセナセ",
745 set_descending, set_min, set_gt, set_lt,
748 "descending - max - min - sis",
749 test_data_new(gcut_list_string_new(
"セナセナ",
754 set_descending, set_max, set_min,
757 "descending - max - min - gt - sis",
758 test_data_new(gcut_list_string_new(
"セナセナ",
762 set_descending, set_max, set_min, set_gt,
765 "descending - max - min - lt - sis",
766 test_data_new(gcut_list_string_new(
"セナセ",
770 set_descending, set_max, set_min, set_lt,
773 "descending - max - min - gt - lt - sis",
774 test_data_new(gcut_list_string_new(
"セナセ",
777 set_descending, set_max, set_min, set_gt,
778 set_lt, set_sis, NULL),
780 "descending - high-min - sis",
781 test_data_new(gcut_list_string_new(
"ナセナセ",
788 set_descending, set_min_high, set_sis, NULL),
790 "descending - low-max - sis",
791 test_data_new(gcut_list_string_new(
"セナ",
795 set_descending, set_max_low, set_sis, NULL),
797 "descending - high-min - low-max - sis",
799 set_descending, set_min_high, set_max_low, set_sis,
807 add_data_ascending();
808 add_data_ascending_sis();
809 add_data_descending();
810 add_data_descending_sis();
817 const gchar key1[] =
"セナ";
818 const gchar key2[] =
"ナセナセ";
819 const gchar key3[] =
"Groonga";
820 const gchar key4[] =
"セナ + Ruby";
821 const gchar key5[] =
"セナセナ";
823 trie_test_data_set_parameters(test_data);
835 retrieve_all_keys());
841 default_cursor_min = g_strdup(
"0");
842 default_cursor_min_size = strlen(default_cursor_min);
843 default_cursor_max = g_strdup(
"9989");
844 default_cursor_max_size = strlen(default_cursor_max);
854 gcut_assert_equal_list_string(gcut_take_new_list_string(
"997", NULL),
855 retrieve_all_keys());
862 default_cursor_offset = 1;
867 gcut_assert_equal_list_string(NULL,
868 retrieve_all_keys());
874 default_value_size = strlen(
"上書きされた値 -");
880 cut_add_data(
"default",
881 test_data_new(gcut_list_string_new(
"Groonga",
893 set_ascending, set_value_size, NULL),
897 test_data_new(gcut_list_string_new(
"Groonga",
921 set_ascending, set_value_size, set_sis, NULL),
929 const gchar key1[] =
"セナ";
930 const gchar key2[] =
"ナセナセ";
931 const gchar key3[] =
"Groonga";
932 const gchar key4[] =
"セナ + Ruby";
933 const gchar key5[] =
"セナセナ";
934 gchar value2[] =
"VALUE2";
935 gchar value4_1[] =
"Groonga";
936 gchar value4_2[] =
"るびい";
937 gchar value5_1[] =
"上書きされる値 - overridden value";
938 gchar value5_2[] =
"上書きされた値 - override value";
940 trie_test_data_set_parameters(test_data);
953 gchar *null_terminated_key;
957 null_terminated_key = g_string_free(g_string_new_len(key, size),
FALSE);
958 if (g_str_equal(null_terminated_key, key2)) {
960 }
else if (g_str_equal(null_terminated_key, key4)) {
963 }
else if (g_str_equal(null_terminated_key, key5)) {
972 retrieve_all_keys_and_values());
978 cut_add_data(
"default",
979 test_data_new(gcut_list_string_new(
"Groonga",
983 set_ascending, NULL),
986 test_data_new(gcut_list_string_new(
"Groonga",
994 set_ascending, set_sis, NULL),
1002 const gchar key1[] =
"セナ";
1003 const gchar key2[] =
"ナセナセ";
1004 const gchar key3[] =
"Groonga";
1005 const gchar key4[] =
"セナ + Ruby";
1006 const gchar key5[] =
"セナセナ";
1008 trie_test_data_set_parameters(test_data);
1021 gchar *null_terminated_key;
1025 null_terminated_key = g_string_free(g_string_new_len(key, size),
FALSE);
1026 if (g_str_equal(null_terminated_key, key1) ||
1027 g_str_equal(null_terminated_key, key5)) {
1035 retrieve_all_keys());