From c926abbd4720c901c4f944cb158b32460efabb48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Tue, 24 Oct 2023 18:11:41 +0200 Subject: Add tests for (calp translation). --- module/calp/translation.scm | 1 + tests/unit/calp/translation.scm | 17 +++++++++++++++++ tests/unit/coverage-supplement.scm | 7 +++++++ 3 files changed, 25 insertions(+) create mode 100644 tests/unit/calp/translation.scm diff --git a/module/calp/translation.scm b/module/calp/translation.scm index e99062db..c50f14de 100644 --- a/module/calp/translation.scm +++ b/module/calp/translation.scm @@ -5,6 +5,7 @@ :use-module (srfi srfi-88) :export (G_ translate yes-no-check)) +;; TODO stop hard coding this. (bindtextdomain "calp" "/home/hugo/code/calp/localization/") diff --git a/tests/unit/calp/translation.scm b/tests/unit/calp/translation.scm new file mode 100644 index 00000000..9ef55830 --- /dev/null +++ b/tests/unit/calp/translation.scm @@ -0,0 +1,17 @@ +(define-module (test translation) + :use-module (srfi srfi-64) + :use-module (srfi srfi-88) + :use-module (calp translation) + :use-module (ice-9 i18n)) + +(define sv (make-locale (list LC_CTYPE LC_MESSAGES) "sv_SE.UTF-8")) + +;; empty key should give us translation header +;; this also tests that translations are properly loaded +(test-assert "translations" (string? (translate ""))) + +(test-equal "yes-no yes" 'yes (yes-no-check "y" sv)) +(test-equal "yes-no no" 'no (yes-no-check "n" sv)) +(test-equal "yes-no invalid" #f (yes-no-check "other" sv)) + +'((calp translation)) diff --git a/tests/unit/coverage-supplement.scm b/tests/unit/coverage-supplement.scm index 288eeda2..b8cea855 100644 --- a/tests/unit/coverage-supplement.scm +++ b/tests/unit/coverage-supplement.scm @@ -107,6 +107,13 @@ 2) + ("module/calp/translation.scm" + "b7c0a82e1c109c339cf83438f39b6fc63219b51a3ad3ee35d58e70fb6a24c5c9" + 1 + 9 ; bindtextdomain + 22 ; G_ function + ) + ;;; Vendored files, and therefore shouldn't be tested ("module/srfi/srfi-64/test-error.scm" -- cgit v1.2.3