rroonga 0.9.2-mswin32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/AUTHORS +5 -0
- data/NEWS.ja.rdoc +114 -0
- data/NEWS.rdoc +116 -0
- data/README.ja.rdoc +65 -0
- data/README.rdoc +66 -0
- data/Rakefile +217 -0
- data/benchmark/common.rb +49 -0
- data/benchmark/read-write-many-small-items.rb +144 -0
- data/benchmark/write-many-small-items.rb +135 -0
- data/example/bookmark.rb +161 -0
- data/example/index-html.rb +89 -0
- data/example/search/config.ru +211 -0
- data/example/search/public/css/groonga.css +122 -0
- data/ext/.gitignore +2 -0
- data/ext/libruby-groonga.a +0 -0
- data/ext/rb-grn-accessor.c +52 -0
- data/ext/rb-grn-array-cursor.c +36 -0
- data/ext/rb-grn-array.c +210 -0
- data/ext/rb-grn-column.c +573 -0
- data/ext/rb-grn-context.c +655 -0
- data/ext/rb-grn-database.c +472 -0
- data/ext/rb-grn-encoding-support.c +64 -0
- data/ext/rb-grn-encoding.c +257 -0
- data/ext/rb-grn-exception.c +1110 -0
- data/ext/rb-grn-expression-builder.c +75 -0
- data/ext/rb-grn-expression.c +735 -0
- data/ext/rb-grn-fix-size-column.c +166 -0
- data/ext/rb-grn-hash-cursor.c +38 -0
- data/ext/rb-grn-hash.c +294 -0
- data/ext/rb-grn-index-column.c +488 -0
- data/ext/rb-grn-logger.c +504 -0
- data/ext/rb-grn-object.c +1369 -0
- data/ext/rb-grn-operation.c +198 -0
- data/ext/rb-grn-patricia-trie-cursor.c +39 -0
- data/ext/rb-grn-patricia-trie.c +488 -0
- data/ext/rb-grn-procedure.c +52 -0
- data/ext/rb-grn-query.c +260 -0
- data/ext/rb-grn-record.c +40 -0
- data/ext/rb-grn-snippet.c +334 -0
- data/ext/rb-grn-table-cursor-key-support.c +69 -0
- data/ext/rb-grn-table-cursor.c +247 -0
- data/ext/rb-grn-table-key-support.c +731 -0
- data/ext/rb-grn-table.c +2141 -0
- data/ext/rb-grn-type.c +181 -0
- data/ext/rb-grn-utils.c +769 -0
- data/ext/rb-grn-variable-size-column.c +36 -0
- data/ext/rb-grn-variable.c +108 -0
- data/ext/rb-grn-view-accessor.c +53 -0
- data/ext/rb-grn-view-cursor.c +35 -0
- data/ext/rb-grn-view-record.c +41 -0
- data/ext/rb-grn-view.c +421 -0
- data/ext/rb-grn.h +700 -0
- data/ext/rb-groonga.c +117 -0
- data/extconf.rb +266 -0
- data/html/bar.svg +153 -0
- data/html/developer.html +117 -0
- data/html/developer.svg +469 -0
- data/html/download.svg +253 -0
- data/html/favicon.ico +0 -0
- data/html/favicon.xcf +0 -0
- data/html/footer.html.erb +28 -0
- data/html/head.html.erb +4 -0
- data/html/header.html.erb +17 -0
- data/html/index.html +147 -0
- data/html/install.svg +636 -0
- data/html/logo.xcf +0 -0
- data/html/ranguba.css +250 -0
- data/html/tutorial.svg +559 -0
- data/lib/groonga.rb +90 -0
- data/lib/groonga/context.rb +184 -0
- data/lib/groonga/expression-builder.rb +285 -0
- data/lib/groonga/patricia-trie.rb +53 -0
- data/lib/groonga/record.rb +311 -0
- data/lib/groonga/schema.rb +1191 -0
- data/lib/groonga/view-record.rb +56 -0
- data/license/GPL +340 -0
- data/license/LGPL +504 -0
- data/license/RUBY +59 -0
- data/misc/grnop2ruby.rb +49 -0
- data/pkg-config.rb +333 -0
- data/test-unit/Rakefile +40 -0
- data/test-unit/TODO +5 -0
- data/test-unit/bin/testrb +5 -0
- data/test-unit/html/classic.html +15 -0
- data/test-unit/html/index.html +25 -0
- data/test-unit/html/index.html.ja +27 -0
- data/test-unit/lib/test/unit.rb +323 -0
- data/test-unit/lib/test/unit/assertionfailederror.rb +25 -0
- data/test-unit/lib/test/unit/assertions.rb +1230 -0
- data/test-unit/lib/test/unit/attribute.rb +125 -0
- data/test-unit/lib/test/unit/autorunner.rb +360 -0
- data/test-unit/lib/test/unit/collector.rb +36 -0
- data/test-unit/lib/test/unit/collector/descendant.rb +23 -0
- data/test-unit/lib/test/unit/collector/dir.rb +108 -0
- data/test-unit/lib/test/unit/collector/load.rb +136 -0
- data/test-unit/lib/test/unit/collector/objectspace.rb +34 -0
- data/test-unit/lib/test/unit/color-scheme.rb +102 -0
- data/test-unit/lib/test/unit/color.rb +96 -0
- data/test-unit/lib/test/unit/diff.rb +724 -0
- data/test-unit/lib/test/unit/error.rb +130 -0
- data/test-unit/lib/test/unit/exceptionhandler.rb +39 -0
- data/test-unit/lib/test/unit/failure.rb +136 -0
- data/test-unit/lib/test/unit/fixture.rb +176 -0
- data/test-unit/lib/test/unit/notification.rb +129 -0
- data/test-unit/lib/test/unit/omission.rb +191 -0
- data/test-unit/lib/test/unit/pending.rb +150 -0
- data/test-unit/lib/test/unit/priority.rb +180 -0
- data/test-unit/lib/test/unit/runner/console.rb +52 -0
- data/test-unit/lib/test/unit/runner/emacs.rb +8 -0
- data/test-unit/lib/test/unit/runner/tap.rb +8 -0
- data/test-unit/lib/test/unit/testcase.rb +476 -0
- data/test-unit/lib/test/unit/testresult.rb +89 -0
- data/test-unit/lib/test/unit/testsuite.rb +110 -0
- data/test-unit/lib/test/unit/ui/console/outputlevel.rb +14 -0
- data/test-unit/lib/test/unit/ui/console/testrunner.rb +466 -0
- data/test-unit/lib/test/unit/ui/emacs/testrunner.rb +63 -0
- data/test-unit/lib/test/unit/ui/tap/testrunner.rb +92 -0
- data/test-unit/lib/test/unit/ui/testrunner.rb +28 -0
- data/test-unit/lib/test/unit/ui/testrunnermediator.rb +77 -0
- data/test-unit/lib/test/unit/ui/testrunnerutilities.rb +41 -0
- data/test-unit/lib/test/unit/util/backtracefilter.rb +41 -0
- data/test-unit/lib/test/unit/util/method-owner-finder.rb +28 -0
- data/test-unit/lib/test/unit/util/observable.rb +90 -0
- data/test-unit/lib/test/unit/util/procwrapper.rb +48 -0
- data/test-unit/lib/test/unit/version.rb +7 -0
- data/test-unit/sample/adder.rb +13 -0
- data/test-unit/sample/subtracter.rb +12 -0
- data/test-unit/sample/test_adder.rb +20 -0
- data/test-unit/sample/test_subtracter.rb +20 -0
- data/test-unit/sample/test_user.rb +23 -0
- data/test-unit/test/collector/test-descendant.rb +133 -0
- data/test-unit/test/collector/test-load.rb +348 -0
- data/test-unit/test/collector/test_dir.rb +406 -0
- data/test-unit/test/collector/test_objectspace.rb +100 -0
- data/test-unit/test/run-test.rb +15 -0
- data/test-unit/test/test-attribute.rb +86 -0
- data/test-unit/test/test-color-scheme.rb +67 -0
- data/test-unit/test/test-color.rb +47 -0
- data/test-unit/test/test-diff.rb +518 -0
- data/test-unit/test/test-emacs-runner.rb +60 -0
- data/test-unit/test/test-fixture.rb +287 -0
- data/test-unit/test/test-notification.rb +33 -0
- data/test-unit/test/test-omission.rb +81 -0
- data/test-unit/test/test-pending.rb +70 -0
- data/test-unit/test/test-priority.rb +119 -0
- data/test-unit/test/test-testcase.rb +544 -0
- data/test-unit/test/test_assertions.rb +1151 -0
- data/test-unit/test/test_error.rb +26 -0
- data/test-unit/test/test_failure.rb +33 -0
- data/test-unit/test/test_testresult.rb +113 -0
- data/test-unit/test/test_testsuite.rb +129 -0
- data/test-unit/test/testunit-test-util.rb +14 -0
- data/test-unit/test/ui/test_testrunmediator.rb +20 -0
- data/test-unit/test/util/test-method-owner-finder.rb +38 -0
- data/test-unit/test/util/test_backtracefilter.rb +41 -0
- data/test-unit/test/util/test_observable.rb +102 -0
- data/test-unit/test/util/test_procwrapper.rb +36 -0
- data/test/.gitignore +1 -0
- data/test/groonga-test-utils.rb +133 -0
- data/test/run-test.rb +58 -0
- data/test/test-array.rb +97 -0
- data/test/test-column.rb +316 -0
- data/test/test-context-select.rb +93 -0
- data/test/test-context.rb +73 -0
- data/test/test-database.rb +113 -0
- data/test/test-encoding.rb +33 -0
- data/test/test-exception.rb +93 -0
- data/test/test-expression-builder.rb +156 -0
- data/test/test-expression.rb +134 -0
- data/test/test-fix-size-column.rb +65 -0
- data/test/test-gqtp.rb +72 -0
- data/test/test-hash.rb +312 -0
- data/test/test-index-column.rb +81 -0
- data/test/test-logger.rb +37 -0
- data/test/test-patricia-trie.rb +189 -0
- data/test/test-procedure.rb +37 -0
- data/test/test-query.rb +22 -0
- data/test/test-record.rb +279 -0
- data/test/test-remote.rb +54 -0
- data/test/test-schema-view.rb +90 -0
- data/test/test-schema.rb +459 -0
- data/test/test-snippet.rb +130 -0
- data/test/test-table-cursor.rb +153 -0
- data/test/test-table-offset-and-limit.rb +102 -0
- data/test/test-table-select-normalize.rb +53 -0
- data/test/test-table-select.rb +150 -0
- data/test/test-table.rb +690 -0
- data/test/test-type.rb +71 -0
- data/test/test-variable-size-column.rb +98 -0
- data/test/test-variable.rb +28 -0
- data/test/test-vector-column.rb +76 -0
- data/test/test-version.rb +31 -0
- data/test/test-view.rb +72 -0
- data/text/TUTORIAL.ja.rdoc +392 -0
- data/text/expression.rdoc +284 -0
- data/vendor/local/bin/grntest.exe +0 -0
- data/vendor/local/bin/groonga.exe +0 -0
- data/vendor/local/bin/libgroonga.dll +0 -0
- data/vendor/local/bin/libmecab.dll +0 -0
- data/vendor/local/include/groonga.h +2285 -0
- data/vendor/local/lib/libgroonga.lib +0 -0
- metadata +280 -0
@@ -0,0 +1,93 @@
|
|
1
|
+
# Copyright (C) 2010 Kouhei Sutou <kou@clear-code.com>
|
2
|
+
#
|
3
|
+
# This library is free software; you can redistribute it and/or
|
4
|
+
# modify it under the terms of the GNU Lesser General Public
|
5
|
+
# License version 2.1 as published by the Free Software Foundation.
|
6
|
+
#
|
7
|
+
# This library is distributed in the hope that it will be useful,
|
8
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
9
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
10
|
+
# Lesser General Public License for more details.
|
11
|
+
#
|
12
|
+
# You should have received a copy of the GNU Lesser General Public
|
13
|
+
# License along with this library; if not, write to the Free Software
|
14
|
+
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
15
|
+
|
16
|
+
class ContextSelectTest < Test::Unit::TestCase
|
17
|
+
include GroongaTestUtils
|
18
|
+
|
19
|
+
setup :setup_database
|
20
|
+
setup
|
21
|
+
def setup_data
|
22
|
+
@books = Groonga::Hash.create(:name => "Books", :key_type => "ShortText")
|
23
|
+
@books.define_column("published", "Time")
|
24
|
+
@users = Groonga::Hash.create(:name => "Users", :key_type => "ShortText")
|
25
|
+
@users.define_column("book", "Books")
|
26
|
+
|
27
|
+
@books.add("the groonga book", :published => Time.parse("2010/04/01"))
|
28
|
+
@users.add("morita", :book => "the groonga book")
|
29
|
+
@users.add("gunyara-kun", :book => "the groonga book")
|
30
|
+
@users.add("yu")
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_no_option
|
34
|
+
result = context.select(@users)
|
35
|
+
assert_equal([3,
|
36
|
+
[{"_id" => 1, "_key" => "morita",
|
37
|
+
"book" => "the groonga book"},
|
38
|
+
{"_id" => 2, "_key" => "gunyara-kun",
|
39
|
+
"book" => "the groonga book"},
|
40
|
+
{"_id" => 3, "_key" => "yu",
|
41
|
+
"book" => ""}]],
|
42
|
+
[result.n_hits, result.records])
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_success
|
46
|
+
result = context.select(@users)
|
47
|
+
assert_equal([true, 0, nil],
|
48
|
+
[result.success?, result.return_code, result.error_message])
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_output_columns
|
52
|
+
result = context.select(@users, :output_columns => ["_key"])
|
53
|
+
assert_equal([3,
|
54
|
+
[{"_key" => "morita"},
|
55
|
+
{"_key" => "gunyara-kun"},
|
56
|
+
{"_key" => "yu"}]],
|
57
|
+
[result.n_hits, result.records])
|
58
|
+
end
|
59
|
+
|
60
|
+
def test_drill_down
|
61
|
+
result = context.select(@users,
|
62
|
+
:output_columns => ["_key"],
|
63
|
+
:drill_down => ["_key", "book"],
|
64
|
+
:drill_down_output_columns => "_key",
|
65
|
+
:drill_down_limit => 10)
|
66
|
+
normalized_drill_down = {}
|
67
|
+
result.drill_down.each do |key, drill_down|
|
68
|
+
normalized_drill_down[key] = [drill_down.n_hits, drill_down.records]
|
69
|
+
end
|
70
|
+
assert_equal([3,
|
71
|
+
[{"_key" => "morita"},
|
72
|
+
{"_key" => "gunyara-kun"},
|
73
|
+
{"_key" => "yu"}],
|
74
|
+
{
|
75
|
+
"_key" => [3, [{"_key" => "morita"},
|
76
|
+
{"_key" => "gunyara-kun"},
|
77
|
+
{"_key" => "yu"}]],
|
78
|
+
"book" => [1, [{"_key" => "the groonga book"}]],
|
79
|
+
},
|
80
|
+
],
|
81
|
+
[result.n_hits, result.records, normalized_drill_down])
|
82
|
+
end
|
83
|
+
|
84
|
+
def test_time
|
85
|
+
result = context.select(@books)
|
86
|
+
assert_equal([{
|
87
|
+
"_id" => 1,
|
88
|
+
"_key" => "the groonga book",
|
89
|
+
"published" => Time.parse("2010/04/01"),
|
90
|
+
}],
|
91
|
+
result.records)
|
92
|
+
end
|
93
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
# Copyright (C) 2009 Kouhei Sutou <kou@clear-code.com>
|
2
|
+
#
|
3
|
+
# This library is free software; you can redistribute it and/or
|
4
|
+
# modify it under the terms of the GNU Lesser General Public
|
5
|
+
# License version 2.1 as published by the Free Software Foundation.
|
6
|
+
#
|
7
|
+
# This library is distributed in the hope that it will be useful,
|
8
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
9
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
10
|
+
# Lesser General Public License for more details.
|
11
|
+
#
|
12
|
+
# You should have received a copy of the GNU Lesser General Public
|
13
|
+
# License along with this library; if not, write to the Free Software
|
14
|
+
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
15
|
+
|
16
|
+
class ContextTest < Test::Unit::TestCase
|
17
|
+
include GroongaTestUtils
|
18
|
+
|
19
|
+
def test_default
|
20
|
+
context = Groonga::Context.default
|
21
|
+
assert_equal(Groonga::Encoding.default, context.encoding)
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_default_options
|
25
|
+
Groonga::Context.default_options = {
|
26
|
+
:encoding => :utf8,
|
27
|
+
}
|
28
|
+
context = Groonga::Context.default
|
29
|
+
assert_equal(Groonga::Encoding::UTF8, context.encoding)
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_encoding
|
33
|
+
context = Groonga::Context.new
|
34
|
+
assert_equal(Groonga::Encoding.default, context.encoding)
|
35
|
+
|
36
|
+
context = Groonga::Context.new(:encoding => :utf8)
|
37
|
+
assert_equal(Groonga::Encoding::UTF8, context.encoding)
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_inspect
|
41
|
+
context = Groonga::Context.new(:encoding => Groonga::Encoding::UTF8)
|
42
|
+
assert_equal("#<Groonga::Context " +
|
43
|
+
"encoding: <:utf8>, " +
|
44
|
+
"database: <nil>>",
|
45
|
+
context.inspect)
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_inspect_with_database
|
49
|
+
db = Groonga::Database.create
|
50
|
+
context = Groonga::Context.default
|
51
|
+
assert_equal("#<Groonga::Context " +
|
52
|
+
"encoding: <#{Groonga::Encoding.default.inspect}>, " +
|
53
|
+
"database: <#{db.inspect}>>",
|
54
|
+
context.inspect)
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_array_reference_by_string
|
58
|
+
Groonga::Database.create
|
59
|
+
context = Groonga::Context.default
|
60
|
+
assert_equal("Int32", context["<int>"].name)
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_array_reference_by_symbol
|
64
|
+
Groonga::Database.create
|
65
|
+
context = Groonga::Context.default
|
66
|
+
assert_equal("Bool", context[:Bool].name)
|
67
|
+
end
|
68
|
+
|
69
|
+
def test_shortcut_access
|
70
|
+
Groonga::Database.create
|
71
|
+
assert_equal("ShortText", Groonga["ShortText"].name)
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,113 @@
|
|
1
|
+
# Copyright (C) 2009 Kouhei Sutou <kou@clear-code.com>
|
2
|
+
#
|
3
|
+
# This library is free software; you can redistribute it and/or
|
4
|
+
# modify it under the terms of the GNU Lesser General Public
|
5
|
+
# License version 2.1 as published by the Free Software Foundation.
|
6
|
+
#
|
7
|
+
# This library is distributed in the hope that it will be useful,
|
8
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
9
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
10
|
+
# Lesser General Public License for more details.
|
11
|
+
#
|
12
|
+
# You should have received a copy of the GNU Lesser General Public
|
13
|
+
# License along with this library; if not, write to the Free Software
|
14
|
+
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
15
|
+
|
16
|
+
class DatabaseTest < Test::Unit::TestCase
|
17
|
+
include GroongaTestUtils
|
18
|
+
|
19
|
+
def test_create
|
20
|
+
assert_nil(Groonga::Context.default.database)
|
21
|
+
|
22
|
+
db_path = @tmp_dir + "db"
|
23
|
+
assert_not_predicate(db_path, :exist?)
|
24
|
+
database = Groonga::Database.create(:path => db_path.to_s)
|
25
|
+
assert_predicate(db_path, :exist?)
|
26
|
+
assert_not_predicate(database, :closed?)
|
27
|
+
|
28
|
+
assert_equal(database, Groonga::Context.default.database)
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_temporary
|
32
|
+
before_files = @tmp_dir.children
|
33
|
+
database = Groonga::Database.create
|
34
|
+
assert_nil(database.name)
|
35
|
+
assert_equal(before_files, @tmp_dir.children)
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_open
|
39
|
+
db_path = @tmp_dir + "db"
|
40
|
+
database = Groonga::Database.create(:path => db_path.to_s)
|
41
|
+
|
42
|
+
called = false
|
43
|
+
Groonga::Database.open(db_path.to_s) do |_database|
|
44
|
+
database = _database
|
45
|
+
assert_not_predicate(database, :closed?)
|
46
|
+
called = true
|
47
|
+
end
|
48
|
+
assert_true(called)
|
49
|
+
assert_predicate(database, :closed?)
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_new
|
53
|
+
db_path = @tmp_dir + "db"
|
54
|
+
assert_raise(Groonga::NoMemoryAvailable) do
|
55
|
+
Groonga::Database.new(db_path.to_s)
|
56
|
+
end
|
57
|
+
|
58
|
+
database = Groonga::Database.create(:path => db_path.to_s)
|
59
|
+
|
60
|
+
assert_not_predicate(Groonga::Database.new(db_path.to_s), :closed?)
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_each
|
64
|
+
db_path = @tmp_dir + "db"
|
65
|
+
database = Groonga::Database.create(:path => db_path.to_s)
|
66
|
+
default_object_names = database.collect {|object| object.name}.sort
|
67
|
+
assert_send([default_object_names, :include?, "Bool"])
|
68
|
+
end
|
69
|
+
|
70
|
+
def test_encoding
|
71
|
+
assert_equal(Groonga::Encoding.default,
|
72
|
+
Groonga::Database.create.encoding)
|
73
|
+
end
|
74
|
+
|
75
|
+
def test_lock
|
76
|
+
database = Groonga::Database.create
|
77
|
+
|
78
|
+
assert_not_predicate(database, :locked?)
|
79
|
+
database.lock
|
80
|
+
assert_predicate(database, :locked?)
|
81
|
+
database.unlock
|
82
|
+
assert_not_predicate(database, :locked?)
|
83
|
+
end
|
84
|
+
|
85
|
+
def test_lock_failed
|
86
|
+
database = Groonga::Database.create
|
87
|
+
|
88
|
+
database.lock
|
89
|
+
assert_raise(Groonga::ResourceDeadlockAvoided) do
|
90
|
+
database.lock
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
def test_lock_block
|
95
|
+
database = Groonga::Database.create
|
96
|
+
|
97
|
+
assert_not_predicate(database, :locked?)
|
98
|
+
database.lock do
|
99
|
+
assert_predicate(database, :locked?)
|
100
|
+
end
|
101
|
+
assert_not_predicate(database, :locked?)
|
102
|
+
end
|
103
|
+
|
104
|
+
def test_clear_lock
|
105
|
+
database = Groonga::Database.create
|
106
|
+
|
107
|
+
assert_not_predicate(database, :locked?)
|
108
|
+
database.lock
|
109
|
+
assert_predicate(database, :locked?)
|
110
|
+
database.clear_lock
|
111
|
+
assert_not_predicate(database, :locked?)
|
112
|
+
end
|
113
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# Copyright (C) 2009 Kouhei Sutou <kou@clear-code.com>
|
2
|
+
#
|
3
|
+
# This library is free software; you can redistribute it and/or
|
4
|
+
# modify it under the terms of the GNU Lesser General Public
|
5
|
+
# License version 2.1 as published by the Free Software Foundation.
|
6
|
+
#
|
7
|
+
# This library is distributed in the hope that it will be useful,
|
8
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
9
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
10
|
+
# Lesser General Public License for more details.
|
11
|
+
#
|
12
|
+
# You should have received a copy of the GNU Lesser General Public
|
13
|
+
# License along with this library; if not, write to the Free Software
|
14
|
+
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
15
|
+
|
16
|
+
class EncodingTest < Test::Unit::TestCase
|
17
|
+
include GroongaTestUtils
|
18
|
+
|
19
|
+
def test_constants
|
20
|
+
assert_equal(:default, Groonga::Encoding::DEFAULT)
|
21
|
+
assert_equal(:none, Groonga::Encoding::NONE)
|
22
|
+
assert_equal(:euc_jp, Groonga::Encoding::EUC_JP)
|
23
|
+
assert_equal(:sjis, Groonga::Encoding::SJIS)
|
24
|
+
assert_equal(:utf8, Groonga::Encoding::UTF8)
|
25
|
+
assert_equal(:latin1, Groonga::Encoding::LATIN1)
|
26
|
+
assert_equal(:koi8r, Groonga::Encoding::KOI8R)
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_default
|
30
|
+
Groonga::Encoding.default = :utf8
|
31
|
+
assert_equal(:utf8, Groonga::Encoding.default)
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,93 @@
|
|
1
|
+
# Copyright (C) 2009-2010 Kouhei Sutou <kou@clear-code.com>
|
2
|
+
#
|
3
|
+
# This library is free software; you can redistribute it and/or
|
4
|
+
# modify it under the terms of the GNU Lesser General Public
|
5
|
+
# License version 2.1 as published by the Free Software Foundation.
|
6
|
+
#
|
7
|
+
# This library is distributed in the hope that it will be useful,
|
8
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
9
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
10
|
+
# Lesser General Public License for more details.
|
11
|
+
#
|
12
|
+
# You should have received a copy of the GNU Lesser General Public
|
13
|
+
# License along with this library; if not, write to the Free Software
|
14
|
+
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
15
|
+
|
16
|
+
class ExceptionTest < Test::Unit::TestCase
|
17
|
+
include GroongaTestUtils
|
18
|
+
|
19
|
+
def test_defined
|
20
|
+
assert_not_const_defined(Groonga, :Success)
|
21
|
+
|
22
|
+
assert_const_defined(Groonga, :Error)
|
23
|
+
assert_const_defined(Groonga, :ObjectClosed)
|
24
|
+
|
25
|
+
assert_const_defined(Groonga, :EndOfData)
|
26
|
+
assert_const_defined(Groonga, :UnknownError)
|
27
|
+
assert_const_defined(Groonga, :OperationNotPermitted)
|
28
|
+
assert_const_defined(Groonga, :NoSuchFileOrDirectory)
|
29
|
+
assert_const_defined(Groonga, :NoSuchProcess)
|
30
|
+
assert_const_defined(Groonga, :InterruptedFunctionCall)
|
31
|
+
assert_const_defined(Groonga, :InputOutputError)
|
32
|
+
assert_const_defined(Groonga, :NoSuchDeviceOrAddress)
|
33
|
+
assert_const_defined(Groonga, :ArgumentListTooLong)
|
34
|
+
assert_const_defined(Groonga, :ExecFormatError)
|
35
|
+
assert_const_defined(Groonga, :BadFileDescriptor)
|
36
|
+
assert_const_defined(Groonga, :NoChildProcesses)
|
37
|
+
assert_const_defined(Groonga, :ResourceTemporarilyUnavailable)
|
38
|
+
assert_const_defined(Groonga, :NotEnoughSpace)
|
39
|
+
assert_const_defined(Groonga, :PermissionDenied)
|
40
|
+
assert_const_defined(Groonga, :BadAddress)
|
41
|
+
assert_const_defined(Groonga, :ResourceBusy)
|
42
|
+
assert_const_defined(Groonga, :FileExists)
|
43
|
+
assert_const_defined(Groonga, :ImproperLink)
|
44
|
+
assert_const_defined(Groonga, :NoSuchDevice)
|
45
|
+
assert_const_defined(Groonga, :NotADirectory)
|
46
|
+
assert_const_defined(Groonga, :IsADirectory)
|
47
|
+
assert_const_defined(Groonga, :InvalidArgument)
|
48
|
+
assert_const_defined(Groonga, :TooManyOpenFilesInSystem)
|
49
|
+
assert_const_defined(Groonga, :TooManyOpenFiles)
|
50
|
+
assert_const_defined(Groonga, :InappropriateIOControlOperation)
|
51
|
+
assert_const_defined(Groonga, :FileTooLarge)
|
52
|
+
assert_const_defined(Groonga, :NoSpaceLeftOnDevice)
|
53
|
+
assert_const_defined(Groonga, :InvalidSeek)
|
54
|
+
assert_const_defined(Groonga, :ReadOnlyFileSystem)
|
55
|
+
assert_const_defined(Groonga, :TooManyLinks)
|
56
|
+
assert_const_defined(Groonga, :BrokenPipe)
|
57
|
+
assert_const_defined(Groonga, :DomainError)
|
58
|
+
assert_const_defined(Groonga, :ResultTooLarge)
|
59
|
+
assert_const_defined(Groonga, :ResourceDeadlockAvoided)
|
60
|
+
assert_const_defined(Groonga, :NoMemoryAvailable)
|
61
|
+
assert_const_defined(Groonga, :FilenameTooLong)
|
62
|
+
assert_const_defined(Groonga, :NoLocksAvailable)
|
63
|
+
assert_const_defined(Groonga, :FunctionNotImplemented)
|
64
|
+
assert_const_defined(Groonga, :DirectoryNotEmpty)
|
65
|
+
assert_const_defined(Groonga, :IllegalByteSequence)
|
66
|
+
assert_const_defined(Groonga, :SocketNotInitialized)
|
67
|
+
assert_const_defined(Groonga, :OperationWouldBlock)
|
68
|
+
assert_const_defined(Groonga, :AddressIsNotAvailable)
|
69
|
+
assert_const_defined(Groonga, :NetworkIsDown)
|
70
|
+
assert_const_defined(Groonga, :NoBuffer)
|
71
|
+
assert_const_defined(Groonga, :SocketIsAlreadyConnected)
|
72
|
+
assert_const_defined(Groonga, :SocketIsNotConnected)
|
73
|
+
assert_const_defined(Groonga, :SocketIsAlreadyShutdowned)
|
74
|
+
assert_const_defined(Groonga, :OperationTimeout)
|
75
|
+
assert_const_defined(Groonga, :ConnectionRefused)
|
76
|
+
assert_const_defined(Groonga, :RangeError)
|
77
|
+
assert_const_defined(Groonga, :TokenizerError)
|
78
|
+
assert_const_defined(Groonga, :FileCorrupt)
|
79
|
+
assert_const_defined(Groonga, :InvalidFormat)
|
80
|
+
assert_const_defined(Groonga, :ObjectCorrupt)
|
81
|
+
assert_const_defined(Groonga, :TooManySymbolicLinks)
|
82
|
+
assert_const_defined(Groonga, :NotSocket)
|
83
|
+
assert_const_defined(Groonga, :OperationNotSupported)
|
84
|
+
assert_const_defined(Groonga, :AddressIsInUse)
|
85
|
+
assert_const_defined(Groonga, :ZLibError)
|
86
|
+
assert_const_defined(Groonga, :LZOError)
|
87
|
+
assert_const_defined(Groonga, :StackOverFlow)
|
88
|
+
assert_const_defined(Groonga, :SyntaxError)
|
89
|
+
assert_const_defined(Groonga, :RetryMax)
|
90
|
+
assert_const_defined(Groonga, :IncompatibleFileFormat)
|
91
|
+
assert_const_defined(Groonga, :UpdateNotAllowed)
|
92
|
+
end
|
93
|
+
end
|
@@ -0,0 +1,156 @@
|
|
1
|
+
# Copyright (C) 2009 Kouhei Sutou <kou@clear-code.com>
|
2
|
+
#
|
3
|
+
# This library is free software; you can redistribute it and/or
|
4
|
+
# modify it under the terms of the GNU Lesser General Public
|
5
|
+
# License version 2.1 as published by the Free Software Foundation.
|
6
|
+
#
|
7
|
+
# This library is distributed in the hope that it will be useful,
|
8
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
9
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
10
|
+
# Lesser General Public License for more details.
|
11
|
+
#
|
12
|
+
# You should have received a copy of the GNU Lesser General Public
|
13
|
+
# License along with this library; if not, write to the Free Software
|
14
|
+
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
15
|
+
|
16
|
+
class ExpressionBuilderTest < Test::Unit::TestCase
|
17
|
+
include GroongaTestUtils
|
18
|
+
|
19
|
+
setup :setup_database
|
20
|
+
setup :setup_tables
|
21
|
+
setup :setup_data
|
22
|
+
|
23
|
+
def setup_tables
|
24
|
+
@users = Groonga::Hash.create(:name => "Users")
|
25
|
+
@name = @users.define_column("name", "ShortText")
|
26
|
+
@hp = @users.define_column("hp", "UInt32")
|
27
|
+
|
28
|
+
@terms = Groonga::PatriciaTrie.create(:name => "Terms",
|
29
|
+
:default_tokenizer => "TokenBigram")
|
30
|
+
@terms.define_index_column("user_name", @users, :source => @name)
|
31
|
+
|
32
|
+
@bookmarks = Groonga::Array.create(:name => "Bookmarks")
|
33
|
+
@bookmarks.define_column("user", @users)
|
34
|
+
@bookmarks.define_column("uri", "ShortText")
|
35
|
+
end
|
36
|
+
|
37
|
+
def setup_data
|
38
|
+
@morita = @users.add("morita",
|
39
|
+
:name => "mori daijiro",
|
40
|
+
:hp => 100)
|
41
|
+
@gunyara_kun = @users.add("gunyara-kun",
|
42
|
+
:name => "Tasuku SUENAGA",
|
43
|
+
:hp => 150)
|
44
|
+
@yu = @users.add("yu",
|
45
|
+
:name => "Yutaro Shimamura",
|
46
|
+
:hp => 200)
|
47
|
+
|
48
|
+
@groonga = @bookmarks.add(:user => @morita, :uri => "http://groonga.org/")
|
49
|
+
@ruby = @bookmarks.add(:user => @morita, :uri => "http://ruby-lang.org/")
|
50
|
+
@nico_dict = @bookmarks.add(:user => @gunyara_kun,
|
51
|
+
:uri => "http://dic.nicovideo.jp/")
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_equal
|
55
|
+
result = @users.select do |record|
|
56
|
+
record["name"] == "mori daijiro"
|
57
|
+
end
|
58
|
+
assert_equal(["morita"],
|
59
|
+
result.collect {|record| record.key.key})
|
60
|
+
end
|
61
|
+
|
62
|
+
def test_not_equal
|
63
|
+
omit("not supported yet!!!")
|
64
|
+
result = @users.select do |record|
|
65
|
+
record["name"] != "mori daijiro"
|
66
|
+
end
|
67
|
+
assert_equal(["gunyara-kun", "yu"],
|
68
|
+
result.collect {|record| record.key.key})
|
69
|
+
end
|
70
|
+
|
71
|
+
def test_less
|
72
|
+
result = @users.select do |record|
|
73
|
+
record["hp"] < 150
|
74
|
+
end
|
75
|
+
assert_equal(["morita"], result.collect {|record| record.key.key})
|
76
|
+
end
|
77
|
+
|
78
|
+
def test_less_equal
|
79
|
+
result = @users.select do |record|
|
80
|
+
record["hp"] <= 150
|
81
|
+
end
|
82
|
+
assert_equal(["morita", "gunyara-kun"],
|
83
|
+
result.collect {|record| record.key.key})
|
84
|
+
end
|
85
|
+
|
86
|
+
def test_greater
|
87
|
+
result = @users.select do |record|
|
88
|
+
record["hp"] > 150
|
89
|
+
end
|
90
|
+
assert_equal(["yu"], result.collect {|record| record.key.key})
|
91
|
+
end
|
92
|
+
|
93
|
+
def test_greater_equal
|
94
|
+
result = @users.select do |record|
|
95
|
+
record["hp"] >= 150
|
96
|
+
end
|
97
|
+
assert_equal(["gunyara-kun", "yu"],
|
98
|
+
result.collect {|record| record.key.key})
|
99
|
+
end
|
100
|
+
|
101
|
+
def test_and
|
102
|
+
result = @users.select do |record|
|
103
|
+
(record["hp"] > 100) & (record["hp"] <= 200)
|
104
|
+
end
|
105
|
+
assert_equal(["gunyara-kun", "yu"],
|
106
|
+
result.collect {|record| record.key.key})
|
107
|
+
end
|
108
|
+
|
109
|
+
def test_match
|
110
|
+
result = @users.select do |record|
|
111
|
+
record["name"] =~ "ro"
|
112
|
+
end
|
113
|
+
assert_equal(["morita", "yu"],
|
114
|
+
result.collect {|record| record.key.key})
|
115
|
+
end
|
116
|
+
|
117
|
+
def test_query_string
|
118
|
+
result = @users.select("name:@ro")
|
119
|
+
assert_equal(["morita", "yu"],
|
120
|
+
result.collect {|record| record.key.key})
|
121
|
+
end
|
122
|
+
|
123
|
+
def test_record
|
124
|
+
result = @bookmarks.select do |record|
|
125
|
+
record["user"] == @morita
|
126
|
+
end
|
127
|
+
assert_equal(["http://groonga.org/", "http://ruby-lang.org/"],
|
128
|
+
result.collect {|record| record.key["uri"]})
|
129
|
+
end
|
130
|
+
|
131
|
+
def test_record_id
|
132
|
+
result = @bookmarks.select do |record|
|
133
|
+
record["user"] == @morita.id
|
134
|
+
end
|
135
|
+
assert_equal(["http://groonga.org/", "http://ruby-lang.org/"],
|
136
|
+
result.collect {|record| record.key["uri"]})
|
137
|
+
end
|
138
|
+
|
139
|
+
def test_nested_column
|
140
|
+
result = @bookmarks.select do |record|
|
141
|
+
record[".user.name"] == @morita["name"]
|
142
|
+
end
|
143
|
+
assert_equal(["http://groonga.org/", "http://ruby-lang.org/"],
|
144
|
+
result.collect {|record| record.key["uri"]})
|
145
|
+
end
|
146
|
+
|
147
|
+
def test_nil_match
|
148
|
+
@users.select do |record|
|
149
|
+
exception = ArgumentError.new("match word should not be nil: Users.name")
|
150
|
+
assert_raise(exception) do
|
151
|
+
record["name"] =~ nil
|
152
|
+
end
|
153
|
+
record["name"] == "dummy"
|
154
|
+
end
|
155
|
+
end
|
156
|
+
end
|