]> git.proxmox.com Git - ceph.git/blame - ceph/src/arrow/ruby/red-arrow/test/test-string-dictionary-array-builder.rb
import quincy 17.2.0
[ceph.git] / ceph / src / arrow / ruby / red-arrow / test / test-string-dictionary-array-builder.rb
CommitLineData
1d09f67e
TL
1# Licensed to the Apache Software Foundation (ASF) under one
2# or more contributor license agreements. See the NOTICE file
3# distributed with this work for additional information
4# regarding copyright ownership. The ASF licenses this file
5# to you under the Apache License, Version 2.0 (the
6# "License"); you may not use this file except in compliance
7# with the License. You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing,
12# software distributed under the License is distributed on an
13# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14# KIND, either express or implied. See the License for the
15# specific language governing permissions and limitations
16# under the License.
17
18class StringDictionaryArrayBuilderTest < Test::Unit::TestCase
19 def setup
20 @builder = Arrow::StringDictionaryArrayBuilder.new
21 end
22
23 sub_test_case("#append_values") do
24 test("[nil]") do
25 @builder.append_values([nil])
26 array = @builder.finish
27 assert_equal([
28 [],
29 [nil],
30 ],
31 [
32 array.dictionary.to_a,
33 array.indices.to_a,
34 ])
35 end
36
37 test("[String]") do
38 @builder.append_values(["hello"])
39 array = @builder.finish
40 assert_equal([
41 ["hello"],
42 [0],
43 ],
44 [
45 array.dictionary.to_a,
46 array.indices.to_a,
47 ])
48 end
49
50 test("[Symbol]") do
51 @builder.append_values([:hello])
52 array = @builder.finish
53 assert_equal([
54 ["hello"],
55 [0],
56 ],
57 [
58 array.dictionary.to_a,
59 array.indices.to_a,
60 ])
61 end
62
63 test("[nil, String, Symbol]") do
64 @builder.append_values([
65 nil,
66 "Hello",
67 :world,
68 "world",
69 ])
70 array = @builder.finish
71 assert_equal([
72 ["Hello", "world"],
73 [nil, 0, 1, 1],
74 ],
75 [
76 array.dictionary.to_a,
77 array.indices.to_a,
78 ])
79 end
80
81 test("is_valids") do
82 @builder.append_values([
83 "Hello",
84 :world,
85 :goodbye,
86 ],
87 [
88 true,
89 false,
90 true,
91 ])
92 array = @builder.finish
93 assert_equal([
94 ["Hello", "goodbye"],
95 [0, nil, 1],
96 ],
97 [
98 array.dictionary.to_a,
99 array.indices.to_a,
100 ])
101 end
102 end
103end