From d57d2c7d60fd5cfa43e83445675a87da9ce19d29 Mon Sep 17 00:00:00 2001 From: Dave Henderson Date: Wed, 14 Jun 2017 00:42:15 -0400 Subject: Enhancing indent function Signed-off-by: Dave Henderson --- strings/strings_test.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 strings/strings_test.go (limited to 'strings/strings_test.go') diff --git a/strings/strings_test.go b/strings/strings_test.go new file mode 100644 index 00000000..03338cd8 --- /dev/null +++ b/strings/strings_test.go @@ -0,0 +1,17 @@ +package strings + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestIndent(t *testing.T) { + actual := "hello\nworld\n!" + expected := " hello\n world\n !" + assert.Equal(t, expected, Indent(1, " ", actual)) + assert.Equal(t, "\n", Indent(1, " ", "\n")) + assert.Equal(t, " foo\n", Indent(1, " ", "foo\n")) + assert.Equal(t, " foo", Indent(1, " ", "foo")) + assert.Equal(t, " foo", Indent(3, " ", "foo")) +} -- cgit v1.2.3