-
Notifications
You must be signed in to change notification settings - Fork 124
Tomandersen/count test #1206
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Tomandersen/count test #1206
Changes from 11 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
60ab28d
Fix linking
tom-andersen 3a68030
Cleanup
tom-andersen 558b317
Responding to PR comments.
tom-andersen 0141434
Rename
tom-andersen ff40ac0
Rename
tom-andersen 1a5b1c0
Fixup constructor/assignment parameter naming.
tom-andersen 4e5a847
Add Test
tom-andersen c0f8f9d
Format
tom-andersen d704a5c
Add test
tom-andersen 41f3e43
Add test
tom-andersen 619e38c
Format
tom-andersen a8379ab
Recognize NaN filter probelm
tom-andersen c80337c
Add tests
tom-andersen 0682275
Add tests
tom-andersen eceb451
Add tests
tom-andersen 1af4623
Test is_valid()
tom-andersen 9bceca3
Add constructor and assignment tests.
tom-andersen f0f6af1
Rename variable
tom-andersen 833a2e8
Format
tom-andersen bbf2f4f
Remove extra semicolon
tom-andersen 50bf905
Add self move assignment test
tom-andersen 0331afe
Format
tom-andersen 9f94fdd
Simplify
tom-andersen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
127 changes: 127 additions & 0 deletions
127
firestore/integration_test_internal/src/aggregate_query_snapshot_test.cc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
/* | ||
* Copyright 2023 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#include "firebase/firestore.h" | ||
#include "firestore_integration_test.h" | ||
|
||
#include "gtest/gtest.h" | ||
|
||
namespace firebase { | ||
namespace firestore { | ||
|
||
using AggregateQuerySnapshotTest = FirestoreIntegrationTest; | ||
|
||
std::size_t AggregateQuerySnapshotHash(const AggregateQuerySnapshot& snapshot) { | ||
return snapshot.Hash(); | ||
} | ||
|
||
TEST_F(AggregateQuerySnapshotTest, Equality) { | ||
dconeybe marked this conversation as resolved.
Show resolved
Hide resolved
|
||
CollectionReference collection = | ||
Collection({{"a", {{"k", FieldValue::String("a")}}}, | ||
{"b", {{"k", FieldValue::String("b")}}}, | ||
{"c", {{"k", FieldValue::String("c")}}}}); | ||
AggregateQuerySnapshot snapshot1 = ReadAggregate( | ||
collection.WhereEqualTo("k", FieldValue::String("d")).Count()); | ||
AggregateQuerySnapshot snapshot2 = ReadAggregate(collection.Limit(1).Count()); | ||
AggregateQuerySnapshot snapshot3 = ReadAggregate(collection.Limit(1).Count()); | ||
AggregateQuerySnapshot snapshot4 = ReadAggregate(collection.Limit(3).Count()); | ||
AggregateQuerySnapshot snapshot5 = ReadAggregate(collection.Count()); | ||
AggregateQuerySnapshot snapshot6 = ReadAggregate(collection.Count()); | ||
|
||
EXPECT_TRUE(snapshot1 == snapshot1); | ||
dconeybe marked this conversation as resolved.
Show resolved
Hide resolved
|
||
EXPECT_TRUE(snapshot1 != snapshot2); | ||
EXPECT_TRUE(snapshot1 != snapshot3); | ||
EXPECT_TRUE(snapshot1 != snapshot4); | ||
EXPECT_TRUE(snapshot1 != snapshot5); | ||
EXPECT_TRUE(snapshot1 != snapshot6); | ||
EXPECT_TRUE(snapshot2 == snapshot2); | ||
EXPECT_TRUE(snapshot2 == snapshot3); | ||
EXPECT_TRUE(snapshot2 != snapshot4); | ||
EXPECT_TRUE(snapshot2 != snapshot5); | ||
EXPECT_TRUE(snapshot2 != snapshot6); | ||
EXPECT_TRUE(snapshot4 == snapshot4); | ||
EXPECT_TRUE(snapshot4 != snapshot5); | ||
EXPECT_TRUE(snapshot4 != snapshot6); | ||
EXPECT_TRUE(snapshot5 == snapshot5); | ||
EXPECT_TRUE(snapshot5 == snapshot6); | ||
|
||
EXPECT_FALSE(snapshot1 != snapshot1); | ||
EXPECT_FALSE(snapshot1 == snapshot2); | ||
EXPECT_FALSE(snapshot1 == snapshot3); | ||
EXPECT_FALSE(snapshot1 == snapshot4); | ||
EXPECT_FALSE(snapshot1 == snapshot5); | ||
EXPECT_FALSE(snapshot1 == snapshot6); | ||
EXPECT_FALSE(snapshot2 != snapshot2); | ||
EXPECT_FALSE(snapshot2 != snapshot3); | ||
EXPECT_FALSE(snapshot2 == snapshot4); | ||
EXPECT_FALSE(snapshot2 == snapshot5); | ||
EXPECT_FALSE(snapshot2 == snapshot6); | ||
EXPECT_FALSE(snapshot4 != snapshot4); | ||
EXPECT_FALSE(snapshot4 == snapshot5); | ||
EXPECT_FALSE(snapshot4 == snapshot6); | ||
EXPECT_FALSE(snapshot5 != snapshot5); | ||
EXPECT_FALSE(snapshot5 != snapshot6); | ||
} | ||
|
||
TEST_F(AggregateQuerySnapshotTest, TestHashCode) { | ||
CollectionReference collection = | ||
Collection({{"a", {{"k", FieldValue::String("a")}}}, | ||
{"b", {{"k", FieldValue::String("b")}}}, | ||
{"c", {{"k", FieldValue::String("c")}}}}); | ||
AggregateQuerySnapshot snapshot1 = ReadAggregate( | ||
collection.WhereEqualTo("k", FieldValue::String("d")).Count()); | ||
AggregateQuerySnapshot snapshot2 = ReadAggregate(collection.Limit(1).Count()); | ||
AggregateQuerySnapshot snapshot3 = ReadAggregate(collection.Limit(1).Count()); | ||
AggregateQuerySnapshot snapshot4 = ReadAggregate(collection.Limit(3).Count()); | ||
AggregateQuerySnapshot snapshot5 = ReadAggregate(collection.Count()); | ||
AggregateQuerySnapshot snapshot6 = ReadAggregate(collection.Count()); | ||
|
||
EXPECT_EQ(AggregateQuerySnapshotHash(snapshot1), | ||
AggregateQuerySnapshotHash(snapshot1)); | ||
EXPECT_NE(AggregateQuerySnapshotHash(snapshot1), | ||
AggregateQuerySnapshotHash(snapshot2)); | ||
EXPECT_NE(AggregateQuerySnapshotHash(snapshot1), | ||
AggregateQuerySnapshotHash(snapshot3)); | ||
EXPECT_NE(AggregateQuerySnapshotHash(snapshot1), | ||
AggregateQuerySnapshotHash(snapshot4)); | ||
EXPECT_NE(AggregateQuerySnapshotHash(snapshot1), | ||
AggregateQuerySnapshotHash(snapshot5)); | ||
EXPECT_NE(AggregateQuerySnapshotHash(snapshot1), | ||
AggregateQuerySnapshotHash(snapshot6)); | ||
EXPECT_EQ(AggregateQuerySnapshotHash(snapshot2), | ||
AggregateQuerySnapshotHash(snapshot2)); | ||
EXPECT_EQ(AggregateQuerySnapshotHash(snapshot2), | ||
AggregateQuerySnapshotHash(snapshot3)); | ||
EXPECT_NE(AggregateQuerySnapshotHash(snapshot2), | ||
AggregateQuerySnapshotHash(snapshot4)); | ||
EXPECT_NE(AggregateQuerySnapshotHash(snapshot2), | ||
AggregateQuerySnapshotHash(snapshot5)); | ||
EXPECT_NE(AggregateQuerySnapshotHash(snapshot2), | ||
AggregateQuerySnapshotHash(snapshot6)); | ||
EXPECT_EQ(AggregateQuerySnapshotHash(snapshot4), | ||
AggregateQuerySnapshotHash(snapshot4)); | ||
EXPECT_NE(AggregateQuerySnapshotHash(snapshot4), | ||
AggregateQuerySnapshotHash(snapshot5)); | ||
EXPECT_NE(AggregateQuerySnapshotHash(snapshot4), | ||
AggregateQuerySnapshotHash(snapshot6)); | ||
EXPECT_EQ(AggregateQuerySnapshotHash(snapshot5), | ||
AggregateQuerySnapshotHash(snapshot5)); | ||
EXPECT_EQ(AggregateQuerySnapshotHash(snapshot5), | ||
AggregateQuerySnapshotHash(snapshot6)); | ||
} | ||
|
||
} // namespace firestore | ||
} // namespace firebase |
46 changes: 46 additions & 0 deletions
46
firestore/integration_test_internal/src/aggregate_query_test.cc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* Copyright 2023 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#include "firebase/firestore.h" | ||
dconeybe marked this conversation as resolved.
Show resolved
Hide resolved
|
||
#include "firestore_integration_test.h" | ||
|
||
#include "gtest/gtest.h" | ||
|
||
namespace firebase { | ||
namespace firestore { | ||
|
||
using AggrgegateQueryTest = FirestoreIntegrationTest; | ||
|
||
size_t AggregateQueryHash(const AggregateQuery& aggregate_query) { | ||
dconeybe marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return aggregate_query.Hash(); | ||
} | ||
|
||
TEST_F(AggrgegateQueryTest, TestHashCode) { | ||
dconeybe marked this conversation as resolved.
Show resolved
Hide resolved
|
||
CollectionReference collection = | ||
Collection({{"a", {{"k", FieldValue::String("a")}}}, | ||
{"b", {{"k", FieldValue::String("b")}}}}); | ||
Query query1 = | ||
collection.Limit(2).OrderBy("sort", Query::Direction::kAscending); | ||
Query query2 = | ||
collection.Limit(2).OrderBy("sort", Query::Direction::kDescending); | ||
EXPECT_NE(AggregateQueryHash(query1.Count()), | ||
AggregateQueryHash(query2.Count())); | ||
EXPECT_EQ(AggregateQueryHash(query1.Count()), | ||
AggregateQueryHash(query1.Count())); | ||
} | ||
|
||
} // namespace firestore | ||
} // namespace firebase |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.