pitrou commented on a change in pull request #11694:
URL: https://github.com/apache/arrow/pull/11694#discussion_r756876211
##########
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:
Or you could rely on the existing `carr.Value` method
--
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]