From 2d9e74ea4602b13bdf4edcb4a6b9523552879862 Mon Sep 17 00:00:00 2001 From: Kent Gruber Date: Mon, 30 Apr 2018 20:10:01 -0400 Subject: [PATCH] add simple tests for core swag color functions add simple tests for each of the color functions in core swag --- core/swag_test.go | 59 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 core/swag_test.go diff --git a/core/swag_test.go b/core/swag_test.go new file mode 100644 index 00000000..e08221d3 --- /dev/null +++ b/core/swag_test.go @@ -0,0 +1,59 @@ +package core + +import "testing" + +func TestW(t *testing.T) { + exp := "<3\033[0m" + got := W("<", "3") + if got != exp { + t.Fatalf("expected '%s', got '%s'", exp, got) + } +} + +func TestBold(t *testing.T) { + exp := "\033[1mgohpers\033[0m" + got := Bold("gohpers") + if got != exp { + t.Fatalf("expected path '%s', got '%s'", exp, got) + } +} + +func TestDim(t *testing.T) { + exp := "\033[2mgohpers\033[0m" + got := Dim("gohpers") + if got != exp { + t.Fatalf("expected path '%s', got '%s'", exp, got) + } +} + +func TestRed(t *testing.T) { + exp := "\033[31mgohpers\033[0m" + got := Red("gohpers") + if got != exp { + t.Fatalf("expected path '%s', got '%s'", exp, got) + } +} + +func TestGreen(t *testing.T) { + exp := "\033[32mgohpers\033[0m" + got := Green("gohpers") + if got != exp { + t.Fatalf("expected path '%s', got '%s'", exp, got) + } +} + +func TestBlue(t *testing.T) { + exp := "\033[34mgohpers\033[0m" + got := Blue("gohpers") + if got != exp { + t.Fatalf("expected path '%s', got '%s'", exp, got) + } +} + +func TestYellow(t *testing.T) { + exp := "\033[33mgohpers\033[0m" + got := Yellow("gohpers") + if got != exp { + t.Fatalf("expected path '%s', got '%s'", exp, got) + } +}