You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ntool/narr/format_test.go

24 lines
513 B
Go

1 year ago
package narr_test
import (
"fmt"
"git.noahlan.cn/noahlan/ntool/narr"
"git.noahlan.cn/noahlan/ntool/ntest/assert"
"testing"
)
func TestNewFormatter(t *testing.T) {
arr := [2]string{"a", "b"}
str := narr.FormatIndent(arr, " ")
assert.Contains(t, str, "\n ")
fmt.Println(str)
str = narr.FormatIndent(arr, "")
assert.NotContains(t, str, "\n ")
assert.Eq(t, "[a, b]", str)
fmt.Println(str)
assert.Eq(t, "", narr.FormatIndent("invalid", ""))
assert.Eq(t, "[]", narr.FormatIndent([]string{}, ""))
}