|
| 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 TestTime64Array < Test::Unit::TestCase |
| 19 | + def setup |
| 20 | + @time_00_00_10_000_000 = 10 * 1_000_000 |
| 21 | + @time_00_01_10_000_000 = (60 + 10) * 1_000_000 |
| 22 | + end |
| 23 | + |
| 24 | + sub_test_case("#initialize") do |
| 25 | + def test_no_null |
| 26 | + values = [@time_00_00_10_000_000, @time_00_01_10_000_000] |
| 27 | + assert_equal(values, |
| 28 | + ArrowFormat::Time64Array.new(:microsecond, values).to_a) |
| 29 | + end |
| 30 | + |
| 31 | + def test_mixed |
| 32 | + values = [@time_00_00_10_000_000, nil, @time_00_01_10_000_000] |
| 33 | + assert_equal(values, |
| 34 | + ArrowFormat::Time64Array.new(:microsecond, values).to_a) |
| 35 | + end |
| 36 | + end |
| 37 | + |
| 38 | + sub_test_case("#==") do |
| 39 | + def test_no_slice |
| 40 | + values = [@time_00_00_10_000_000, nil, @time_00_01_10_000_000] |
| 41 | + array1 = ArrowFormat::Time64Array.new(:microsecond, values) |
| 42 | + array2 = ArrowFormat::Time64Array.new(:microsecond, values) |
| 43 | + assert_equal(array1, array2) |
| 44 | + end |
| 45 | + |
| 46 | + def test_sliced |
| 47 | + values = [@time_00_00_10_000_000, nil, @time_00_01_10_000_000] |
| 48 | + array1 = ArrowFormat::Time64Array.new(:microsecond, values) |
| 49 | + array2 = ArrowFormat::Time64Array.new(:microsecond, [0, *values, 0]) |
| 50 | + assert_equal(array1, array2.slice(1, 3)) |
| 51 | + end |
| 52 | + |
| 53 | + def test_sliced_different_content |
| 54 | + values = [@time_00_00_10_000_000, nil, @time_00_01_10_000_000] |
| 55 | + array1 = ArrowFormat::Time64Array.new(:microsecond, values) |
| 56 | + array2 = ArrowFormat::Time64Array.new(:microsecond, [0, 0, *values, 0]) |
| 57 | + assert_not_equal(array1, array2.slice(1, 3)) |
| 58 | + end |
| 59 | + end |
| 60 | +end |
0 commit comments