]> git.proxmox.com Git - ceph.git/blob - ceph/src/arrow/c_glib/test/test-dense-union-data-type.rb
import quincy 17.2.0
[ceph.git] / ceph / src / arrow / c_glib / test / test-dense-union-data-type.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
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
18 class TestDenseUnionDataType < Test::Unit::TestCase
19 def setup
20 @number_field_data_type = Arrow::Int32DataType.new
21 @text_field_data_type = Arrow::StringDataType.new
22 @field_data_types = [
23 @number_field_data_type,
24 @text_field_data_type,
25 ]
26 @number_field = Arrow::Field.new("number", @number_field_data_type)
27 @text_field = Arrow::Field.new("text", @text_field_data_type)
28 @fields = [
29 @number_field,
30 @text_field,
31 ]
32 @data_type = Arrow::DenseUnionDataType.new(@fields, [2, 9])
33 end
34
35 def test_type
36 assert_equal(Arrow::Type::DENSE_UNION, @data_type.id)
37 end
38
39 def test_name
40 assert_equal("dense_union", @data_type.name)
41 end
42
43 def test_to_s
44 assert_equal("dense_union<number: int32=2, text: string=9>",
45 @data_type.to_s)
46 end
47
48 def test_fields
49 assert_equal(@fields.zip(@field_data_types),
50 @data_type.fields.collect {|field| [field, field.data_type]})
51 end
52
53 def test_get_field
54 field = @data_type.get_field(0)
55 assert_equal([
56 @fields[0],
57 @field_data_types[0],
58 ],
59 [
60 field,
61 field.data_type,
62 ])
63 end
64 end