FIRAggregateQueryUnitTests.mm 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. * Copyright 2023 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. #import <FirebaseFirestore/FIRAggregateQuery.h>
  17. #import <FirebaseFirestore/FIRQuery.h>
  18. #import <XCTest/XCTest.h>
  19. #import "Firestore/Source/API/FIRFirestore+Internal.h"
  20. #import "Firestore/Source/API/FIRQuery+Internal.h"
  21. #import "Firestore/Example/Tests/API/FSTAPIHelpers.h"
  22. #import "Firestore/Example/Tests/Util/FSTHelpers.h"
  23. #include "Firestore/core/src/core/query.h"
  24. #include "Firestore/core/test/unit/testutil/testutil.h"
  25. namespace api = firebase::firestore::api;
  26. using firebase::firestore::testutil::Query;
  27. NS_ASSUME_NONNULL_BEGIN
  28. @interface FIRAggregateQueryUnitTests : XCTestCase
  29. @end
  30. @implementation FIRAggregateQueryUnitTests
  31. - (void)testEquals {
  32. std::shared_ptr<api::Firestore> firestore = FSTTestFirestore().wrapped;
  33. FIRAggregateQuery *queryFoo =
  34. [[FIRQuery alloc] initWithQuery:Query("foo") firestore:firestore].count;
  35. FIRAggregateQuery *queryFooDup =
  36. [[FIRQuery alloc] initWithQuery:Query("foo") firestore:firestore].count;
  37. FIRAggregateQuery *queryBar =
  38. [[FIRQuery alloc] initWithQuery:Query("bar") firestore:firestore].count;
  39. XCTAssertEqualObjects(queryFoo, queryFooDup);
  40. XCTAssertNotEqualObjects(queryFoo, queryBar);
  41. XCTAssertEqual([queryFoo hash], [queryFooDup hash]);
  42. XCTAssertNotEqual([queryFoo hash], [queryBar hash]);
  43. }
  44. @end
  45. NS_ASSUME_NONNULL_END