38 startup_hash_common();
44 shutdown_hash_common();
50 setup_hash_common(
"hash-sort");
60 gcut_list_string_free(keys);
69 gcut_list_string_free(values);
81 teardown_hash_common();
86 grn_obj *hash1,
void *target1, uint32_t target1_size,
87 grn_obj *hash2,
void *target2, uint32_t target2_size,
100 sort_options_new(
int flags,
compare_func _compare,
void *compare_arg,
int offset)
105 options->
flags = flags;
106 options->
compar = _compare;
120 sort_test_data_new(GList *expected_strings,
124 const GList *strings)
130 test_data->
limit = limit;
142 sort_options_free(test_data->
options);
163 hash_id = array_value;
166 keys = g_list_append(keys, g_strdup(key));
191 hash_id = array_value;
193 values = g_list_append(values, g_strdup(value));
202 add_sort_by_uint_key_data(
const gchar *additional_label,
205 int sort_by_unsigned_key_flags;
210 cut_add_data(cut_take_printf(
"ascending%s", additional_label),
211 sort_test_data_new(gcut_list_string_new(
"セナセナ",
219 sort_by_unsigned_key_flags,
224 sort_test_data_free);
226 cut_add_data(cut_take_printf(
"ascending - limit%s", additional_label),
227 sort_test_data_new(gcut_list_string_new(
"セナセナ",
233 sort_by_unsigned_key_flags,
238 sort_test_data_free);
240 cut_add_data(cut_take_printf(
"descending%s", additional_label),
241 sort_test_data_new(gcut_list_string_new(
"セナ + Ruby",
249 sort_by_unsigned_key_flags,
254 sort_test_data_free);
256 cut_add_data(cut_take_printf(
"descending - limit%s", additional_label),
257 sort_test_data_new(gcut_list_string_new(
"セナ + Ruby",
263 sort_by_unsigned_key_flags,
268 sort_test_data_free);
270 cut_add_data(cut_take_printf(
"no options%s", additional_label),
271 sort_test_data_new(gcut_list_string_new(
"セナセナ",
281 sort_test_data_free);
283 cut_add_data(cut_take_printf(
"no options - limit%s", additional_label),
284 sort_test_data_new(gcut_list_string_new(
"セナセナ",
292 sort_test_data_free);
298 add_sort_by_uint_key_data(
"", NULL);
299 add_sort_by_uint_key_data(
" - tiny", set_tiny_flags);
306 const uint32_t key1 = 100;
307 const uint32_t key2 = 2000000;
308 const uint32_t key3 = 30000;
309 const uint32_t key4 = 4000;
310 const uint32_t key5 = 5;
311 gchar value1[] =
"セナ";
312 gchar value2[] =
"セナ + Ruby";
313 gchar value3[] =
"Senna";
314 gchar value4[] =
"ナセナセ";
315 gchar value5[] =
"セナセナ";
331 sort_result, test_data->
options);
333 retrieve_all_values(sort_result, n_entries));
337 add_sort_by_int_key_data(
const gchar *additional_label,
340 int sort_by_number_key_flags;
344 cut_add_data(cut_take_printf(
"ascending%s", additional_label),
345 sort_test_data_new(gcut_list_string_new(
"セナ + Ruby",
353 sort_by_number_key_flags,
358 sort_test_data_free);
360 cut_add_data(cut_take_printf(
"ascending - limit%s", additional_label),
361 sort_test_data_new(gcut_list_string_new(
"セナ + Ruby",
367 sort_by_number_key_flags,
372 sort_test_data_free);
374 cut_add_data(cut_take_printf(
"descending%s", additional_label),
375 sort_test_data_new(gcut_list_string_new(
"Senna",
383 sort_by_number_key_flags,
388 sort_test_data_free);
390 cut_add_data(cut_take_printf(
"descending - limit%s", additional_label),
391 sort_test_data_new(gcut_list_string_new(
"Senna",
397 sort_by_number_key_flags,
402 sort_test_data_free);
404 cut_add_data(cut_take_printf(
"no options%s", additional_label),
405 sort_test_data_new(gcut_list_string_new(
"セナセナ",
415 sort_test_data_free);
417 cut_add_data(cut_take_printf(
"no options - limit%s", additional_label),
418 sort_test_data_new(gcut_list_string_new(
"セナセナ",
426 sort_test_data_free);
432 add_sort_by_int_key_data(
"", NULL);
433 add_sort_by_int_key_data(
" - tiny", set_tiny_flags);
440 const int32_t key1 = 100;
441 const int32_t key2 = -2000000;
442 const int32_t key3 = 30000;
443 const int32_t key4 = -4000;
444 const int32_t key5 = 5;
445 gchar value1[] =
"セナ";
446 gchar value2[] =
"セナ + Ruby";
447 gchar value3[] =
"Senna";
448 gchar value4[] =
"ナセナセ";
449 gchar value5[] =
"セナセナ";
452 key_size =
sizeof(int32_t);
468 sort_result, test_data->
options);
470 retrieve_all_values(sort_result, n_entries));
475 grn_obj *hash1,
void *target1, uint32_t target1_size,
476 grn_obj *hash2,
void *target2, uint32_t target2_size,
479 gchar *null_terminated_target1;
480 gchar *null_terminated_target2;
482 null_terminated_target1 =
483 g_string_free(g_string_new_len(target1, target1_size),
FALSE);
484 null_terminated_target2 =
485 g_string_free(g_string_new_len(target2, target2_size),
FALSE);
486 return strcmp(cut_take_string(null_terminated_target1),
487 cut_take_string(null_terminated_target2)) > 0;
491 add_sort_by_variable_size_key_data(
const gchar *additional_label,
496 keys = gcut_take_list(gcut_list_string_new(
"セナ",
503 cut_add_data(cut_take_printf(
"ascending%s", additional_label),
504 sort_test_data_new(gcut_list_string_new(
"Senna",
512 compare_string, NULL,
516 sort_test_data_free);
518 cut_add_data(cut_take_printf(
"ascending - limit%s", additional_label),
519 sort_test_data_new(gcut_list_string_new(
"Senna",
525 compare_string, NULL,
529 sort_test_data_free);
531 cut_add_data(cut_take_printf(
"descending%s", additional_label),
532 sort_test_data_new(gcut_list_string_new(
"ナセナセ",
540 compare_string, NULL,
544 sort_test_data_free);
546 cut_add_data(cut_take_printf(
"descending - limit%s", additional_label),
547 sort_test_data_new(gcut_list_string_new(
"ナセナセ",
553 compare_string, NULL,
557 sort_test_data_free);
561 add_sort_by_variable_size_key_data_many(
const gchar *additional_label,
566 keys = gcut_take_list(gcut_list_string_new(
"セナ",
577 cut_add_data(cut_take_printf(
"many - ascending%s", additional_label),
578 sort_test_data_new(gcut_list_string_new(
"Ludia",
590 compare_string, NULL,
594 sort_test_data_free);
596 cut_add_data(cut_take_printf(
"many - ascending - limit%s", additional_label),
597 sort_test_data_new(gcut_list_string_new(
"Ludia",
603 compare_string, NULL,
607 sort_test_data_free);
609 cut_add_data(cut_take_printf(
"many - descending%s", additional_label),
610 sort_test_data_new(gcut_list_string_new(
"ブラジル",
622 compare_string, NULL,
626 sort_test_data_free);
628 cut_add_data(cut_take_printf(
"many - descending - limit%s", additional_label),
629 sort_test_data_new(gcut_list_string_new(
"ブラジル",
635 compare_string, NULL,
639 sort_test_data_free);
645 add_sort_by_variable_size_key_data(
"", NULL);
646 add_sort_by_variable_size_key_data(
" - tiny", set_tiny_flags);
648 add_sort_by_variable_size_key_data_many(
"", NULL);
649 add_sort_by_variable_size_key_data_many(
" - tiny", set_tiny_flags);
667 for (node = test_data->
strings; node; node = g_list_next(node)) {
668 gchar *key = node->data;
674 sort_result, test_data->
options);
676 retrieve_all_keys(sort_result, n_entries));
680 add_sort_by_value_data(
const gchar *additional_label,
685 values = gcut_take_list(gcut_list_string_new(
"セナ",
693 cut_add_data(cut_take_printf(
"ascending%s", additional_label),
694 sort_test_data_new(gcut_list_string_new(
"Senna",
703 compare_string, NULL,
707 sort_test_data_free);
709 cut_add_data(cut_take_printf(
"ascending - limit%s", additional_label),
710 sort_test_data_new(gcut_list_string_new(
"Senna",
717 compare_string, NULL,
721 sort_test_data_free);
723 cut_add_data(cut_take_printf(
"descending%s", additional_label),
724 sort_test_data_new(gcut_list_string_new(
"ナセナセ",
733 compare_string, NULL,
737 sort_test_data_free);
739 cut_add_data(cut_take_printf(
"descending - limit%s", additional_label),
740 sort_test_data_new(gcut_list_string_new(
"ナセナセ",
747 compare_string, NULL,
751 sort_test_data_free);
755 add_sort_by_value_data_many(
const gchar *additional_label,
760 values = gcut_take_list(gcut_list_string_new(
"セナ",
772 cut_add_data(cut_take_printf(
"many - ascending%s", additional_label),
773 sort_test_data_new(gcut_list_string_new(
"Ludia",
786 compare_string, NULL,
790 sort_test_data_free);
792 cut_add_data(cut_take_printf(
"many - ascending - limit%s", additional_label),
793 sort_test_data_new(gcut_list_string_new(
"Ludia",
800 compare_string, NULL,
804 sort_test_data_free);
806 cut_add_data(cut_take_printf(
"many - descending%s", additional_label),
807 sort_test_data_new(gcut_list_string_new(
"ブラジル",
820 compare_string, NULL,
824 sort_test_data_free);
826 cut_add_data(cut_take_printf(
"many - descending - limit%s", additional_label),
827 sort_test_data_new(gcut_list_string_new(
"ブラジル",
834 compare_string, NULL,
838 sort_test_data_free);
844 add_sort_by_value_data(
"", NULL);
845 add_sort_by_value_data(
" - tiny", set_tiny_flags);
847 add_sort_by_value_data_many(
"", NULL);
848 add_sort_by_value_data_many(
" - tiny", set_tiny_flags);
859 key_size =
sizeof(key);
868 for (node = test_data->
strings; node; node = g_list_next(node)) {
869 gchar *_value = node->data;
876 sort_result, test_data->
options);
878 retrieve_all_values(sort_result, n_entries));