Files
logger/lvl/lvl_test.go
2025-05-09 18:32:06 +02:00

74 lines
848 B
Go

package lvl
import (
"testing"
)
func TestString(t *testing.T) {
cases := []struct {
l Level
e string
}{
{
l: Debug,
e: "Debug",
},
{
l: Info,
e: "Info",
},
{
l: Warn,
e: "Warn",
},
{
l: Error,
e: "Error",
},
}
for _, c := range cases {
t.Run(c.e, func(t *testing.T) {
s := c.l.String()
if s != c.e {
t.Errorf("Expected %s but got %s", c.e, s)
}
})
}
}
func TestMarshalJSON(t *testing.T) {
cases := []struct {
l Level
e string
}{
{
l: Debug,
e: `"Debug"`,
},
{
l: Info,
e: `"Info"`,
},
{
l: Warn,
e: `"Warn"`,
},
{
l: Error,
e: `"Error"`,
},
}
for _, c := range cases {
t.Run(c.e, func(t *testing.T) {
res, _ := c.l.MarshalJSON()
if string(res) != c.e {
t.Errorf("Expected %s but got %s", c.e, res)
}
})
}
}