void test_add_cond_with_invalid_argument(void) { unsigned int n_conds = 0, max_n_conds = 32U; const gchar keyword[] = "Groonga"; unsigned int keyword_len; const gchar open_tag[] = "<<"; const gchar close_tag[] = ">>"; unsigned int open_tag_len, close_tag_len; keyword_len = strlen(keyword); open_tag_len = strlen(open_tag); close_tag_len = strlen(close_tag); cut_assert_open_snip(); grn_test_assert(grn_snip_add_cond(&context, snip, keyword, keyword_len, open_tag, open_tag_len, close_tag, close_tag_len)); n_conds++; grn_test_assert_equal_rc(GRN_INVALID_ARGUMENT, grn_snip_add_cond(&context, NULL, keyword, keyword_len, open_tag, open_tag_len, close_tag, close_tag_len)); grn_test_assert_equal_rc(GRN_INVALID_ARGUMENT, grn_snip_add_cond(&context, snip, NULL, keyword_len, open_tag, open_tag_len, close_tag, close_tag_len)); grn_test_assert_equal_rc(GRN_INVALID_ARGUMENT, grn_snip_add_cond(&context, snip, keyword, 0, open_tag, open_tag_len, close_tag, close_tag_len)); while (n_conds < max_n_conds) { grn_test_assert(grn_snip_add_cond(&context, snip, keyword, keyword_len, open_tag, open_tag_len, close_tag, close_tag_len), cut_message("cond #%d", n_conds)); n_conds++; } grn_test_assert_equal_rc(GRN_INVALID_ARGUMENT, grn_snip_add_cond(&context, snip, keyword, keyword_len, open_tag, open_tag_len, close_tag, close_tag_len), cut_message("cond #%d", n_conds)); }
void test_suffix_search(gconstpointer data) { const grn_trie_test_data *test_data = data; const gchar key1[] = "セナ"; const gchar key2[] = "ナセナセ"; const gchar key3[] = "Groonga"; const gchar key4[] = "セナ + Ruby"; const gchar key5[] = "セナセナ"; trie_test_data_set_parameters(test_data); cut_assert_create_trie(); cut_assert_lookup_add(key1); cut_assert_lookup_add(key2); cut_assert_lookup_add(key3); cut_assert_lookup_add(key4); cut_assert_lookup_add(key5); cut_assert_create_hash(); grn_test_assert_equal_rc(test_data->expected_rc, grn_pat_suffix_search(context, trie, test_data->search_key, strlen(test_data->search_key), hash)); gcut_assert_equal_list_string(test_data->expected_strings, retrieve_all_keys()); }
void test_int32_to_geo_point_invalid(void) { grn_obj_reinit(&context, &dest, GRN_DB_WGS84_GEO_POINT, 0); set_int32(1); grn_test_assert_equal_rc(GRN_INVALID_ARGUMENT, grn_obj_cast(&context, &src, &dest, GRN_FALSE)); }
void test_text_to_geo_point_mixed_invalid(void) { grn_obj_reinit(&context, &dest, GRN_DB_WGS84_GEO_POINT, 0); set_text("35.6954581363924x503802073garbage"); grn_test_assert_equal_rc(GRN_INVALID_ARGUMENT, grn_obj_cast(&context, &src, &dest, FALSE)); }
void test_text_to_geo_point_in_degree_invalid(void) { grn_obj_reinit(&context, &dest, GRN_DB_WGS84_GEO_POINT, 0); set_text("35.6954581363924?139.564207350021"); grn_test_assert_equal_rc(GRN_INVALID_ARGUMENT, grn_obj_cast(&context, &src, &dest, FALSE)); }
void test_text_to_geo_point_invalid(void) { grn_obj_reinit(&context, &dest, GRN_DB_WGS84_GEO_POINT, 0); set_text("130194581?503802073"); grn_test_assert_equal_rc(GRN_INVALID_ARGUMENT, grn_obj_cast(&context, &src, &dest, FALSE)); }
void test_text_error(gconstpointer data) { grn_obj_reinit(&context, &dest, gcut_data_get_uint(data, "type"), 0); grn_obj_reinit(&context, &src, GRN_DB_TEXT, 0); GRN_TEXT_PUTS(&context, &src, gcut_data_get_string(data, "text")); grn_test_assert_equal_rc(gcut_data_get_uint(data, "expected"), grn_obj_cast(&context, &src, &dest, GRN_FALSE)); }
static void cast_text(grn_rc expected_rc, const gchar *text) { grn_obj_reinit(&context, &src, GRN_DB_TEXT, 0); if (text) { GRN_TEXT_PUTS(&context, &src, text); } grn_test_assert_equal_rc(expected_rc, grn_obj_cast(&context, &src, &dest, GRN_FALSE)); }
void test_set_value_with_null_value(gconstpointer data) { const grn_test_set_parameters_func set_parameters = data; grn_id nonexistence_id = 999; if (set_parameters) set_parameters(); cut_assert_create_hash(); grn_test_assert_equal_rc(GRN_INVALID_ARGUMENT, grn_hash_set_value(context, hash, nonexistence_id, NULL, GRN_OBJ_SET)); put_sample_entry(); grn_test_assert_equal_rc(GRN_INVALID_ARGUMENT, grn_hash_set_value(context, hash, sample_id, NULL, GRN_OBJ_SET)); }
void test_add_cond_with_too_large_keyword(void) { const gchar *sub_text; cut_assert_open_snip(); cut_assert_operator_int(strlen(text), >, default_width); grn_test_assert_equal_rc(GRN_INVALID_ARGUMENT, grn_snip_add_cond(&context, snip, text, strlen(text), NULL, 0, NULL, 0)); sub_text = text + strlen(text) - default_width; grn_test_assert(grn_snip_add_cond(&context, snip, sub_text, strlen(sub_text), NULL, 0, NULL, 0)); sub_text--; grn_test_assert_equal_rc(GRN_INVALID_ARGUMENT, grn_snip_add_cond(&context, snip, sub_text, strlen(sub_text), NULL, 0, NULL, 0)); }
void test_exec_with_invalid_argument(void) { unsigned int n_results; unsigned int max_tagged_len; cut_assert_open_snip(); grn_test_assert(grn_snip_exec(&context, snip, text, strlen(text), &n_results, &max_tagged_len)); grn_test_assert_equal_rc(GRN_INVALID_ARGUMENT, grn_snip_exec(&context, NULL, text, strlen(text), &n_results, &max_tagged_len)); grn_test_assert_equal_rc(GRN_INVALID_ARGUMENT, grn_snip_exec(&context, snip, NULL, strlen(text), &n_results, &max_tagged_len)); grn_test_assert_equal_rc(GRN_INVALID_ARGUMENT, grn_snip_exec(&context, snip, text, strlen(text), NULL, &max_tagged_len)); grn_test_assert_equal_rc(GRN_INVALID_ARGUMENT, grn_snip_exec(&context, snip, text, strlen(text), &n_results, NULL)); }
void test_default(void) { grn_encoding default_encoding; default_encoding = grn_get_default_encoding(); grn_test_assert_equal_rc(GRN_INVALID_ARGUMENT, grn_set_default_encoding(999)); grn_test_assert_equal_encoding(default_encoding, grn_get_default_encoding()); grn_test_assert(grn_set_default_encoding(GRN_ENC_SJIS)); grn_test_assert_equal_encoding(GRN_ENC_SJIS, grn_get_default_encoding()); }
void test_invalid_result_index(void) { unsigned int n_results; unsigned int max_tagged_len; unsigned int result_len; const gchar keyword[] = "index"; cut_assert_open_snip(); grn_test_assert(grn_snip_add_cond(&context, snip, keyword, strlen(keyword), NULL, 0, NULL, 0)); grn_test_assert(grn_snip_exec(&context, snip, text, strlen(text), &n_results, &max_tagged_len)); cut_assert_equal_uint(1, n_results); cut_assert_equal_uint(113, max_tagged_len); result = g_new(gchar, max_tagged_len); grn_test_assert(grn_snip_get_result(&context, snip, 0, result, &result_len)); grn_test_assert_equal_rc(GRN_INVALID_ARGUMENT, grn_snip_get_result(&context, snip, 1, result, &result_len)); }
void test_close_with_null(void) { grn_test_assert_equal_rc(GRN_INVALID_ARGUMENT, grn_obj_close(&context, NULL)); }