[Groonga-commit] groonga/groonga [master] [test][query-expansion] don't expand 'OR' at the end.

Back to archive index

null+****@clear***** null+****@clear*****
2011年 9月 11日 (日) 19:34:50 JST


Kouhei Sutou	2011-09-11 10:34:50 +0000 (Sun, 11 Sep 2011)

  New Revision: 78e38133004503f00329380e58fe6c6f73d1da75

  Log:
    [test][query-expansion] don't expand 'OR' at the end.

  Modified files:
    lib/proc.c
    test/unit/core/test-command-select-query-expansion.c

  Modified: lib/proc.c (+2 -1)
===================================================================
--- lib/proc.c    2011-09-11 10:24:31 +0000 (da39669)
+++ lib/proc.c    2011-09-11 10:34:50 +0000 (f00c964)
@@ -104,7 +104,8 @@ expand_query(grn_ctx *ctx, grn_obj *table, grn_obj *column, grn_expr_flags flags
       }
       break;
     case 'O' :
-      if (cur + 2 < str_end && cur[1] == 'R' && grn_isspace(cur + 2, ctx->encoding)) {
+      if (cur + 2 <= str_end && cur[1] == 'R' &&
+          (cur + 2 == str_end || grn_isspace(cur + 2, ctx->encoding))) {
         GRN_TEXT_PUT(ctx, dest, cur, 2);
         cur += 2;
         break;

  Modified: test/unit/core/test-command-select-query-expansion.c (+4 -5)
===================================================================
--- test/unit/core/test-command-select-query-expansion.c    2011-09-11 10:24:31 +0000 (bcce14f)
+++ test/unit/core/test-command-select-query-expansion.c    2011-09-11 10:34:50 +0000 (3e1820e)
@@ -25,7 +25,7 @@
 
 void test_expand(void);
 void test_expand_recursive_not_supported(void);
-void test_expand_OR(void);
+void test_expand_OR_at_the_end(void);
 void test_expand_OR_with_leading_space(void);
 void test_no_expand(void);
 void test_nonexistent_expansion_column(void);
@@ -160,14 +160,13 @@ test_expand_recursive_not_supported(void)
 }
 
 void
-test_expand_OR(void)
+test_expand_OR_at_the_end(void)
 {
   cut_assert_equal_string(
-      "[[[1],"
+      "[[[0],"
        "[[\"_id\",\"UInt32\"],"
         "[\"_key\",\"Time\"],"
-        "[\"content\",\"Text\"]],"
-       "[10,1316444400.0,\"明日は日本語あるいは中国語を勉強します。\"]]]",
+        "[\"content\",\"Text\"]]]]",
     send_command("select Diaries --sortby _id "
                  "--match_columns content --query OR "
                  "--query_expand Synonyms.words"));




Groonga-commit メーリングリストの案内
Back to archive index