aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2023-10-24 18:11:41 +0200
committerHugo Hörnquist <hugo@lysator.liu.se>2023-10-24 18:11:41 +0200
commitc926abbd4720c901c4f944cb158b32460efabb48 (patch)
treef047ec110d99cbadb47e675036dc589c31bd2c5d
parentAdd tests for (calp) module. (diff)
downloadcalp-c926abbd4720c901c4f944cb158b32460efabb48.tar.gz
calp-c926abbd4720c901c4f944cb158b32460efabb48.tar.xz
Add tests for (calp translation).
-rw-r--r--module/calp/translation.scm1
-rw-r--r--tests/unit/calp/translation.scm17
-rw-r--r--tests/unit/coverage-supplement.scm7
3 files changed, 25 insertions, 0 deletions
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"