main
 1import 'package:blood_pressure_app/model/iso_lang_names.dart';
 2import 'package:flutter/material.dart';
 3import 'package:blood_pressure_app/l10n/app_localizations.dart';
 4import 'package:flutter_test/flutter_test.dart';
 5
 6void main() {
 7  test('should have unique names for all languages provided in localizations', () {
 8    final allNames = <String>[];
 9    for (final locale in AppLocalizations.supportedLocales) {
10      final name = getDisplayLanguage(locale);
11      expect(allNames, isNot(contains(name)));
12      allNames.add(name);
13    }
14  });
15  test('should start all names in upper case', () {
16    for (final locale in AppLocalizations.supportedLocales) {
17      final firstChar = getDisplayLanguage(locale)[0];
18      expect(firstChar, equals(firstChar.toUpperCase()));
19    }
20  });
21  test('should not store names where no localization present', () {
22    final tmp = debugPrint;
23    int printCounts = 0;
24    debugPrint = (String? s, {int? wrapWidth}) {
25      printCounts += 1;
26    };
27    for (final c1 in 'abcdefghijklmnopqrstuvwxyz'.characters) {
28      for (final c2 in 'abcdefghijklmnopqrstuvwxyz'.characters) {
29        if (AppLocalizations.supportedLocales.where(
30            (e) => e.toLanguageTag() == '$c1$c2',).isNotEmpty) continue;
31        expect(() => getDisplayLanguage(Locale('$c1$c2')),
32          throwsAssertionError,
33          reason: 'Lang $c1$c2 does not exist'
34        );
35        expect(printCounts, greaterThan(1));
36        printCounts = 0;
37      }
38    }
39    debugPrint = tmp;
40  });
41}