kou commented on a change in pull request #12269:
URL: https://github.com/apache/arrow/pull/12269#discussion_r794988539



##########
File path: c_glib/test/test-month-day-nano-interval-array.rb
##########
@@ -0,0 +1,49 @@
+# 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 TestMonthDayNanoIntervalArray < Test::Unit::TestCase
+  include Helper::Buildable
+
+  def test_new
+    zero_month_day_nano = Arrow::MonthDayNano.new(0, 0, 0)
+    first_month_day_nano = Arrow::MonthDayNano.new(1, 10, 100)
+    second_month_day_nano = Arrow::MonthDayNano.new(3, 30, 100)
+    raw_data = [zero_month_day_nano, first_month_day_nano, 
second_month_day_nano]
+    array = build_month_day_nano_interval_array(raw_data)
+    assert_equal(array.get_value(1).month, first_month_day_nano.month)
+  end
+
+  def test_value
+    month_day_nano = Arrow::MonthDayNano.new(3, 30, 100)
+
+    builder = Arrow::MonthDayNanoIntervalArrayBuilder.new
+    builder.append_value(month_day_nano)
+    array = builder.finish
+    assert_equal(month_day_nano.day, array.get_value(0).day)

Review comment:
       ```suggestion
       assert_equal(month_day_nano, array.get_value(0))
   ```

##########
File path: c_glib/test/test-day-time-interval-array.rb
##########
@@ -0,0 +1,50 @@
+# 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 TestDayTimeIntervalArray < Test::Unit::TestCase
+  include Helper::Buildable
+  include Helper::Omittable
+
+  def test_new

Review comment:
       Is this redundant?

##########
File path: c_glib/test/test-month-day-nano-interval-array.rb
##########
@@ -0,0 +1,49 @@
+# 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 TestMonthDayNanoIntervalArray < Test::Unit::TestCase
+  include Helper::Buildable
+
+  def test_new
+    zero_month_day_nano = Arrow::MonthDayNano.new(0, 0, 0)
+    first_month_day_nano = Arrow::MonthDayNano.new(1, 10, 100)
+    second_month_day_nano = Arrow::MonthDayNano.new(3, 30, 100)
+    raw_data = [zero_month_day_nano, first_month_day_nano, 
second_month_day_nano]
+    array = build_month_day_nano_interval_array(raw_data)
+    assert_equal(array.get_value(1).month, first_month_day_nano.month)

Review comment:
       ```suggestion
       assert_equal(first_month_day_nano, array.get_value(1))
   ```

