Skip to content

Commit fae6142

Browse files
committed
feat: Add test for Sum method in AggregateQuery
1 parent f89d482 commit fae6142

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

firestore/integration_test_internal/src/aggregate_query_test.cc

+15
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,21 @@ TEST_F(AggregateQueryTest, TestHashCode) {
337337
AggregateQueryHash(query1.Count()));
338338
}
339339

340+
TEST_F(AggregateQueryTest, SumReturnsCorrectSum) {
341+
CollectionReference collection =
342+
Collection({{"a", {{"value", FieldValue::Integer(1)}}},
343+
{"b", {{"value", FieldValue::Integer(2)}}},
344+
{"c", {{"value", FieldValue::Integer(3)}}}});
345+
346+
AggregateQuery aggregate_query =
347+
collection.Sum("value");
348+
AggregateQuerySnapshot snapshot = ReadAggregate(aggregate_query);
349+
350+
EXPECT_EQ(6.0, snapshot.sum("value"));
351+
EXPECT_EQ(aggregate_query, snapshot.query());
352+
}
353+
354+
340355
#if defined(__ANDROID__)
341356
TEST(QueryTestAndroidStub, Construction) {
342357
testutil::AssertWrapperConstructionContract<AggregateQuery>();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/*
2+
* Copyright 2025 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
// TODO: Add tests for AggregateQuery Sum

0 commit comments

Comments
 (0)