Skip to content

Commit 6dca8e8

Browse files
committed
Add tests
1 parent 647e596 commit 6dca8e8

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

zapcore/level_test.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ package zapcore
2323
import (
2424
"bytes"
2525
"flag"
26+
"fmt"
2627
"strings"
2728
"testing"
2829

@@ -76,6 +77,23 @@ func TestLevelText(t *testing.T) {
7677
}
7778
}
7879

80+
func TestParseLevel(t *testing.T) {
81+
tests := []struct {
82+
text string
83+
level Level
84+
err error
85+
}{
86+
{"info", InfoLevel, nil},
87+
{"DEBUG", DebugLevel, nil},
88+
{"FOO", 0, fmt.Errorf("unrecognized level: \"FOO\"")},
89+
}
90+
for _, tt := range tests {
91+
parsedLevel, err := ParseLevel(tt.text)
92+
assert.Equal(t, tt.level, parsedLevel)
93+
assert.Equal(t, tt.err, err)
94+
}
95+
}
96+
7997
func TestCapitalLevelsParse(t *testing.T) {
8098
tests := []struct {
8199
text string

0 commit comments

Comments
 (0)