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.
55 lines
886 B
Go
55 lines
886 B
Go
package narr_test
|
|
|
|
import (
|
|
"git.noahlan.cn/noahlan/ntool/narr"
|
|
"git.noahlan.cn/noahlan/ntool/ntest/assert"
|
|
"testing"
|
|
)
|
|
|
|
func TestInts_Has_String(t *testing.T) {
|
|
tests := []struct {
|
|
is narr.Ints
|
|
val int
|
|
want bool
|
|
want2 string
|
|
}{
|
|
{
|
|
narr.Ints{12, 23},
|
|
12,
|
|
true,
|
|
"12,23",
|
|
},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
assert.Eq(t, tt.want, tt.is.Has(tt.val))
|
|
assert.False(t, tt.is.Has(999))
|
|
assert.Eq(t, tt.want2, tt.is.String())
|
|
}
|
|
}
|
|
|
|
func TestStrings_methods(t *testing.T) {
|
|
tests := []struct {
|
|
ss narr.Strings
|
|
val string
|
|
want bool
|
|
want2 string
|
|
}{
|
|
{
|
|
narr.Strings{"a", "b"},
|
|
"a",
|
|
true,
|
|
"a,b",
|
|
},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
assert.Eq(t, tt.want, tt.ss.Has(tt.val))
|
|
assert.False(t, tt.ss.Has("not-exists"))
|
|
assert.Eq(t, tt.want2, tt.ss.String())
|
|
}
|
|
|
|
ss := narr.Strings{"a", "b"}
|
|
assert.Eq(t, "a b", ss.Join(" "))
|
|
}
|