emecii commented on code in PR #51263: URL: https://github.com/apache/arrow/pull/51263#discussion_r3976636086
########## ruby/red-arrow-format/test/test-list-array.rb: ########## @@ -0,0 +1,56 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +class TestListArray < Test::Unit::TestCase + def setup + child = ArrowFormat::Field.new("item", ArrowFormat::Int32Type.singleton) + @type = ArrowFormat::ListType.new(child) + end + + sub_test_case("#initialize") do + def test_no_null + values = [[-1, 0], [], [1, 2, 3]] + array = ArrowFormat::ListArray.new(@type, values) + assert_same(@type, array.type) + assert_equal(values, array.to_a) + end + + def test_null_list + values = [[1, 2], nil, [], [3]] + array = ArrowFormat::ListArray.new(@type, values) + assert_equal([0, 2, 2, 2, 3], array.offsets) + assert_equal(1, array.n_nulls) Review Comment: Removed the parent null-count assertion in 665a620534cb38e75c9b4a3244db85e1b307e3d1. The value round-trip assertion remains; all four focused tests pass. ########## ruby/red-arrow-format/test/test-list-array.rb: ########## @@ -0,0 +1,56 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +class TestListArray < Test::Unit::TestCase + def setup + child = ArrowFormat::Field.new("item", ArrowFormat::Int32Type.singleton) + @type = ArrowFormat::ListType.new(child) + end + + sub_test_case("#initialize") do + def test_no_null + values = [[-1, 0], [], [1, 2, 3]] + array = ArrowFormat::ListArray.new(@type, values) + assert_same(@type, array.type) + assert_equal(values, array.to_a) + end + + def test_null_list + values = [[1, 2], nil, [], [3]] + array = ArrowFormat::ListArray.new(@type, values) + assert_equal([0, 2, 2, 2, 3], array.offsets) + assert_equal(1, array.n_nulls) + assert_equal([1, 2, 3], array.child.to_a) + assert_equal(values, array.to_a) + end + + def test_null_child + values = [[1, nil], [], [nil, 2]] + array = ArrowFormat::ListArray.new(@type, values) + assert_equal(2, array.child.n_nulls) Review Comment: Removed the child null-count assertion in 665a620534cb38e75c9b4a3244db85e1b307e3d1. The value round-trip assertion remains; all four focused tests pass. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
