9prady9 commented on a change in pull request #11694:
URL: https://github.com/apache/arrow/pull/11694#discussion_r756873581



##########
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:
       Exactly my thoughts, hence I tried to use hard coded array as input 
instead of random number generator, in which case I have to fetch the values 
from `Array` which indirectly use same routines inside arrow.
   
   Do you mean copy the `int8_t*` buffer and reinterpret it in the test 
accordingly ?




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