Uploaded image for project: 'Apache Arrow'
  1. Apache Arrow
  2. ARROW-8467

[C++] Test cases using ArrayFromJSON assume only a little-endian platform

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.0.0
    • Component/s: C++

      Description

      Test cases using ArrayFromJSON assumes little endian platform

      The following test cases seem to assume little-endian platform.
      TEST_F(TestChunkedArray, View) at https://github.com/apache/arrow/blob/master/cpp/src/arrow/table_test.cc#L175
      TEST(TestArrayView, PrimitiveAsFixedSizeBinary) at https://github.com/apache/arrow/blob/master/cpp/src/arrow/array_view_test.cc#L105
      TEST(TestArrayView, StructAsStructSimple) at https://github.com/apache/arrow/blob/master/cpp/src/arrow/array_view_test.cc#L126
      TEST(TestArrayView, ExtensionType) at https://github.com/apache/arrow/blob/master/cpp/src/arrow/array_view_test.cc

      One of examples is PrimitiveAsFixedSizeBinary.

      TEST(TestArrayView, PrimitiveAsFixedSizeBinary) {
        auto arr = ArrayFromJSON(int32(), "[2020568934, 2054316386, null]");
        auto expected = ArrayFromJSON(fixed_size_binary(4), R"(["foox", "barz", null])");
        CheckView(arr, expected);
        CheckView(expected, arr);
      }
      

      The expected strings are represented in binary as follows:

      "foox" = [0x66 0x6f 0x6f 0x78]
      "barz" = [0x62 0x61 0x72 0x7a]
      

      This test gives a value as raw int32. The current values assume only a little-endian platform as follows to generate the expected binary sequence.

      2020568934 = 0x786f6f66
      2054316386 = 0x7a726162
      

        Attachments

          Activity

            People

            • Assignee:
              kiszk Kazuaki Ishizaki
              Reporter:
              kiszk Kazuaki Ishizaki
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 1h 20m
                1h 20m