null+****@clear*****
null+****@clear*****
2011年 8月 2日 (火) 18:43:27 JST
Kouhei Sutou 2011-08-02 09:43:27 +0000 (Tue, 02 Aug 2011)
New Revision: 4f3aa9bd6c486783ff13119be7e904ca34320f3e
Log:
[pat][cursor][test] add a test about grn_pat_cursor_next(). fixes #1039
Modified files:
test/unit/core/test-patricia-trie-cursor.c
Modified: test/unit/core/test-patricia-trie-cursor.c (+53 -1)
===================================================================
--- test/unit/core/test-patricia-trie-cursor.c 2011-07-30 09:34:37 +0000 (ea37ba5)
+++ test/unit/core/test-patricia-trie-cursor.c 2011-08-02 09:43:27 +0000 (678754b)
@@ -1,6 +1,6 @@
/* -*- c-basic-offset: 2; coding: utf-8 -*- */
/*
- Copyright (C) 2008-2009 Kouhei Sutou <kou****@cozmi*****>
+ Copyright (C) 2008-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
@@ -24,6 +24,8 @@ void data_next_with_one_entry(void);
void test_next_with_one_entry(gconstpointer data);
void data_next_with_multi_entries(void);
void test_next_with_multi_entries(gconstpointer data);
+void data_digit(void);
+void test_digit(gconstpointer data);
void data_value(void);
void test_value(gconstpointer data);
void data_delete(void);
@@ -834,6 +836,56 @@ test_next_with_multi_entries(gconstpointer data)
}
static void
+set_min_digit(void)
+{
+ default_cursor_min = g_strdup("0");
+ default_cursor_min_size = strlen(default_cursor_min);
+}
+
+static void
+set_max_digit(void)
+{
+ default_cursor_max = g_strdup("9989");
+ default_cursor_max_size = strlen(default_cursor_max);
+}
+
+void
+data_digit(void)
+{
+ cut_add_data("min - max - descending",
+ test_data_new(gcut_list_string_new("997",
+ NULL),
+ set_min_digit, set_max_digit, set_descending, NULL),
+ test_data_free,
+ NULL);
+}
+
+void
+test_digit(gconstpointer data)
+{
+ const grn_trie_test_data *test_data = data;
+ const GList *keys;
+
+ keys = gcut_take_new_list_string("997",
+ "999",
+ "9998",
+ NULL);
+
+ trie_test_data_set_parameters(test_data);
+
+ cut_assert_create_trie();
+
+ for (; keys; keys = g_list_next(keys)) {
+ const gchar *key = keys->data;
+ cut_assert_lookup_add(key);
+ }
+
+ cut_assert_open_cursor();
+ gcut_assert_equal_list_string(test_data->expected_strings,
+ retrieve_all_keys());
+}
+
+static void
set_value_size(void)
{
default_value_size = strlen("上書きされた値 -");