Skip to content

Commit 2ea9c3f

Browse files
committed
Add test
1 parent 596a73d commit 2ea9c3f

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

firestore/integration_test_internal/src/filter_test.cc

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,29 @@ TEST_F(FilterTest, CompositeComparison) {
433433
EXPECT_NE(or3, or4);
434434
}
435435

436+
TEST_F(FilterTest, QueryWhereComposite) {
437+
MapFieldValue doc_aa = {{"x", FieldValue::String("a")}, {"y", FieldValue::String("a")}};
438+
MapFieldValue doc_ab = {{"x", FieldValue::String("a")}, {"y", FieldValue::String("b")}};
439+
MapFieldValue doc_ba = {{"x", FieldValue::String("b")}, {"y", FieldValue::String("a")}};
440+
MapFieldValue doc_bb = {{"x", FieldValue::String("b")}, {"y", FieldValue::String("b")}};
441+
CollectionReference collection =
442+
Collection({{"aa", doc_aa},
443+
{"ab", doc_ab},
444+
{"ba", doc_ba},
445+
{"bb", doc_bb}});
446+
447+
Filter filter_xa = Filter::EqualTo("x", FieldValue::String("a"));
448+
Filter filter_yb = Filter::EqualTo("y", FieldValue::String("b"));
449+
450+
QuerySnapshot snapshot1 =
451+
ReadDocuments(collection.Where(Filter::And(filter_xa, filter_yb)));
452+
EXPECT_EQ(std::vector<MapFieldValue>({doc_ab}), QuerySnapshotToValues(snapshot1));
453+
454+
QuerySnapshot snapshot2 =
455+
ReadDocuments(collection.Where(Filter::Or(filter_xa, filter_yb)));
456+
EXPECT_EQ(std::vector<MapFieldValue>({doc_aa, doc_ab, doc_bb}), QuerySnapshotToValues(snapshot2));
457+
}
458+
436459
} // namespace
437460

438461
} // namespace firestore

0 commit comments

Comments
 (0)