FIRGeoPointTests.mm 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*
  2. * Copyright 2017 Google
  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/FIRGeoPoint.h>
  17. #import <XCTest/XCTest.h>
  18. #import "Firestore/Example/Tests/Util/FSTHelpers.h"
  19. NS_ASSUME_NONNULL_BEGIN
  20. @interface FIRGeoPointTests : XCTestCase
  21. @end
  22. @implementation FIRGeoPointTests
  23. - (void)testEquals {
  24. FIRGeoPoint *foo = FSTTestGeoPoint(1.23, 4.56);
  25. FIRGeoPoint *fooDup = FSTTestGeoPoint(1.23, 4.56);
  26. FIRGeoPoint *differentLatitude = FSTTestGeoPoint(1.23, 0);
  27. FIRGeoPoint *differentLongitude = FSTTestGeoPoint(0, 4.56);
  28. XCTAssertEqualObjects(foo, fooDup);
  29. XCTAssertNotEqualObjects(foo, differentLatitude);
  30. XCTAssertNotEqualObjects(foo, differentLongitude);
  31. XCTAssertEqual([foo hash], [fooDup hash]);
  32. XCTAssertNotEqual([foo hash], [differentLatitude hash]);
  33. XCTAssertNotEqual([foo hash], [differentLongitude hash]);
  34. }
  35. - (void)testComparison {
  36. NSArray *values = @[
  37. @[ [[FIRGeoPoint alloc] initWithLatitude:-90 longitude:-180] ],
  38. @[ [[FIRGeoPoint alloc] initWithLatitude:-90 longitude:0] ],
  39. @[ [[FIRGeoPoint alloc] initWithLatitude:-90 longitude:180] ],
  40. @[ [[FIRGeoPoint alloc] initWithLatitude:-89 longitude:-180] ],
  41. @[ [[FIRGeoPoint alloc] initWithLatitude:-89 longitude:0] ],
  42. @[ [[FIRGeoPoint alloc] initWithLatitude:-89 longitude:180] ],
  43. @[ [[FIRGeoPoint alloc] initWithLatitude:0 longitude:-180] ],
  44. @[ [[FIRGeoPoint alloc] initWithLatitude:0 longitude:0] ],
  45. @[ [[FIRGeoPoint alloc] initWithLatitude:0 longitude:180] ],
  46. @[ [[FIRGeoPoint alloc] initWithLatitude:89 longitude:-180] ],
  47. @[ [[FIRGeoPoint alloc] initWithLatitude:89 longitude:0] ],
  48. @[ [[FIRGeoPoint alloc] initWithLatitude:89 longitude:180] ],
  49. @[ [[FIRGeoPoint alloc] initWithLatitude:90 longitude:-180] ],
  50. @[ [[FIRGeoPoint alloc] initWithLatitude:90 longitude:0] ],
  51. @[ [[FIRGeoPoint alloc] initWithLatitude:90 longitude:180] ],
  52. ];
  53. FSTAssertComparisons(values);
  54. }
  55. @end
  56. NS_ASSUME_NONNULL_END