]>
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 Time64ArrayTest < Test::Unit::TestCase | |
19 | sub_test_case(".new") do | |
20 | sub_test_case("unit") do | |
21 | test("Arrow::TimeUnit") do | |
22 | values = [1000 * 10, nil] | |
23 | array = Arrow::Time64Array.new(Arrow::TimeUnit::NANO, values) | |
24 | assert_equal([ | |
25 | "time64[ns]", | |
26 | [ | |
27 | Arrow::Time.new(Arrow::TimeUnit::NANO, | |
28 | 1000 * 10), | |
29 | nil, | |
30 | ], | |
31 | ], | |
32 | [ | |
33 | array.value_data_type.to_s, | |
34 | array.to_a, | |
35 | ]) | |
36 | end | |
37 | ||
38 | test("Symbol") do | |
39 | values = [1000 * 10, nil] | |
40 | array = Arrow::Time64Array.new(:micro, values) | |
41 | assert_equal([ | |
42 | "time64[us]", | |
43 | [ | |
44 | Arrow::Time.new(Arrow::TimeUnit::MICRO, | |
45 | 1000 * 10), | |
46 | nil, | |
47 | ], | |
48 | ], | |
49 | [ | |
50 | array.value_data_type.to_s, | |
51 | array.to_a, | |
52 | ]) | |
53 | end | |
54 | end | |
55 | ||
56 | sub_test_case("values") do | |
57 | test("Arrow::Time") do | |
58 | data_type = Arrow::Time64DataType.new(:nano) | |
59 | values = [ | |
60 | Arrow::Time.new(Arrow::TimeUnit::NANO, | |
61 | 1000 * 10), | |
62 | nil, | |
63 | ] | |
64 | array = Arrow::Time64Array.new(data_type, values) | |
65 | assert_equal(values, array.to_a) | |
66 | end | |
67 | ||
68 | test("Integer") do | |
69 | data_type = Arrow::Time64DataType.new(:nano) | |
70 | values = [1000 * 10, nil] | |
71 | array = Arrow::Time64Array.new(data_type, values) | |
72 | assert_equal([ | |
73 | Arrow::Time.new(Arrow::TimeUnit::NANO, | |
74 | 1000 * 10), | |
75 | nil, | |
76 | ], | |
77 | array.to_a) | |
78 | end | |
79 | end | |
80 | end | |
81 | end |