kou commented on code in PR #34970: URL: https://github.com/apache/arrow/pull/34970#discussion_r1161178303
########## cpp/src/arrow/record_batch_test.cc: ########## @@ -81,6 +82,40 @@ TEST_F(TestRecordBatch, Equals) { ASSERT_FALSE(b1->Equals(*b2, /*check_metadata=*/true)); } +TEST_F(TestRecordBatch, EqualsOptions) { + int length = 2; + auto f = field("f", float32()); + + auto metadata = key_value_metadata({"foo"}, {"bar"}); + + std::vector<std::shared_ptr<Field>> fields = {f}; + auto schema = ::arrow::schema(fields); + { + std::shared_ptr<Array> array1, array2; + ArrayFromVector<FloatType>(float32(), {true, true}, {0.5, NAN}, &array1); + ArrayFromVector<FloatType>(float32(), {true, true}, {0.5, NAN}, &array2); + auto b1 = RecordBatch::Make(schema, length, {array1}); + auto b2 = RecordBatch::Make(schema, length, {array2}); + + EXPECT_FALSE(b1->Equals(*b2, false, EqualOptions::Defaults().nans_equal(false))); + EXPECT_TRUE(b1->Equals(*b2, false, EqualOptions::Defaults().nans_equal(true))); + } + { + std::shared_ptr<Array> array1, array2; + ArrayFromVector<FloatType>(float32(), {true, true}, {0.5, NAN}, &array1); + ArrayFromVector<FloatType>(float32(), {true, true}, {0.501, NAN}, &array2); + + auto b1 = RecordBatch::Make(schema, length, {array1}); + auto b2 = RecordBatch::Make(schema, length, {array2}); + + EXPECT_FALSE(b1->ApproxEquals(*b2, EqualOptions::Defaults().nans_equal(false))); + EXPECT_FALSE(b1->ApproxEquals(*b2, EqualOptions::Defaults().nans_equal(true))); + + EXPECT_TRUE( + b1->ApproxEquals(*b2, EqualOptions::Defaults().nans_equal(true).atol(0.1))); + } Review Comment: Could you extract this to a separated test? -- 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: github-unsubscr...@arrow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org