[Groonga-commit] groonga/groonga [master] add a test for deleting breaks data. #844

Back to archive index

null+****@clear***** null+****@clear*****
2011年 1月 29日 (土) 21:47:49 JST


Kouhei Sutou	2011-01-29 12:47:49 +0000 (Sat, 29 Jan 2011)

  New Revision: dab6069c7306e8e022d0c6a9f7f6bafee1236375

  Log:
    add a test for deleting breaks data. #844

  Modified files:
    test/unit/core/test-command-delete.c

  Modified: test/unit/core/test-command-delete.c (+48 -1)
===================================================================
--- test/unit/core/test-command-delete.c    2011-01-28 03:23:17 +0000 (3e486b7)
+++ test/unit/core/test-command-delete.c    2011-01-29 12:47:49 +0000 (89e9088)
@@ -1,6 +1,6 @@
 /* -*- c-basic-offset: 2; coding: utf-8 -*- */
 /*
-  Copyright (C) 2010  Kouhei Sutou <kou****@clear*****>
+  Copyright (C) 2010-2011  Kouhei Sutou <kou****@clear*****>
 
   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
@@ -30,6 +30,7 @@ void test_uint64(void);
 void test_last_token(void);
 void test_no_key_twice(void);
 void test_no_key_by_id(void);
+void test_corrupt_jagged_array(void);
 
 static gchar *tmp_directory;
 
@@ -234,3 +235,49 @@ test_no_key_by_id(void)
                            "[3,\"Cutter\"]]]",
                           send_command("select Sites"));
 }
+
+void
+test_corrupt_jagged_array(void)
+{
+  const gchar *text_65bytes =
+    "65bytes text "
+    "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
+  const gchar *text_129bytes =
+    "129bytes text "
+    "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
+    "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
+
+  assert_send_command("table_create Sites TABLE_NO_KEY");
+  assert_send_command("column_create Sites description COLUMN_SCALAR ShortText");
+  cut_assert_equal_string(
+    "1",
+    send_command(cut_take_printf("load --table Sites\n"
+                                 "[[\"description\"],\n"
+                                 "[\"%s\"]\n"
+                                 "]",
+                                 text_129bytes)));
+  assert_send_command("delete Sites --id 1");
+
+  cut_assert_equal_string(
+    "3",
+    send_command(cut_take_printf("load --table Sites\n"
+                                 "[[\"description\"],\n"
+                                 "[\"%s\"],\n"
+                                 "[\"%s\"],\n"
+                                 "[\"%s\"]"
+                                 "]",
+                                 text_65bytes,
+                                 text_65bytes,
+                                 text_129bytes)));
+  cut_assert_equal_string(
+    cut_take_printf("[[[3],"
+                    "[[\"_id\",\"UInt32\"],"
+                     "[\"description\",\"ShortText\"]],"
+                     "[2,\"%s\"],"
+                     "[3,\"%s\"],"
+                     "[4,\"%s\"]]]",
+                    text_65bytes,
+                    text_65bytes,
+                    text_129bytes),
+                    send_command("select Sites"));
+}




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