mirror of
https://github.com/FoggedLens/deflock-app.git
synced 2026-08-10 21:20:18 +02:00
better limits for min/max zoom validations, separate lat+lon validation, less verbose comments
This commit is contained in:
@@ -3,36 +3,51 @@ import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:deflockapp/services/coordinate_validation.dart';
|
||||
|
||||
void main() {
|
||||
group('isValidCoordinate', () {
|
||||
test('accepts normal in-range values', () {
|
||||
expect(isValidCoordinate(0), isTrue);
|
||||
expect(isValidCoordinate(37.7749), isTrue);
|
||||
expect(isValidCoordinate(-122.4194), isTrue);
|
||||
expect(isValidCoordinate(180), isTrue);
|
||||
expect(isValidCoordinate(-180), isTrue);
|
||||
group('isValidLatitude', () {
|
||||
test('accepts in-range values', () {
|
||||
expect(isValidLatitude(0), isTrue);
|
||||
expect(isValidLatitude(37.7749), isTrue);
|
||||
expect(isValidLatitude(90), isTrue);
|
||||
expect(isValidLatitude(-90), isTrue);
|
||||
});
|
||||
|
||||
test('rejects NaN', () {
|
||||
expect(isValidCoordinate(double.nan), isFalse);
|
||||
});
|
||||
|
||||
test('rejects positive and negative infinity', () {
|
||||
expect(isValidCoordinate(double.infinity), isFalse);
|
||||
expect(isValidCoordinate(double.negativeInfinity), isFalse);
|
||||
test('rejects NaN and Infinite', () {
|
||||
expect(isValidLatitude(double.nan), isFalse);
|
||||
expect(isValidLatitude(double.infinity), isFalse);
|
||||
expect(isValidLatitude(double.negativeInfinity), isFalse);
|
||||
});
|
||||
|
||||
test('rejects out-of-range values', () {
|
||||
expect(isValidCoordinate(180.1), isFalse);
|
||||
expect(isValidCoordinate(-180.1), isFalse);
|
||||
expect(isValidCoordinate(1000), isFalse);
|
||||
expect(isValidLatitude(90.1), isFalse);
|
||||
expect(isValidLatitude(-90.1), isFalse);
|
||||
});
|
||||
});
|
||||
|
||||
group('isValidLongitude', () {
|
||||
test('accepts in-range values', () {
|
||||
expect(isValidLongitude(0), isTrue);
|
||||
expect(isValidLongitude(-122.4194), isTrue);
|
||||
expect(isValidLongitude(180), isTrue);
|
||||
expect(isValidLongitude(-180), isTrue);
|
||||
});
|
||||
|
||||
test('rejects NaN and Infinite', () {
|
||||
expect(isValidLongitude(double.nan), isFalse);
|
||||
expect(isValidLongitude(double.infinity), isFalse);
|
||||
expect(isValidLongitude(double.negativeInfinity), isFalse);
|
||||
});
|
||||
|
||||
test('rejects out-of-range values', () {
|
||||
expect(isValidLongitude(180.1), isFalse);
|
||||
expect(isValidLongitude(-180.1), isFalse);
|
||||
});
|
||||
});
|
||||
|
||||
group('isValidZoom', () {
|
||||
test('accepts normal in-range values', () {
|
||||
expect(isValidZoom(0), isTrue);
|
||||
test('accepts in-range values (default bounds: 1.0 to kAbsoluteMaxZoom)', () {
|
||||
expect(isValidZoom(1), isTrue);
|
||||
expect(isValidZoom(15), isTrue);
|
||||
expect(isValidZoom(25), isTrue);
|
||||
expect(isValidZoom(23), isTrue);
|
||||
});
|
||||
|
||||
test('rejects NaN and Infinite', () {
|
||||
@@ -42,8 +57,9 @@ void main() {
|
||||
});
|
||||
|
||||
test('rejects out-of-range values with default bounds', () {
|
||||
expect(isValidZoom(-1), isFalse);
|
||||
expect(isValidZoom(26), isFalse);
|
||||
expect(isValidZoom(0), isFalse);
|
||||
expect(isValidZoom(0.5), isFalse);
|
||||
expect(isValidZoom(24), isFalse);
|
||||
});
|
||||
|
||||
test('respects custom min/max bounds', () {
|
||||
|
||||
Reference in New Issue
Block a user