55 lines
2.2 KiB
Dart
55 lines
2.2 KiB
Dart
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:sign_checker/data/catalog/bundled_sign_catalog.dart';
|
|
import 'package:sign_checker/domain/sign_code.dart';
|
|
|
|
void main() {
|
|
test('labels with a sign number resolve, free text does not', () {
|
|
final catalog = bundledSignCatalog;
|
|
expect(catalog.findByLabel('3_27')?.name, 'Остановка запрещена');
|
|
expect(catalog.findByLabel('sign-2.5')?.code, '2.5');
|
|
expect(catalog.findByLabel('speed_limit'), isNull);
|
|
expect(catalog.findByLabel('3.13.35'), isNull);
|
|
expect(catalog.findByLabel('2.3'), isNull);
|
|
expect(normalizeSignCode('8.13'), '8.13');
|
|
});
|
|
|
|
test('dataset speed variants and traffic lights resolve without guessing', () {
|
|
final catalog = bundledSignCatalog;
|
|
expect(catalog.findByLabel('3.24.7')?.code, '3.24');
|
|
expect(catalog.findByLabel('3.24')?.code, '3.24');
|
|
expect(catalog.findByLabel('redTrafficLights')?.code, 'signal.red');
|
|
expect(catalog.findByLabel('TrafficLights')?.name, 'Светофор');
|
|
expect(
|
|
catalog.findByLabel('redyellowTrafficLights')?.action,
|
|
contains('зелёный'),
|
|
);
|
|
});
|
|
|
|
test('critical signs keep the distinctions drivers mix up', () {
|
|
final catalog = bundledSignCatalog;
|
|
final stop = catalog.findByCode('3.27')!;
|
|
expect(stop.summary, contains('остановка'));
|
|
expect(stop.summary, contains('стоянка'));
|
|
|
|
final parking = catalog.findByCode('3.28')!;
|
|
expect(parking.summary, contains('не запрещена'));
|
|
|
|
final halt = catalog.findByCode('2.5')!;
|
|
expect(halt.action, contains('Остановитесь'));
|
|
|
|
final yieldSign = catalog.findByCode('2.4')!;
|
|
expect(yieldSign.action, contains('уступите'));
|
|
|
|
final speed = catalog.findByCode('3.24')!;
|
|
expect(speed.requiresReadingTheSign, isTrue);
|
|
expect(speed.action, contains('цифру'));
|
|
});
|
|
|
|
test('every code is unique and sortable', () {
|
|
final codes = bundledSignCatalog.signs.map((sign) => sign.code).toList();
|
|
expect(codes.toSet(), hasLength(codes.length));
|
|
expect(codes.first, '1.1');
|
|
expect(codes.indexOf('1.4.2'), lessThan(codes.indexOf('1.20.1')));
|
|
});
|
|
}
|