Log System Implementation #1
47
log_test.go
Normal file
47
log_test.go
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
package stonelog
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func Test_LogLevelString(t *testing.T) {
|
||||||
|
levelTests := []struct {
|
||||||
|
level StoneLevel
|
||||||
|
expected string
|
||||||
|
}{
|
||||||
|
{TRACE, "TRACE"},
|
||||||
|
{DEBUG, "DEBUG"},
|
||||||
|
{INFO, "INFO"},
|
||||||
|
{WARN, "WARN"},
|
||||||
|
{ERROR, "ERROR"},
|
||||||
|
{FATAL, "FATAL"},
|
||||||
|
{PANIC, "PANIC"},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range levelTests {
|
||||||
|
if tt.level.String() != tt.expected {
|
||||||
|
t.Errorf("Expected %s, got %s", tt.expected, tt.level.String())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func Test_LogLevelColor(t *testing.T) {
|
||||||
|
levelTests := []struct {
|
||||||
|
level StoneLevel
|
||||||
|
expected string
|
||||||
|
}{
|
||||||
|
{TRACE, colorWhite},
|
||||||
|
{DEBUG, colorCyan},
|
||||||
|
{INFO, colorGreen},
|
||||||
|
{WARN, colorYellow},
|
||||||
|
{ERROR, colorRed},
|
||||||
|
{FATAL, colorMagenta},
|
||||||
|
{PANIC, colorRed + "\033[1m"},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range levelTests {
|
||||||
|
if tt.level.Color() != tt.expected {
|
||||||
|
t.Errorf("Expected %s, got %s", tt.expected, tt.level.Color())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user