##########
File path: c_glib/test/test-month-interval-array.rb
##########
@@ -0,0 +1,65 @@
+# 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 TestMonthIntervalArray < Test::Unit::TestCase
+  include Helper::Buildable
+  include Helper::Omittable
+
+  def test_new
+    after_month = 1
+    raw_data = [0, after_month]
+    assert_equal(build_month_interval_array([*raw_data, nil]),
+                 Arrow::MonthIntervalArray.new(3,
+                                               
Arrow::Buffer.new(raw_data.pack("l*")),
+                                               
Arrow::Buffer.new([0b011].pack("C*")),
+                                               -1))
+  end
+
+  def test_buffer
+    before_month = 1
+    after_month = 12
+
+    builder = Arrow::MonthIntervalArrayBuilder.new
+    builder.append_value(0)
+    builder.append_value(before_month)
+    builder.append_value(after_month)
+    array = builder.finish
+    assert_equal([0, before_month, after_month].pack("l*"),

Review comment:
       ```suggestion
       builder.append_value(1)
       builder.append_value(12)
       array = builder.finish
       assert_equal([0, 1, 12].pack("l*"),
   ```

##########
File path: c_glib/test/test-month-interval-array.rb
##########
@@ -0,0 +1,65 @@
+# 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 TestMonthIntervalArray < Test::Unit::TestCase
+  include Helper::Buildable
+  include Helper::Omittable
+
+  def test_new
+    after_month = 1

Review comment:
       Did you copy `after_` prefix from other test such as `after_epoch` in 
`test-timestamp-array.rb`?
   The `after_` prefix means "a value after epoch".
   But `after_` prefix here is meaning because there is not a base value such 
as epoch.
   
   How about simply using `raw_data = [0, 1]` here? 

##########
File path: c_glib/test/test-month-interval-array.rb
##########
@@ -0,0 +1,65 @@
+# 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 TestMonthIntervalArray < Test::Unit::TestCase
+  include Helper::Buildable
+  include Helper::Omittable
+
+  def test_new
+    after_month = 1
+    raw_data = [0, after_month]
+    assert_equal(build_month_interval_array([*raw_data, nil]),
+                 Arrow::MonthIntervalArray.new(3,
+                                               
Arrow::Buffer.new(raw_data.pack("l*")),
+                                               
Arrow::Buffer.new([0b011].pack("C*")),
+                                               -1))
+  end
+
+  def test_buffer
+    before_month = 1
+    after_month = 12
+
+    builder = Arrow::MonthIntervalArrayBuilder.new
+    builder.append_value(0)
+    builder.append_value(before_month)
+    builder.append_value(after_month)
+    array = builder.finish
+    assert_equal([0, before_month, after_month].pack("l*"),
+                 array.buffer.data.to_s)
+  end
+
+  def test_value
+    after_month = 1
+
+    builder = Arrow::MonthIntervalArrayBuilder.new
+    builder.append_value(after_month)
+    array = builder.finish
+    assert_equal(after_month, array.get_value(0))
+  end
+
+  def test_values
+    before_month = 1
+    after_month = 12
+
+    builder = Arrow::MonthIntervalArrayBuilder.new
+    builder.append_value(0)
+    builder.append_value(before_month)
+    builder.append_value(after_month)
+    array = builder.finish
+    assert_equal([0, before_month, after_month], array.values)

Review comment:
       ```suggestion
       builder.append_value(1)
       builder.append_value(12)
       array = builder.finish
       assert_equal([0, 1, 12], array.values)
   ```

##########
File path: c_glib/test/test-day-millisecond.rb
##########
@@ -0,0 +1,64 @@
+# 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 TestDayMillisecond < Test::Unit::TestCase
+  include Helper::Omittable
+
+  def test_equal
+    day_millisecond = Arrow::DayMillisecond.new(3, 100)
+    other_day_millisecond1 = Arrow::DayMillisecond.new(3, 100)
+    other_day_millisecond2 = Arrow::DayMillisecond.new(3, 101)
+    assert_equal([
+                   true,
+                   false,
+                 ],
+                 [
+                   day_millisecond == other_day_millisecond1,
+                   day_millisecond == other_day_millisecond2,
+                 ])
+  end
+
+  def test_not_equal
+    day_millisecond = Arrow::DayMillisecond.new(3, 100)
+    other_day_millisecond1 = Arrow::DayMillisecond.new(3, 100)
+    other_day_millisecond2 = Arrow::DayMillisecond.new(3, 101)
+    assert_equal([
+                   false,
+                   true,
+                 ],
+                 [
+                   day_millisecond != other_day_millisecond1,
+                   day_millisecond != other_day_millisecond2,
+                 ])
+  end
+
+  def test_less_than
+    day_millisecond = Arrow::DayMillisecond.new(3, 100)
+    other_day_millisecond1 = Arrow::DayMillisecond.new(3, 100)
+    other_day_millisecond2 = Arrow::DayMillisecond.new(3, 101)
+    assert_equal([
+                   false,
+                   true,
+                   false
+                 ],
+                 [
+                   day_millisecond < other_day_millisecond1,
+                   day_millisecond < other_day_millisecond2,
+                   day_millisecond < day_millisecond,

Review comment:
       Is this redundant?

##########
File path: c_glib/test/test-month-day-nano-interval-array.rb
##########
@@ -0,0 +1,49 @@
+# 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 TestMonthDayNanoIntervalArray < Test::Unit::TestCase
+  include Helper::Buildable
+
+  def test_new

Review comment:
       It seems that this test is redundant.
   Do `test_value` and `test_values` cover this case?

##########
File path: c_glib/test/test-month-interval-array.rb
##########
@@ -0,0 +1,65 @@
+# 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 TestMonthIntervalArray < Test::Unit::TestCase
+  include Helper::Buildable
+  include Helper::Omittable
+
+  def test_new
+    after_month = 1
+    raw_data = [0, after_month]
+    assert_equal(build_month_interval_array([*raw_data, nil]),
+                 Arrow::MonthIntervalArray.new(3,
+                                               
Arrow::Buffer.new(raw_data.pack("l*")),
+                                               
Arrow::Buffer.new([0b011].pack("C*")),
+                                               -1))
+  end
+
+  def test_buffer
+    before_month = 1
+    after_month = 12
+
+    builder = Arrow::MonthIntervalArrayBuilder.new
+    builder.append_value(0)
+    builder.append_value(before_month)
+    builder.append_value(after_month)
+    array = builder.finish
+    assert_equal([0, before_month, after_month].pack("l*"),
+                 array.buffer.data.to_s)
+  end
+
+  def test_value
+    after_month = 1
+
+    builder = Arrow::MonthIntervalArrayBuilder.new
+    builder.append_value(after_month)
+    array = builder.finish
+    assert_equal(after_month, array.get_value(0))

Review comment:
       ```suggestion
       builder.append_value(1)
       array = builder.finish
       assert_equal(1, array.get_value(0))
   ```

##########
File path: c_glib/test/test-month-day-nano-interval-scalar.rb
##########
@@ -0,0 +1,47 @@
+# 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 TestMonthDayNanoIntervalScalar < Test::Unit::TestCase
+  def setup
+    @value = Arrow::MonthDayNano.new(3, 10, 100)
+    @scalar = Arrow::MonthDayNanoIntervalScalar.new(@value)
+  end
+
+  def test_data_type
+    assert_equal(Arrow::MonthDayNanoIntervalDataType.new,
+                 @scalar.data_type)
+  end
+
+  def test_valid?
+    assert do
+      @scalar.valid?
+    end
+  end
+
+  def test_equal
+    assert_equal(Arrow::MonthDayNanoIntervalScalar.new(@value),
+                 @scalar)
+  end
+
+  def test_to_s
+    assert_equal("3M10d100ns", @scalar.to_s)
+  end
+
+  def test_value
+    assert_equal(@value.month, @scalar.value.month)

Review comment:
       ```suggestion
       assert_equal(@value, @scalar.value)
   ```

##########
File path: c_glib/test/test-day-time-interval-scalar.rb
##########
@@ -0,0 +1,47 @@
+# 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 TestDayTimeIntervalScalar < Test::Unit::TestCase
+  def setup
+    @value = Arrow::DayMillisecond.new(3, 100)
+    @scalar = Arrow::DayTimeIntervalScalar.new(@value)
+  end
+
+  def test_data_type
+    assert_equal(Arrow::DayTimeIntervalDataType.new,
+                 @scalar.data_type)
+  end
+
+  def test_valid?
+    assert do
+      @scalar.valid?
+    end
+  end
+
+  def test_equal
+    assert_equal(Arrow::DayTimeIntervalScalar.new(@value),
+                 @scalar)
+  end
+
+  def test_to_s
+    assert_equal("3d100ms", @scalar.to_s)
+  end
+
+  def test_value
+    assert_equal(@value.day, @scalar.value.day)

Review comment:
       ```suggestion
       assert_equal(@value, @scalar.value)
   ```




-- 
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]


Reply via email to