This repository has been archived on 2021-06-21. You can view files and clone it, but cannot push or open issues/pull-requests.
2020-01-29 04:01:33 +00:00
|
|
|
package color
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestMain(m *testing.M) {
|
|
|
|
os.Exit(m.Run())
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestParseLevel(t *testing.T) {
|
|
|
|
tt := []struct {
|
|
|
|
Parse string
|
2021-02-16 21:44:17 +00:00
|
|
|
Expected Color
|
2020-01-29 04:01:33 +00:00
|
|
|
}{
|
|
|
|
{"T", Trace},
|
|
|
|
{"Trace", Trace},
|
|
|
|
{"D", Debug},
|
|
|
|
{"Debug", Debug},
|
|
|
|
{"I", Info},
|
|
|
|
{"Info", Info},
|
|
|
|
{"W", Warn},
|
|
|
|
{"Warn", Warn},
|
|
|
|
{"E", Error},
|
|
|
|
{"Error", Error},
|
|
|
|
{"F", Fatal},
|
|
|
|
{"Fatal", Fatal},
|
|
|
|
{"Unknown", Info},
|
|
|
|
{"N/A", Info},
|
|
|
|
{"1234", Info},
|
|
|
|
{"A Space", Info},
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, tc := range tt {
|
|
|
|
t.Run(tc.Parse, func(t *testing.T) {
|
|
|
|
level := ParseLevel(tc.Parse)
|
|
|
|
if level != tc.Expected {
|
|
|
|
t.Logf("Expected `%s`, got `%s`", tc.Expected, level)
|
|
|
|
t.Fail()
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|