Kouhei Sutou
null+****@clear*****
Tue Mar 10 15:50:23 JST 2015
Kouhei Sutou 2015-03-10 15:50:23 +0900 (Tue, 10 Mar 2015) New Revision: 0cf4da885e840e96d85545d8cc1039dc9d867083 https://github.com/groonga/groonga/commit/0cf4da885e840e96d85545d8cc1039dc9d867083 Message: test: add tests for grn_operator_exec_greater_equal() Modified files: test/unit/core/test-operator.c Modified: test/unit/core/test-operator.c (+71 -0) =================================================================== --- test/unit/core/test-operator.c 2015-03-10 15:50:02 +0900 (688e994) +++ test/unit/core/test-operator.c 2015-03-10 15:50:23 +0900 (0b17d7b) @@ -45,6 +45,10 @@ void data_exec_less_equal_true(void); void test_exec_less_equal_true(gconstpointer data); void data_exec_less_equal_false(void); void test_exec_less_equal_false(gconstpointer data); +void data_exec_greater_equal_true(void); +void test_exec_greater_equal_true(gconstpointer data); +void data_exec_greater_equal_false(void); +void test_exec_greater_equal_false(gconstpointer data); static gchar *tmp_directory; @@ -447,3 +451,70 @@ test_exec_less_equal_false(gconstpointer data) cut_assert_false(grn_operator_exec_less_equal(context, &lhs, &rhs)); } + +void +data_exec_greater_equal_true(void) +{ +#define ADD_DATA(lhs_type, rhs_type) \ + gcut_add_datum(lhs_type " >= " rhs_type, \ + "lhs_type", G_TYPE_STRING, lhs_type, \ + "rhs_type", G_TYPE_STRING, rhs_type, \ + NULL) + + ADD_DATA("int32", "int32"); + ADD_DATA("text", "text"); + ADD_DATA("text", "int32"); + ADD_DATA("int32", "text"); + +#undef ADD_DATA +} + +void +test_exec_greater_equal_true(gconstpointer data) +{ + const gchar *lhs_type; + const gchar *rhs_type; + + lhs_type = gcut_data_get_string(data, "lhs_type"); + rhs_type = gcut_data_get_string(data, "rhs_type"); + + set_two(&lhs, lhs_type); + + set_two(&rhs, rhs_type); + cut_assert_true(grn_operator_exec_greater_equal(context, &lhs, &rhs)); + + set_one(&rhs, rhs_type); + cut_assert_true(grn_operator_exec_greater_equal(context, &lhs, &rhs)); +} + +void +data_exec_greater_equal_false(void) +{ +#define ADD_DATA(lhs_type, rhs_type) \ + gcut_add_datum(lhs_type " >= " rhs_type, \ + "lhs_type", G_TYPE_STRING, lhs_type, \ + "rhs_type", G_TYPE_STRING, rhs_type, \ + NULL) + + ADD_DATA("int32", "int32"); + ADD_DATA("text", "text"); + ADD_DATA("text", "int32"); + ADD_DATA("int32", "text"); + +#undef ADD_DATA +} + +void +test_exec_greater_equal_false(gconstpointer data) +{ + const gchar *lhs_type; + const gchar *rhs_type; + + lhs_type = gcut_data_get_string(data, "lhs_type"); + rhs_type = gcut_data_get_string(data, "rhs_type"); + + set_one(&lhs, lhs_type); + set_two(&rhs, rhs_type); + + cut_assert_false(grn_operator_exec_greater_equal(context, &lhs, &rhs)); +} -------------- next part -------------- HTML����������������������������... Download