Improve test coverage to ~100%

This commit is contained in:
Leonel Quinteros
2016-06-26 12:15:08 -03:00
parent 2c5ca9c0e6
commit 21c6bc86cb
3 changed files with 52 additions and 33 deletions

View File

@@ -7,26 +7,26 @@ import (
) )
func TestGettersSetters(t *testing.T) { func TestGettersSetters(t *testing.T) {
SetDomain("test") SetDomain("test")
dom := GetDomain() dom := GetDomain()
if dom != "test" { if dom != "test" {
t.Errorf("Expected GetDomain to return 'test', but got '%s'", dom) t.Errorf("Expected GetDomain to return 'test', but got '%s'", dom)
} }
SetLibrary("/tmp/test") SetLibrary("/tmp/test")
lib := GetLibrary() lib := GetLibrary()
if lib != "/tmp/test" { if lib != "/tmp/test" {
t.Errorf("Expected GetLibrary to return '/tmp/test', but got '%s'", lib) t.Errorf("Expected GetLibrary to return '/tmp/test', but got '%s'", lib)
} }
SetLanguage("es") SetLanguage("es")
lang := GetLanguage() lang := GetLanguage()
if lang != "es" { if lang != "es" {
t.Errorf("Expected GetLanguage to return 'es', but got '%s'", lang) t.Errorf("Expected GetLanguage to return 'es', but got '%s'", lang)
} }
} }
func TestPackageFunctions(t *testing.T) { func TestPackageFunctions(t *testing.T) {
@@ -47,8 +47,8 @@ msgstr[2] "And this is the second plural form: %s"
` `
// Set default configuration // Set default configuration
Configure("/tmp", "en_US", "default") Configure("/tmp", "en_US", "default")
// Create Locales directory on default location // Create Locales directory on default location
dirname := path.Clean(library + string(os.PathSeparator) + "en_US") dirname := path.Clean(library + string(os.PathSeparator) + "en_US")

View File

@@ -93,6 +93,25 @@ msgstr[0] "Badly formatted string'
} }
} }
func TestTranslationObject(t *testing.T) {
tr := newTranslation()
str := tr.get()
if str != "" {
t.Errorf("Expected '' but got '%s'", str)
}
// Set id
tr.id = "Text"
// Get again
str = tr.get()
if str != "Text" {
t.Errorf("Expected 'Text' but got '%s'", str)
}
}
func TestPoRace(t *testing.T) { func TestPoRace(t *testing.T) {
// Set PO content // Set PO content
str := `# Some comment str := `# Some comment