]> git.proxmox.com Git - ceph.git/blob - ceph/src/arrow/ruby/red-arrow/test/test-column.rb
import quincy 17.2.0
[ceph.git] / ceph / src / arrow / ruby / red-arrow / test / test-column.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 ColumnTest < Test::Unit::TestCase
19 def setup
20 table = Arrow::Table.new("visible" => [true, nil, false])
21 @column = table.visible
22 end
23
24 test("#name") do
25 assert_equal("visible", @column.name)
26 end
27
28 test("#data_type") do
29 assert_equal(Arrow::BooleanDataType.new, @column.data_type)
30 end
31
32 test("#null?") do
33 assert do
34 @column.null?(1)
35 end
36 end
37
38 test("#valid?") do
39 assert do
40 @column.valid?(0)
41 end
42 end
43
44 test("#each") do
45 assert_equal([true, nil, false], @column.each.to_a)
46 end
47
48 test("#reverse_each") do
49 assert_equal([false, nil, true], @column.reverse_each.to_a)
50 end
51
52 test("#n_rows") do
53 assert_equal(3, @column.n_rows)
54 end
55
56 test("#n_nulls") do
57 assert_equal(1, @column.n_nulls)
58 end
59
60 sub_test_case("#==") do
61 test("same value") do
62 table1 = Arrow::Table.new("visible" => [true, false])
63 table2 = Arrow::Table.new("visible" => [true, false])
64 assert do
65 table1.visible == table2.visible
66 end
67 end
68
69 test("different name") do
70 table1 = Arrow::Table.new("visible" => [true, false])
71 table2 = Arrow::Table.new("invisible" => [true, false])
72 assert do
73 not table1.visible == table2.invisible
74 end
75 end
76
77 test("different value") do
78 table1 = Arrow::Table.new("visible" => [true, false])
79 table2 = Arrow::Table.new("visible" => [true, true])
80 assert do
81 not table1.visible == table2.visible
82 end
83 end
84
85 test("not Arrow::Column") do
86 table = Arrow::Table.new("visible" => [true, false])
87 assert do
88 not table.visible == 29
89 end
90 end
91 end
92 end