]>
git.proxmox.com Git - ceph.git/blob - ceph/src/arrow/ruby/red-arrow/test/test-map-array-builder.rb
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
9 # http://www.apache.org/licenses/LICENSE-2.0
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
18 class MapArrayBuilderTest
< Test
::Unit::TestCase
20 key_type
= Arrow
::StringDataType.new
21 item_type
= Arrow
::Int16DataType.new
22 data_type
= Arrow
::MapDataType.new(key_type
, item_type
)
23 @builder = Arrow
::MapArrayBuilder.new(data_type
)
26 sub_test_case("#append_value") do
28 @builder.append_value(nil)
29 array
= @builder.finish
30 assert_equal([nil], array
.collect
{|value
| value
})
34 @builder.append_value({"a" => 0, "b" => 1})
35 @builder.append_value({"c" => 0, "d" => 1})
36 array
= @builder.finish
41 array
.collect
{|value
| value
})
45 @builder.append_value([["a", 0], ["b", 1]])
46 @builder.append_value([["c", 0], ["d", 1]])
47 array
= @builder.finish
52 array
.collect
{|value
| value
})
56 sub_test_case("#append_values") do
58 @builder.append_values([nil])
59 array
= @builder.finish
60 assert_equal([nil], array
.collect
{|value
| value
})
64 @builder.append_values([{"a" => 0, "b" => 1}, {"c" => 0, "d" => 1}])
65 array
= @builder.finish
70 array
.collect
{|value
| value
})
74 @builder.append_values([[["a", 0], ["b", 1]], [["c", 0], ["d", 1]]])
75 array
= @builder.finish
80 array
.collect
{|value
| value
})
83 test("[nil, Hash, #each]") do
84 @builder.append_values([nil, {"a" => 0, "b" => 1}, [["c", 0], ["d", 1]]])
85 array
= @builder.finish
91 array
.collect
{|value
| value
})
95 @builder.append_values([
101 array
= @builder.finish
103 {"a" => 0, "b" => 1},
107 array
.collect
{|value
| value
})