MCPcopy Create free account
hub / github.com/apache/arrow / StructArrayTest

Class StructArrayTest

ruby/red-arrow/test/test-struct-array.rb:18–94  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16# under the License.
17
18class StructArrayTest < Test::Unit::TestCase
19 sub_test_case(".new") do
20 test("build") do
21 data_type = Arrow::StructDataType.new(visible: :boolean,
22 count: :uint64)
23 values = [
24 [true, 1],
25 nil,
26 [false, 2],
27 ]
28 array = Arrow::StructArray.new(data_type, values)
29 assert_equal([
30 [true, false, false],
31 [1, 0, 2],
32 ],
33 [
34 array.find_field(0).to_a,
35 array.find_field(1).to_a,
36 ])
37 end
38 end
39
40 sub_test_case("instance methods") do
41 def setup
42 @data_type = Arrow::StructDataType.new(visible: {type: :boolean},
43 count: {type: :uint64})
44 @values = [
45 [true, 1],
46 [false, 2],
47 ]
48 @array = Arrow::StructArray.new(@data_type, @values)
49 end
50
51 test("#[]") do
52 assert_equal([
53 {"visible" => true, "count" => 1},
54 {"visible" => false, "count" => 2},
55 ],
56 @array.to_a)
57 end
58
59 test("#get_value") do
60 assert_equal([
61 {"visible" => true, "count" => 1},
62 {"visible" => false, "count" => 2},
63 ],
64 [
65 @array.get_value(0),
66 @array.get_value(1),
67 ])
68 end
69
70 sub_test_case("#find_field") do
71 test("Integer") do
72 assert_equal([
73 [true, false],
74 [1, 2],
75 ],

Callers

nothing calls this directly

Calls 5

testFunction · 0.85
newMethod · 0.45
to_aMethod · 0.45
find_fieldMethod · 0.45
get_valueMethod · 0.45

Tested by

no test coverage detected