Improve test coverage to ~100%

This commit is contained in:
Leonel Quinteros
2016-06-26 11:54:28 -03:00
parent 5f34149d25
commit 2c5ca9c0e6
3 changed files with 82 additions and 9 deletions

View File

@@ -47,6 +47,9 @@ msgstr[2] "And this is the second plural form: %s"
// Create Locale with full language code
l := NewLocale("/tmp", "en_US")
// Force nil domain storage
l.domains = nil
// Add domain
l.AddDomain("my_domain")
@@ -68,6 +71,17 @@ msgstr[2] "And this is the second plural form: %s"
if tr != "And this is the second plural form: Variable" {
t.Errorf("Expected 'And this is the second plural form: Variable' but got '%s'", tr)
}
// Test non-existent "deafult" domain responses
tr = l.Get("My text")
if tr != "My text" {
t.Errorf("Expected 'My text' but got '%s'", tr)
}
tr = l.GetN("One with var: %s", "Several with vars: %s", 2, v)
if tr != "Several with vars: Variable" {
t.Errorf("Expected 'Several with vars: Variable' but got '%s'", tr)
}
}
func TestLocaleRace(t *testing.T) {
@@ -124,12 +138,12 @@ msgstr[2] "And this is the second plural form: %s"
// Get translations in goroutine
go func(l *Locale, done chan bool) {
println(l.GetD("race", "My text"))
l.GetD("race", "My text")
done <- true
}(l, rc)
// Get translations at top level
println(l.GetD("race", "My text"))
l.GetD("race", "My text")
// Wait for goroutines to finish
<-ac