1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
package i18n
import (
"testing"
"time"
"github.com/lukaszkasprzak/prognosis/internal/config"
)
func TestForFallsBackToEnglish(t *testing.T) {
if For("klingon").Lang() != EN {
t.Fatal("an unknown language must degrade to English, not to empty strings")
}
if For("pl").Lang() != PL {
t.Fatal("pl must resolve to the Polish catalogue")
}
}
// Every catalogue must cover every column, or a table in that language would
// silently fall back to the internal column name.
func TestEveryLanguageCoversEveryColumn(t *testing.T) {
for _, lang := range []Lang{EN, PL} {
c := For(string(lang))
for _, col := range config.ValidColumns() {
if _, ok := c.headers[col]; !ok {
t.Errorf("%s: no header for column %q", lang, col)
}
}
}
}
// The WMO codes must match across languages: a code described in English but
// not Polish would print "code 71" to a Polish reader.
func TestConditionCoverageMatchesAcrossLanguages(t *testing.T) {
en, pl := For("en"), For("pl")
for code := range en.conditions {
if _, ok := pl.conditions[code]; !ok {
t.Errorf("code %d described in English but not Polish", code)
}
}
for code := range pl.conditions {
if _, ok := en.conditions[code]; !ok {
t.Errorf("code %d described in Polish but not English", code)
}
}
}
func TestWordAndSpeciesCoverageMatches(t *testing.T) {
en, pl := For("en"), For("pl")
for k := range en.words {
if _, ok := pl.words[k]; !ok {
t.Errorf("word %q missing from Polish", k)
}
}
for _, s := range config.AllSpecies {
if _, ok := en.species[s]; !ok {
t.Errorf("species %q missing from English", s)
}
if _, ok := pl.species[s]; !ok {
t.Errorf("species %q missing from Polish", s)
}
}
for _, b := range []string{"none", "low", "medium", "high", "very high"} {
if en.Band(b) == b && b != "none" && b != "low" && b != "medium" && b != "high" && b != "very high" {
t.Errorf("band %q missing from English", b)
}
if pl.Band(b) == b {
t.Errorf("band %q not translated to Polish", b)
}
}
}
func TestUnknownCodeIsVisible(t *testing.T) {
got := For("en").Condition(4242)
if got != "code 4242" {
t.Fatalf("unknown codes must be visible, got %q", got)
}
}
func TestDate(t *testing.T) {
d := time.Date(2026, 8, 10, 13, 0, 0, 0, time.UTC) // a Monday
if got, want := For("en").Date(d), "Mon 10 Aug"; got != want {
t.Errorf("en date = %q, want %q", got, want)
}
if got, want := For("pl").Date(d), "pn 10 sie"; got != want {
t.Errorf("pl date = %q, want %q", got, want)
}
}
|