| 30 | namespace parquet::geospatial { |
| 31 | |
| 32 | TEST(TestGeoStatistics, TestDefaults) { |
| 33 | GeoStatistics stats; |
| 34 | EXPECT_TRUE(stats.geometry_types().has_value()); |
| 35 | EXPECT_EQ(stats.geometry_types().value().size(), 0); |
| 36 | EXPECT_TRUE(stats.is_valid()); |
| 37 | EXPECT_THAT(stats.dimension_empty(), ::testing::ElementsAre(true, true, true, true)); |
| 38 | EXPECT_THAT(stats.dimension_valid(), ::testing::ElementsAre(true, true, true, true)); |
| 39 | for (int i = 0; i < kMaxDimensions; i++) { |
| 40 | EXPECT_EQ(stats.lower_bound()[i], kInf); |
| 41 | EXPECT_EQ(stats.upper_bound()[i], -kInf); |
| 42 | } |
| 43 | |
| 44 | EXPECT_TRUE(stats.Equals(GeoStatistics())); |
| 45 | EXPECT_EQ(stats.ToString(), |
| 46 | "<GeoStatistics> x: empty y: empty z: empty m: empty " |
| 47 | "geometry_types: []"); |
| 48 | |
| 49 | // Merging empty with empty should equal empty |
| 50 | stats.Merge(GeoStatistics()); |
| 51 | EXPECT_TRUE(stats.Equals(GeoStatistics())); |
| 52 | |
| 53 | // There's no way to encode empty ranges in Thrift, so we pretend that we |
| 54 | // didn't calculate them. |
| 55 | auto encoded = stats.Encode(); |
| 56 | EXPECT_FALSE(encoded->xy_bounds_present); |
| 57 | EXPECT_FALSE(encoded->z_bounds_present); |
| 58 | EXPECT_FALSE(encoded->m_bounds_present); |
| 59 | EXPECT_FALSE(encoded->geospatial_types_present()); |
| 60 | |
| 61 | // When imported, the statistics marked with everything uncalculated should |
| 62 | // be "valid" but should have individual components marked as invalid. |
| 63 | GeoStatistics valid_but_uncalculated; |
| 64 | valid_but_uncalculated.Decode(*encoded); |
| 65 | |
| 66 | EXPECT_TRUE(valid_but_uncalculated.is_valid()); |
| 67 | EXPECT_THAT(valid_but_uncalculated.dimension_valid(), |
| 68 | ::testing::ElementsAre(false, false, false, false)); |
| 69 | EXPECT_EQ(valid_but_uncalculated.geometry_types(), std::nullopt); |
| 70 | } |
| 71 | |
| 72 | TEST(TestGeoStatistics, TestImportEncodedWithNaN) { |
| 73 | double nan_dbl = std::numeric_limits<double>::quiet_NaN(); |
nothing calls this directly
no test coverage detected