|
|
@@ -99,6 +99,9 @@ class ValueUtilTest : public ::testing::Test {
|
|
|
ComparisonResult expected_result) {
|
|
|
for (pb_size_t i = 0; i < left->values_count; ++i) {
|
|
|
for (pb_size_t j = 0; j < right->values_count; ++j) {
|
|
|
+ if (expected_result != Compare(left->values[i], right->values[j])) {
|
|
|
+ std::cout << "here" << std::endl;
|
|
|
+ }
|
|
|
EXPECT_EQ(expected_result, Compare(left->values[i], right->values[j]))
|
|
|
<< "Order check failed for '" << CanonicalId(left->values[i])
|
|
|
<< "' and '" << CanonicalId(right->values[j]) << "' (expected "
|
|
|
@@ -243,6 +246,8 @@ TEST_F(ValueUtilTest, Equality) {
|
|
|
Add(equals_group, Array("foo", "bar"), Array("foo", "bar"));
|
|
|
Add(equals_group, Array("foo", "bar", "baz"));
|
|
|
Add(equals_group, Array("foo"));
|
|
|
+ Add(equals_group, Map("__type__", "__vector__", "value", Array()),
|
|
|
+ DeepClone(MinVector()));
|
|
|
Add(equals_group, Map("bar", 1, "foo", 2), Map("bar", 1, "foo", 2));
|
|
|
Add(equals_group, Map("bar", 2, "foo", 1));
|
|
|
Add(equals_group, Map("bar", 1));
|
|
|
@@ -271,8 +276,7 @@ TEST_F(ValueUtilTest, StrictOrdering) {
|
|
|
Add(comparison_groups, true);
|
|
|
|
|
|
// numbers
|
|
|
- Add(comparison_groups,
|
|
|
- DeepClone(GetLowerBound(google_firestore_v1_Value_integer_value_tag)));
|
|
|
+ Add(comparison_groups, DeepClone(MinNumber()));
|
|
|
Add(comparison_groups, -1e20);
|
|
|
Add(comparison_groups, std::numeric_limits<int64_t>::min());
|
|
|
Add(comparison_groups, -0.1);
|
|
|
@@ -285,8 +289,7 @@ TEST_F(ValueUtilTest, StrictOrdering) {
|
|
|
Add(comparison_groups, 1e20);
|
|
|
|
|
|
// dates
|
|
|
- Add(comparison_groups,
|
|
|
- DeepClone(GetLowerBound(google_firestore_v1_Value_timestamp_value_tag)));
|
|
|
+ Add(comparison_groups, DeepClone(MinTimestamp()));
|
|
|
Add(comparison_groups, kTimestamp1);
|
|
|
Add(comparison_groups, kTimestamp2);
|
|
|
|
|
|
@@ -316,8 +319,7 @@ TEST_F(ValueUtilTest, StrictOrdering) {
|
|
|
Add(comparison_groups, BlobValue(255));
|
|
|
|
|
|
// resource names
|
|
|
- Add(comparison_groups,
|
|
|
- DeepClone(GetLowerBound(google_firestore_v1_Value_reference_value_tag)));
|
|
|
+ Add(comparison_groups, DeepClone(MinReference()));
|
|
|
Add(comparison_groups, RefValue(DbId("p1/d1"), Key("c1/doc1")));
|
|
|
Add(comparison_groups, RefValue(DbId("p1/d1"), Key("c1/doc2")));
|
|
|
Add(comparison_groups, RefValue(DbId("p1/d1"), Key("c10/doc1")));
|
|
|
@@ -340,23 +342,28 @@ TEST_F(ValueUtilTest, StrictOrdering) {
|
|
|
Add(comparison_groups, GeoPoint(90, 180));
|
|
|
|
|
|
// arrays
|
|
|
- Add(comparison_groups,
|
|
|
- DeepClone(GetLowerBound(google_firestore_v1_Value_array_value_tag)));
|
|
|
+ Add(comparison_groups, DeepClone(MinArray()));
|
|
|
Add(comparison_groups, Array("bar"));
|
|
|
Add(comparison_groups, Array("foo", 1));
|
|
|
Add(comparison_groups, Array("foo", 2));
|
|
|
Add(comparison_groups, Array("foo", "0"));
|
|
|
|
|
|
- // objects
|
|
|
+ // vectors
|
|
|
+ Add(comparison_groups, DeepClone(MinVector()));
|
|
|
+ Add(comparison_groups, Map("__type__", "__vector__", "value", Array(100)));
|
|
|
+ Add(comparison_groups,
|
|
|
+ Map("__type__", "__vector__", "value", Array(1.0, 2.0, 3.0)));
|
|
|
Add(comparison_groups,
|
|
|
- DeepClone(GetLowerBound(google_firestore_v1_Value_map_value_tag)));
|
|
|
+ Map("__type__", "__vector__", "value", Array(1.0, 3.0, 2.0)));
|
|
|
+
|
|
|
+ // objects
|
|
|
+ Add(comparison_groups, DeepClone(MinMap()));
|
|
|
Add(comparison_groups, Map("bar", 0));
|
|
|
Add(comparison_groups, Map("bar", 0, "foo", 1));
|
|
|
Add(comparison_groups, Map("foo", 1));
|
|
|
Add(comparison_groups, Map("foo", 2));
|
|
|
Add(comparison_groups, Map("foo", "0"));
|
|
|
- Add(comparison_groups,
|
|
|
- DeepClone(GetUpperBound(google_firestore_v1_Value_map_value_tag)));
|
|
|
+ Add(comparison_groups, DeepClone(MaxValue()));
|
|
|
|
|
|
for (size_t i = 0; i < comparison_groups.size(); ++i) {
|
|
|
for (size_t j = i; j < comparison_groups.size(); ++j) {
|
|
|
@@ -377,25 +384,19 @@ TEST_F(ValueUtilTest, RelaxedOrdering) {
|
|
|
std::vector<Message<google_firestore_v1_ArrayValue>> comparison_groups;
|
|
|
|
|
|
// null first
|
|
|
- Add(comparison_groups,
|
|
|
- DeepClone(GetLowerBound(google_firestore_v1_Value_null_value_tag)));
|
|
|
+ Add(comparison_groups, DeepClone(NullValue()));
|
|
|
Add(comparison_groups, nullptr);
|
|
|
- Add(comparison_groups,
|
|
|
- DeepClone(GetUpperBound(google_firestore_v1_Value_null_value_tag)));
|
|
|
+ Add(comparison_groups, DeepClone(MinBoolean()));
|
|
|
|
|
|
// booleans
|
|
|
- Add(comparison_groups,
|
|
|
- DeepClone(GetLowerBound(google_firestore_v1_Value_boolean_value_tag)));
|
|
|
+ Add(comparison_groups, DeepClone(MinBoolean()));
|
|
|
Add(comparison_groups, false);
|
|
|
Add(comparison_groups, true);
|
|
|
- Add(comparison_groups,
|
|
|
- DeepClone(GetUpperBound(google_firestore_v1_Value_boolean_value_tag)));
|
|
|
+ Add(comparison_groups, DeepClone(MinNumber()));
|
|
|
|
|
|
// numbers
|
|
|
- Add(comparison_groups,
|
|
|
- DeepClone(GetLowerBound(google_firestore_v1_Value_integer_value_tag)));
|
|
|
- Add(comparison_groups,
|
|
|
- DeepClone(GetLowerBound(google_firestore_v1_Value_double_value_tag)));
|
|
|
+ Add(comparison_groups, DeepClone(MinNumber()));
|
|
|
+ Add(comparison_groups, DeepClone(MinNumber()));
|
|
|
Add(comparison_groups, -1e20);
|
|
|
Add(comparison_groups, std::numeric_limits<int64_t>::min());
|
|
|
Add(comparison_groups, -0.1);
|
|
|
@@ -406,14 +407,11 @@ TEST_F(ValueUtilTest, RelaxedOrdering) {
|
|
|
Add(comparison_groups, 1.0, 1L);
|
|
|
Add(comparison_groups, std::numeric_limits<int64_t>::max());
|
|
|
Add(comparison_groups, 1e20);
|
|
|
- Add(comparison_groups,
|
|
|
- DeepClone(GetUpperBound(google_firestore_v1_Value_integer_value_tag)));
|
|
|
- Add(comparison_groups,
|
|
|
- DeepClone(GetUpperBound(google_firestore_v1_Value_double_value_tag)));
|
|
|
+ Add(comparison_groups, DeepClone(MinTimestamp()));
|
|
|
+ Add(comparison_groups, DeepClone(MinTimestamp()));
|
|
|
|
|
|
// dates
|
|
|
- Add(comparison_groups,
|
|
|
- DeepClone(GetLowerBound(google_firestore_v1_Value_timestamp_value_tag)));
|
|
|
+ Add(comparison_groups, DeepClone(MinTimestamp()));
|
|
|
Add(comparison_groups, kTimestamp1);
|
|
|
Add(comparison_groups, kTimestamp2);
|
|
|
|
|
|
@@ -421,12 +419,10 @@ TEST_F(ValueUtilTest, RelaxedOrdering) {
|
|
|
// NOTE: server timestamps can't be parsed with .
|
|
|
Add(comparison_groups, EncodeServerTimestamp(kTimestamp1, absl::nullopt));
|
|
|
Add(comparison_groups, EncodeServerTimestamp(kTimestamp2, absl::nullopt));
|
|
|
- Add(comparison_groups,
|
|
|
- DeepClone(GetUpperBound(google_firestore_v1_Value_timestamp_value_tag)));
|
|
|
+ Add(comparison_groups, DeepClone(MinString()));
|
|
|
|
|
|
// strings
|
|
|
- Add(comparison_groups,
|
|
|
- DeepClone(GetLowerBound(google_firestore_v1_Value_string_value_tag)));
|
|
|
+ Add(comparison_groups, DeepClone(MinString()));
|
|
|
Add(comparison_groups, "");
|
|
|
Add(comparison_groups, "\001\ud7ff\ue000\uffff");
|
|
|
Add(comparison_groups, "(╯°□°)╯︵ ┻━┻");
|
|
|
@@ -438,35 +434,29 @@ TEST_F(ValueUtilTest, RelaxedOrdering) {
|
|
|
Add(comparison_groups, "æ");
|
|
|
// latin small letter e with acute accent + latin small letter a
|
|
|
Add(comparison_groups, "\u00e9a");
|
|
|
- Add(comparison_groups,
|
|
|
- DeepClone(GetUpperBound(google_firestore_v1_Value_string_value_tag)));
|
|
|
+ Add(comparison_groups, DeepClone(MinBytes()));
|
|
|
|
|
|
// blobs
|
|
|
- Add(comparison_groups,
|
|
|
- DeepClone(GetLowerBound(google_firestore_v1_Value_bytes_value_tag)));
|
|
|
+ Add(comparison_groups, DeepClone(MinBytes()));
|
|
|
Add(comparison_groups, BlobValue());
|
|
|
Add(comparison_groups, BlobValue(0));
|
|
|
Add(comparison_groups, BlobValue(0, 1, 2, 3, 4));
|
|
|
Add(comparison_groups, BlobValue(0, 1, 2, 4, 3));
|
|
|
Add(comparison_groups, BlobValue(255));
|
|
|
- Add(comparison_groups,
|
|
|
- DeepClone(GetUpperBound(google_firestore_v1_Value_bytes_value_tag)));
|
|
|
+ Add(comparison_groups, DeepClone(MinReference()));
|
|
|
|
|
|
// resource names
|
|
|
- Add(comparison_groups,
|
|
|
- DeepClone(GetLowerBound(google_firestore_v1_Value_reference_value_tag)));
|
|
|
+ Add(comparison_groups, DeepClone(MinReference()));
|
|
|
Add(comparison_groups, RefValue(DbId("p1/d1"), Key("c1/doc1")));
|
|
|
Add(comparison_groups, RefValue(DbId("p1/d1"), Key("c1/doc2")));
|
|
|
Add(comparison_groups, RefValue(DbId("p1/d1"), Key("c10/doc1")));
|
|
|
Add(comparison_groups, RefValue(DbId("p1/d1"), Key("c2/doc1")));
|
|
|
Add(comparison_groups, RefValue(DbId("p1/d2"), Key("c1/doc1")));
|
|
|
Add(comparison_groups, RefValue(DbId("p2/d1"), Key("c1/doc1")));
|
|
|
- Add(comparison_groups,
|
|
|
- DeepClone(GetUpperBound(google_firestore_v1_Value_reference_value_tag)));
|
|
|
+ Add(comparison_groups, DeepClone(MinGeoPoint()));
|
|
|
|
|
|
// geo points
|
|
|
- Add(comparison_groups,
|
|
|
- DeepClone(GetLowerBound(google_firestore_v1_Value_geo_point_value_tag)));
|
|
|
+ Add(comparison_groups, DeepClone(MinGeoPoint()));
|
|
|
Add(comparison_groups, GeoPoint(-90, -180));
|
|
|
Add(comparison_groups, GeoPoint(-90, 0));
|
|
|
Add(comparison_groups, GeoPoint(-90, 180));
|
|
|
@@ -479,29 +469,32 @@ TEST_F(ValueUtilTest, RelaxedOrdering) {
|
|
|
Add(comparison_groups, GeoPoint(90, -180));
|
|
|
Add(comparison_groups, GeoPoint(90, 0));
|
|
|
Add(comparison_groups, GeoPoint(90, 180));
|
|
|
- Add(comparison_groups,
|
|
|
- DeepClone(GetUpperBound(google_firestore_v1_Value_geo_point_value_tag)));
|
|
|
+ Add(comparison_groups, DeepClone(MinArray()));
|
|
|
|
|
|
// arrays
|
|
|
- Add(comparison_groups,
|
|
|
- DeepClone(GetLowerBound(google_firestore_v1_Value_array_value_tag)));
|
|
|
+ Add(comparison_groups, DeepClone(MinArray()));
|
|
|
Add(comparison_groups, Array("bar"));
|
|
|
Add(comparison_groups, Array("foo", 1));
|
|
|
Add(comparison_groups, Array("foo", 2));
|
|
|
Add(comparison_groups, Array("foo", "0"));
|
|
|
+ Add(comparison_groups, DeepClone(MinVector()));
|
|
|
+
|
|
|
+ // vectors
|
|
|
+ Add(comparison_groups, DeepClone(MinVector()));
|
|
|
+ Add(comparison_groups, Map("__type__", "__vector__", "value", Array(100)));
|
|
|
+ Add(comparison_groups,
|
|
|
+ Map("__type__", "__vector__", "value", Array(1.0, 2.0, 3.0)));
|
|
|
Add(comparison_groups,
|
|
|
- DeepClone(GetUpperBound(google_firestore_v1_Value_array_value_tag)));
|
|
|
+ Map("__type__", "__vector__", "value", Array(1.0, 3.0, 2.0)));
|
|
|
|
|
|
// objects
|
|
|
- Add(comparison_groups,
|
|
|
- DeepClone(GetLowerBound(google_firestore_v1_Value_map_value_tag)));
|
|
|
+ Add(comparison_groups, DeepClone(MinMap()));
|
|
|
Add(comparison_groups, Map("bar", 0));
|
|
|
Add(comparison_groups, Map("bar", 0, "foo", 1));
|
|
|
Add(comparison_groups, Map("foo", 1));
|
|
|
Add(comparison_groups, Map("foo", 2));
|
|
|
Add(comparison_groups, Map("foo", "0"));
|
|
|
- Add(comparison_groups,
|
|
|
- DeepClone(GetUpperBound(google_firestore_v1_Value_map_value_tag)));
|
|
|
+ Add(comparison_groups, DeepClone(MaxValue()));
|
|
|
|
|
|
for (size_t i = 0; i < comparison_groups.size(); ++i) {
|
|
|
for (size_t j = i; j < comparison_groups.size(); ++j) {
|
|
|
@@ -526,6 +519,9 @@ TEST_F(ValueUtilTest, CanonicalId) {
|
|
|
VerifyCanonicalId(Map("a", 1, "b", 2, "c", "3"), "{a:1,b:2,c:3}");
|
|
|
VerifyCanonicalId(Map("a", Array("b", Map("c", GeoPoint(30, 60)))),
|
|
|
"{a:[b,{c:geo(30.0,60.0)}]}");
|
|
|
+ VerifyCanonicalId(
|
|
|
+ Map("__type__", "__vector__", "value", Array(1.0, 1.0, -2.0, 3.14)),
|
|
|
+ "{__type__:__vector__,value:[1.0,1.0,-2.0,3.1]}");
|
|
|
}
|
|
|
|
|
|
TEST_F(ValueUtilTest, DeepClone) {
|