github.com/andrewhsu/cli/v2@v2.0.1-0.20210910131313-d4b4061f5b89/pkg/text/indent_test.go (about) 1 package text 2 3 import "testing" 4 5 func Test_Indent(t *testing.T) { 6 type args struct { 7 s string 8 indent string 9 } 10 tests := []struct { 11 name string 12 args args 13 want string 14 }{ 15 { 16 name: "empty", 17 args: args{ 18 s: "", 19 indent: "--", 20 }, 21 want: "", 22 }, 23 { 24 name: "blank", 25 args: args{ 26 s: "\n", 27 indent: "--", 28 }, 29 want: "\n", 30 }, 31 { 32 name: "indent", 33 args: args{ 34 s: "one\ntwo\nthree", 35 indent: "--", 36 }, 37 want: "--one\n--two\n--three", 38 }, 39 } 40 for _, tt := range tests { 41 t.Run(tt.name, func(t *testing.T) { 42 if got := Indent(tt.args.s, tt.args.indent); got != tt.want { 43 t.Errorf("indent() = %q, want %q", got, tt.want) 44 } 45 }) 46 } 47 }