From 7fd03665437ef9e26472fbf7c04c70a143cf41fe Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 30 Nov 2025 14:25:24 +0000 Subject: [PATCH 1/2] Initial plan From e9eebc24a7ceec0ba3f2053a989cb3c14fc34a6f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 30 Nov 2025 14:29:57 +0000 Subject: [PATCH 2/2] Fix longitude validation to check longitude instead of latitude Co-authored-by: mtrezza <5673677+mtrezza@users.noreply.github.com> --- .../dart/lib/src/objects/parse_geo_point.dart | 4 +- .../src/objects/parse_geo_point_test.dart | 103 ++++++++++++++++++ 2 files changed, 105 insertions(+), 2 deletions(-) create mode 100644 packages/dart/test/src/objects/parse_geo_point_test.dart diff --git a/packages/dart/lib/src/objects/parse_geo_point.dart b/packages/dart/lib/src/objects/parse_geo_point.dart index 95579ff6..349c41b2 100644 --- a/packages/dart/lib/src/objects/parse_geo_point.dart +++ b/packages/dart/lib/src/objects/parse_geo_point.dart @@ -12,11 +12,11 @@ class ParseGeoPoint { 'Latitude must be within the range (-90.0, 90.0).', ), assert( - latitude < 180, + longitude < 180, 'Longitude must be within the range (-180.0, 180.0).', ), assert( - latitude > -180, + longitude > -180, 'Longitude must be within the range (-180.0, 180.0).', ); diff --git a/packages/dart/test/src/objects/parse_geo_point_test.dart b/packages/dart/test/src/objects/parse_geo_point_test.dart new file mode 100644 index 00000000..ce8d8765 --- /dev/null +++ b/packages/dart/test/src/objects/parse_geo_point_test.dart @@ -0,0 +1,103 @@ +import 'package:parse_server_sdk/parse_server_sdk.dart'; +import 'package:test/test.dart'; + +import '../../test_utils.dart'; + +void main() { + setUpAll(() async { + await initializeParse(); + }); + + group('ParseGeoPoint', () { + group('constructor validation', () { + test('should create a valid GeoPoint with default values', () { + final geoPoint = ParseGeoPoint(); + expect(geoPoint.latitude, equals(0.0)); + expect(geoPoint.longitude, equals(0.0)); + }); + + test('should create a valid GeoPoint with valid coordinates', () { + final geoPoint = ParseGeoPoint(latitude: 40.0, longitude: -74.0); + expect(geoPoint.latitude, equals(40.0)); + expect(geoPoint.longitude, equals(-74.0)); + }); + + test('should create a valid GeoPoint with edge case values', () { + // Test boundary values that should be valid (exclusive bounds) + final geoPoint1 = ParseGeoPoint(latitude: 89.999, longitude: 179.999); + expect(geoPoint1.latitude, equals(89.999)); + expect(geoPoint1.longitude, equals(179.999)); + + final geoPoint2 = ParseGeoPoint(latitude: -89.999, longitude: -179.999); + expect(geoPoint2.latitude, equals(-89.999)); + expect(geoPoint2.longitude, equals(-179.999)); + }); + + test('should throw assertion error for latitude >= 90', () { + expect( + () => ParseGeoPoint(latitude: 90.0, longitude: 0.0), + throwsA(isA()), + ); + + expect( + () => ParseGeoPoint(latitude: 100.0, longitude: 0.0), + throwsA(isA()), + ); + }); + + test('should throw assertion error for latitude <= -90', () { + expect( + () => ParseGeoPoint(latitude: -90.0, longitude: 0.0), + throwsA(isA()), + ); + + expect( + () => ParseGeoPoint(latitude: -100.0, longitude: 0.0), + throwsA(isA()), + ); + }); + + test('should throw assertion error for longitude >= 180', () { + expect( + () => ParseGeoPoint(latitude: 0.0, longitude: 180.0), + throwsA(isA()), + ); + + expect( + () => ParseGeoPoint(latitude: 0.0, longitude: 200.0), + throwsA(isA()), + ); + }); + + test('should throw assertion error for longitude <= -180', () { + expect( + () => ParseGeoPoint(latitude: 0.0, longitude: -180.0), + throwsA(isA()), + ); + + expect( + () => ParseGeoPoint(latitude: 0.0, longitude: -200.0), + throwsA(isA()), + ); + }); + }); + + group('toJson', () { + test('should return correct JSON representation', () { + final geoPoint = ParseGeoPoint(latitude: 40.0, longitude: -74.0); + final json = geoPoint.toJson(); + + expect(json['__type'], equals('GeoPoint')); + expect(json['latitude'], equals(40.0)); + expect(json['longitude'], equals(-74.0)); + }); + }); + + group('toString', () { + test('should return correct string representation', () { + final geoPoint = ParseGeoPoint(latitude: 40.0, longitude: -74.0); + expect(geoPoint.toString(), equals('latitude: 40.0, longitude: -74.0')); + }); + }); + }); +}