Repository: apache/arrow
File: ruby/red-arrow/test/test-array-builder.rb (Ruby)

Code before:

      test("list<boolean>s") do
        assert_build(Arrow::ArrayBuilder,
                     [
                       [nil, true, false],
                       nil,
                       [false],
                     ])
      end

      test("list<string>s") do
        assert_build(Arrow::ArrayBuilder,
                     [
                       ["Hello", "World"],
                       ["Apache Arrow"],
                     ])
      end

      sub_test_case("nested integer list") do
        test("list<uint8>s") do
          values = [
            [0, 1, 2],
            [3, 4],
          ]
          array = Arrow::Array.new(values)
          data_type = Arrow::ListDataType.new(Arrow::UInt8DataType.new)
          assert_equal({
                         data_type: data_type,
                         values: [
                           [0, 1, 2],
                           [3, 4],
                         ],
                       },
                       {
                         data_type: array.value_data_type,
                         values: array.to_a,
                       })
        end

        test("list<int8>s") do
          values = [
            [0, -1, 2],
            [3, 4],
          ]
          array = Arrow::Array.new(values)
          data_type = Arrow::ListDataType.new(Arrow::Int8DataType.new)
          assert_equal({
                         data_type: data_type,
                         values: [
                           [0, -1, 2],
                           [3, 4],

Review comment (refactor):
We can simplify this:

```suggestion
          data_type = Arrow::ListDataType.new(:uint8)
```

Code after:

      test("list<boolean>s") do
        assert_build(Arrow::ArrayBuilder,
                     [
                       [nil, true, false],
                       nil,
                       [false],
                     ])
      end

      test("list<string>s") do
        assert_build(Arrow::ArrayBuilder,
                     [
                       ["Hello", "World"],
                       ["Apache Arrow"],
                     ])
      end

      sub_test_case("nested integer list") do
        test("list<uint8>s") do
          values = [
            [0, 1, 2],
            [3, 4],
          ]
          array = Arrow::Array.new(values)
          data_type = Arrow::ListDataType.new(:uint8)
          assert_equal({
                         data_type: data_type,
                         values: [
                           [0, 1, 2],
                           [3, 4],
                         ],
                       },
                       {
                         data_type: array.value_data_type,
                         values: array.to_a,
                       })
        end

        test("list<int8>s boundary") do
          values = [
            [0, GLib::MININT8],
            [GLib::MAXINT8],
          ]
          array = Arrow::Array.new(values)
          data_type = Arrow::ListDataType.new(:int8)

          assert_equal({
                         data_type: data_type,
                         values: [
                           [0, GLib::MININT8],