Improve test coverage to ~100%
This commit is contained in:
@@ -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")
|
||||||
|
|||||||
19
po_test.go
19
po_test.go
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user