null+****@clear*****
null+****@clear*****
2011年 9月 11日 (日) 21:23:32 JST
Kouhei Sutou 2011-09-11 12:23:32 +0000 (Sun, 11 Sep 2011)
New Revision: 756b5a56b6da80656d9e4060ad15451e8402f7d0
Log:
[test][query-expansion] add tests for operators.
Modified files:
test/unit/core/test-command-select-query-expansion.c
Modified: test/unit/core/test-command-select-query-expansion.c (+59 -2)
===================================================================
--- test/unit/core/test-command-select-query-expansion.c 2011-09-11 11:21:03 +0000 (b72ce92)
+++ test/unit/core/test-command-select-query-expansion.c 2011-09-11 12:23:32 +0000 (7e7cf98)
@@ -30,6 +30,9 @@ void test_expand_OR_quoted(void);
void test_not_expand_OR(void);
void test_not_expand_OR_at_the_end(void);
void test_not_expand_OR_with_leading_space(void);
+void test_not_expand_and(void);
+void test_not_expand_but(void);
+void test_not_expand_paren(void);
void test_no_expand(void);
void test_no_expand_word_with_space(void);
void test_nonexistent_expansion_column(void);
@@ -86,7 +89,10 @@ setup_data(void)
"[\"2011-09-19 00:00:00\", "
"\"Learning Ruby and groonga...\"],\n"
"[\"2011-09-20 00:00:00\", "
- "\"明日は日本語あるいは中国語を勉強します。\"]\n"
+ "\"明日は日本語あるいは中国語を勉強します。\"],\n"
+ "[\"2011-09-21 00:00:00\", "
+ "\"かつ 差集合 より重要 重要度を下げる "
+ "補集合 前方一致 かっこ こっか\"]\n"
"]");
assert_send_command("load --table Synonyms\n"
"[\n"
@@ -98,7 +104,15 @@ setup_data(void)
"\\\"groonga storage engine\\\")\"],\n"
"[\"groonga storage engine\", "
"\"(\\\"groonga storage engine\\\" OR mroonga)\"],\n"
- "[\"OR\", \"あるいは\"]\n"
+ "[\"OR\", \"あるいは\"],\n"
+ "[\"+\", \"かつ\"],\n"
+ "[\"-\", \"差集合\"],\n"
+ "[\">\", \"より重要\"],\n"
+ "[\"<\", \"重要度を下げる\"],\n"
+ "[\"~\", \"補集合\"],\n"
+ "[\"*\", \"前方一致\"],\n"
+ "[\"(\", \"かっこ\"],\n"
+ "[\")\", \"こっか\"],\n"
"]");
}
@@ -239,6 +253,49 @@ test_not_expand_OR_with_leading_space(void)
}
void
+test_not_expand_and(void)
+{
+ cut_assert_equal_string(
+ "[[[1],"
+ "[[\"_id\",\"UInt32\"],"
+ "[\"_key\",\"Time\"],"
+ "[\"content\",\"Text\"]],"
+ "[9,1316358000.0,\"Learning Ruby and groonga...\"]]]",
+ send_command("select Diaries --sortby _id "
+ "--match_columns content --query 'Ruby + groonga' "
+ "--query_expand Synonyms.words"));
+}
+
+void
+test_not_expand_but(void)
+{
+ cut_assert_equal_string(
+ "[[[1],"
+ "[[\"_id\",\"UInt32\"],"
+ "[\"_key\",\"Time\"],"
+ "[\"content\",\"Text\"]],"
+ "[9,1316358000.0,\"Learning Ruby and groonga...\"]]]",
+ send_command("select Diaries --sortby _id "
+ "--match_columns content --query 'Ruby - Start' "
+ "--query_expand Synonyms.words"));
+}
+
+void
+test_not_expand_paren(void)
+{
+ cut_assert_equal_string(
+ "[[[2],"
+ "[[\"_id\",\"UInt32\"],"
+ "[\"_key\",\"Time\"],"
+ "[\"content\",\"Text\"]],"
+ "[4,1315926000.0,\"Start Ruby!\"],"
+ "[9,1316358000.0,\"Learning Ruby and groonga...\"]]]",
+ send_command("select Diaries --sortby _id "
+ "--match_columns content --query '(Ruby)' "
+ "--query_expand Synonyms.words"));
+}
+
+void
test_no_expand(void)
{
cut_assert_equal_string(