|
16 | 16 |
|
17 | 17 | #include "Firestore/core/src/firebase/firestore/core/query.h"
|
18 | 18 |
|
| 19 | +#include <cmath> |
| 20 | + |
19 | 21 | #include "Firestore/core/src/firebase/firestore/model/document.h"
|
20 | 22 | #include "Firestore/core/src/firebase/firestore/model/field_path.h"
|
21 | 23 | #include "Firestore/core/src/firebase/firestore/model/field_value.h"
|
@@ -97,6 +99,26 @@ TEST(QueryTest, PrimitiveValueFilter) {
|
97 | 99 | EXPECT_FALSE(query2.Matches(doc5));
|
98 | 100 | }
|
99 | 101 |
|
| 102 | +TEST(QueryTest, NanFilter) { |
| 103 | + Query query = Query::AtPath(ResourcePath::FromString("collection")) |
| 104 | + .Filter(Filter("sort", "==", NAN)); |
| 105 | + |
| 106 | + Document doc1 = Doc("collection/1", 0, {{"sort", FieldValue::NanValue()}}); |
| 107 | + Document doc2 = |
| 108 | + Doc("collection/2", 0, {{"sort", FieldValue::IntegerValue(2)}}); |
| 109 | + Document doc3 = |
| 110 | + Doc("collection/3", 0, {{"sort", FieldValue::DoubleValue(3.1)}}); |
| 111 | + Document doc4 = Doc("collection/4", 0, {{"sort", FieldValue::FalseValue()}}); |
| 112 | + Document doc5 = |
| 113 | + Doc("collection/5", 0, {{"sort", FieldValue::StringValue("string")}}); |
| 114 | + |
| 115 | + EXPECT_TRUE(query.Matches(doc1)); |
| 116 | + EXPECT_FALSE(query.Matches(doc2)); |
| 117 | + EXPECT_FALSE(query.Matches(doc3)); |
| 118 | + EXPECT_FALSE(query.Matches(doc4)); |
| 119 | + EXPECT_FALSE(query.Matches(doc5)); |
| 120 | +} |
| 121 | + |
100 | 122 | } // namespace core
|
101 | 123 | } // namespace firestore
|
102 | 124 | } // namespace firebase
|
0 commit comments