Skip to content

Commit 13299bc

Browse files
committed
GH-50455: [Ruby] Add ArrowFormat::TimeType#==
Signed-off-by: Aaditya Srinivasan <aadityasri03@gmail.com>
1 parent 97b8678 commit 13299bc

3 files changed

Lines changed: 66 additions & 0 deletions

File tree

ruby/red-arrow-format/lib/arrow-format/type.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,12 @@ def initialize(bit_width, unit)
463463
@unit = unit
464464
end
465465

466+
def ==(other)
467+
other.is_a?(self.class) and
468+
@bit_width == other.bit_width and
469+
@unit == other.unit
470+
end
471+
466472
def to_s
467473
"#{super}(#{unit})"
468474
end
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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 TestTimeType < Test::Unit::TestCase
19+
sub_test_case("Time32Type#==") do
20+
def test_equal
21+
assert_equal(ArrowFormat::Time32Type.new(:second),
22+
ArrowFormat::Time32Type.new(:second))
23+
end
24+
25+
def test_not_equal
26+
assert_not_equal(ArrowFormat::Time32Type.new(:second),
27+
ArrowFormat::Time32Type.new(:millisecond))
28+
end
29+
end
30+
end
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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 TestTime64Type < Test::Unit::TestCase
19+
sub_test_case("#==") do
20+
def test_equal
21+
assert_equal(ArrowFormat::Time64Type.new(:microsecond),
22+
ArrowFormat::Time64Type.new(:microsecond))
23+
end
24+
25+
def test_not_equal
26+
assert_not_equal(ArrowFormat::Time64Type.new(:microsecond),
27+
ArrowFormat::Time64Type.new(:nanosecond))
28+
end
29+
end
30+
end

0 commit comments

Comments
 (0)