pitrou commented on a change in pull request #11694:
URL: https://github.com/apache/arrow/pull/11694#discussion_r756883423



##########
File path: cpp/src/arrow/array/array_test.cc
##########
@@ -3348,4 +3358,38 @@ TEST(TestSwapEndianArrayData, InvalidLength) {
   }
 }
 
+template <typename T>
+class TestPrimitiveArray : public ::testing::Test {
+ public:
+  void SetUp() { pool_ = default_memory_pool(); }
+
+ protected:
+  MemoryPool* pool_;
+};
+
+TYPED_TEST_SUITE(TestPrimitiveArray, Primitives);
+
+TYPED_TEST(TestPrimitiveArray, IndexOperator) {
+  random::RandomArrayGenerator rng(0x76878);
+
+  auto input_array = rng.ArrayOf(TypeParam::type(), 6, 0.2);
+  auto con_array = checked_pointer_cast<typename 
TypeParam::ArrayType>(input_array);
+  const auto& carr = *con_array;
+
+  std::vector<util::optional<typename TypeParam::T>> values;
+  for (auto v : carr) {
+    values.push_back(v);
+  }
+
+  for (int64_t i = 0; i < carr.length(); ++i) {
+    auto res = carr[i];
+    if (res) {
+      ASSERT_EQ(values[i].value(), res.value());

Review comment:
       Ah, you're right. Well, let's not overdo it then. But perhaps you can 
add type-specific tests for the interval types (using e.g. `ArrayFromJSON` to 
build up the array)?




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