]>
Commit | Line | Data |
---|---|---|
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 | ||
18 | class FieldTest < Test::Unit::TestCase | |
19 | sub_test_case(".new") do | |
20 | test("String, Arrow::DataType") do | |
21 | assert_equal("visible: bool", | |
22 | Arrow::Field.new("visible", Arrow::BooleanDataType.new).to_s) | |
23 | end | |
24 | ||
25 | test("Symbol, Arrow::DataType") do | |
26 | assert_equal("visible: bool", | |
27 | Arrow::Field.new(:visible, Arrow::BooleanDataType.new).to_s) | |
28 | end | |
29 | ||
30 | test("String, Symbol") do | |
31 | assert_equal("visible: bool", | |
32 | Arrow::Field.new(:visible, :boolean).to_s) | |
33 | end | |
34 | ||
35 | test("String, Hash") do | |
36 | assert_equal("visible: bool", | |
37 | Arrow::Field.new(:visible, type: :boolean).to_s) | |
38 | end | |
39 | ||
40 | test("description: String") do | |
41 | assert_equal("visible: bool", | |
42 | Arrow::Field.new(name: "visible", | |
43 | data_type: :boolean).to_s) | |
44 | end | |
45 | ||
46 | test("description: Symbol") do | |
47 | assert_equal("visible: bool", | |
48 | Arrow::Field.new(name: :visible, | |
49 | data_type: :boolean).to_s) | |
50 | end | |
51 | ||
52 | test("description: shortcut") do | |
53 | assert_equal("visible: bool", | |
54 | Arrow::Field.new(name: :visible, | |
55 | type: :boolean).to_s) | |
56 | end | |
57 | ||
58 | test("Hash: shortcut: additional") do | |
59 | description = { | |
60 | name: :tags, | |
61 | type: :list, | |
62 | field: { | |
63 | name: "tag", | |
64 | type: :string, | |
65 | }, | |
66 | } | |
67 | assert_equal("tags: list<tag: string>", | |
68 | Arrow::Field.new(description).to_s) | |
69 | end | |
70 | end | |
71 | ||
72 | sub_test_case("instance methods") do | |
73 | def setup | |
74 | @field = Arrow::Field.new("count", :uint32) | |
75 | end | |
76 | ||
77 | sub_test_case("#==") do | |
78 | test("Arrow::Field") do | |
79 | assert do | |
80 | @field == @field | |
81 | end | |
82 | end | |
83 | ||
84 | test("not Arrow::Field") do | |
85 | assert do | |
86 | not (@field == 29) | |
87 | end | |
88 | end | |
89 | end | |
90 | end | |
91 | end |