Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat: Add test for Sum method in AggregateQuery
  • Loading branch information
KKimj committed Apr 1, 2025
commit fae6142f5e08f09e6b66b56fdb6b175e8d60994e
15 changes: 15 additions & 0 deletions firestore/integration_test_internal/src/aggregate_query_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,21 @@ TEST_F(AggregateQueryTest, TestHashCode) {
AggregateQueryHash(query1.Count()));
}

TEST_F(AggregateQueryTest, SumReturnsCorrectSum) {
CollectionReference collection =
Collection({{"a", {{"value", FieldValue::Integer(1)}}},
{"b", {{"value", FieldValue::Integer(2)}}},
{"c", {{"value", FieldValue::Integer(3)}}}});

AggregateQuery aggregate_query =
collection.Sum("value");
AggregateQuerySnapshot snapshot = ReadAggregate(aggregate_query);

EXPECT_EQ(6.0, snapshot.sum("value"));
EXPECT_EQ(aggregate_query, snapshot.query());
}


#if defined(__ANDROID__)
TEST(QueryTestAndroidStub, Construction) {
testutil::AssertWrapperConstructionContract<AggregateQuery>();
Expand Down
17 changes: 17 additions & 0 deletions firestore/integration_test_internal/src/aggregate_sum_test.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
* Copyright 2025 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.
*/

// TODO: Add tests for AggregateQuery Sum