]> git.ipfire.org Git - thirdparty/google/fonts.git/commitdiff
Add test_datalanguages.py with exemplar test
authorDenis Moyogo Jacquerye <moyogo@gmail.com>
Fri, 28 Oct 2022 13:08:45 +0000 (15:08 +0200)
committerDenis Moyogo Jacquerye <moyogo@gmail.com>
Mon, 31 Oct 2022 17:01:08 +0000 (18:01 +0100)
tests/test_data_languages.py [new file with mode: 0644]

diff --git a/tests/test_data_languages.py b/tests/test_data_languages.py
new file mode 100644 (file)
index 0000000..40e78a6
--- /dev/null
@@ -0,0 +1,32 @@
+#!/usr/bin/env python3
+#
+# Copyright 2022 Google LLC All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS-IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+import pytest
+from collections import Counter
+from gflanguages import LoadLanguages
+
+
+@pytest.mark.parametrize(
+    "exemplar_name",
+    ["base", "auxiliary", "marks", "numerals", "punctuation", "index"]
+)
+def test_languages_exemplars_duplicates(exemplar_name):
+    for code, lang in LoadLanguages().items():
+        exemplar = getattr(lang.exemplar_chars, exemplar_name).split()
+        counter = Counter(exemplar)
+        counts = sorted(counter.most_common(), key=lambda pair:
+                        exemplar.index(pair[0]))
+        assert (counts == [(v, 1) for v in exemplar])