github.com/phuslu/log@v1.0.100/level_test.go (about) 1 package log 2 3 import ( 4 "testing" 5 ) 6 7 func TestLevelParse(t *testing.T) { 8 cases := []struct { 9 Level Level 10 String string 11 }{ 12 {TraceLevel, "trace"}, 13 {DebugLevel, "debug"}, 14 {InfoLevel, "info"}, 15 {WarnLevel, "warn"}, 16 {ErrorLevel, "error"}, 17 {FatalLevel, "fatal"}, 18 {PanicLevel, "panic"}, 19 {noLevel, "????"}, 20 } 21 22 for _, c := range cases { 23 if v := ParseLevel(c.String); v != c.Level { 24 t.Errorf("ParseLevel(%#v) must return %#v, not %#v", c.String, c.Level, v) 25 } 26 if v := c.Level.String(); v != c.String { 27 t.Errorf("%T.String() must return %#v, not %#v", c.Level, c.String, v) 28 } 29 } 30 }