From dec323113fbb49c83e0f6dff5f8a5e99aa46da38 Mon Sep 17 00:00:00 2001 From: shengzhou Date: Fri, 8 Jul 2022 19:52:39 +0800 Subject: [PATCH] test(config/file): add format test (#2147) (#2168) --- config/file/format_test.go | 41 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 config/file/format_test.go diff --git a/config/file/format_test.go b/config/file/format_test.go new file mode 100644 index 000000000..509a98379 --- /dev/null +++ b/config/file/format_test.go @@ -0,0 +1,41 @@ +package file + +import "testing" + +func TestFormat(t *testing.T) { + tests := []struct { + input string + expect string + }{ + { + input: "", + expect: "", + }, + { + input: " ", + expect: "", + }, + { + input: ".", + expect: "", + }, + { + input: "a.", + expect: "", + }, + { + input: ".b", + expect: "b", + }, + { + input: "a.b", + expect: "b", + }, + } + for _, v := range tests { + content := format(v.input) + if got, want := content, v.expect; got != want { + t.Errorf("expect %v,got %v", want, got) + } + } +}