andishgar commented on code in PR #46422:
URL: https://github.com/apache/arrow/pull/46422#discussion_r2123930217


##########
cpp/src/arrow/array/statistics_test.cc:
##########
@@ -96,6 +99,69 @@ TEST(ArrayStatisticsTest, TestEquality) {
   ASSERT_NE(statistics1, statistics2);
   statistics2.is_max_exact = true;
   ASSERT_EQ(statistics1, statistics2);
+
+  // Test different ArrayStatistics::ValueType
+  statistics1.max = static_cast<uint64_t>(29);
+  statistics1.max = static_cast<int64_t>(29);
+  ASSERT_NE(statistics1, statistics2);
+}
+class TestEqualityDoubleValue : public ::testing::Test {
+ protected:
+  ArrayStatistics statistics1_;
+  ArrayStatistics statistics2_;
+  EqualOptions options_ = EqualOptions::Defaults();
+};
+
+TEST_F(TestEqualityDoubleValue, ExactValue) {
+  ASSERT_EQ(statistics1_, statistics2_);
+  statistics2_.min = 29.0;
+  ASSERT_NE(statistics1_, statistics2_);
+  statistics1_.min = 29.0;
+  ASSERT_EQ(statistics1_, statistics2_);
+  statistics2_.min = 30.0;
+  ASSERT_NE(statistics1_, statistics2_);
+}
+
+TEST_F(TestEqualityDoubleValue, SignedZero) {
+  statistics1_.min = +0.0;
+  statistics2_.min = -0.0;
+  ASSERT_TRUE(statistics1_.Equals(statistics2_, 
options_.signed_zeros_equal(true)));
+  ASSERT_FALSE(statistics1_.Equals(statistics2_, 
options_.signed_zeros_equal(false)));
+}
+
+TEST_F(TestEqualityDoubleValue, Infinity) {
+  auto infinity = std::numeric_limits<double>::infinity();
+  statistics1_.min = infinity;
+  statistics2_.min = infinity;
+  ASSERT_TRUE(statistics1_.Equals(statistics2_, 
options_.signed_zeros_equal(true)));
+  ASSERT_TRUE(statistics1_.Equals(statistics2_, 
options_.signed_zeros_equal(false)));
+  statistics1_.min = -infinity;
+  ASSERT_FALSE(statistics1_.Equals(statistics2_, 
options_.signed_zeros_equal(true)));
+  ASSERT_FALSE(statistics1_.Equals(statistics2_, 
options_.signed_zeros_equal(false)));
+  statistics1_.min = 0.0;
+  ASSERT_FALSE(statistics1_.Equals(statistics2_, 
options_.signed_zeros_equal(true)));
+  ASSERT_FALSE(statistics1_.Equals(statistics2_, 
options_.signed_zeros_equal(false)));

Review Comment:
   Since infinity is a valid value in IEEE 754 double-precision, if both values 
are equal and infinite, the following 
[lines](https://github.com/apache/arrow/blob/94e3b3e98fe75a7498f2ee6edaeb006146d5cbe3/cpp/src/arrow/compare.cc#L85-L87)
 are executed. I want to test that signed_zero has no effect in this case. 
However, I forgot to include a NaN options as well, which would have triggered 
execution of the following 
[lines](https://github.com/apache/arrow/blob/94e3b3e98fe75a7498f2ee6edaeb006146d5cbe3/cpp/src/arrow/compare.cc#L88-L90).
 (I’m aware that the purpose of the dispatcher here is to generate only the 
relevant code paths at compile time, based on `arrow::EqualOptions`.)



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

Reply via email to