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