feat: assert with startswith and endswith for string

This commit is contained in:
debugtalk
2021-10-04 18:09:46 +08:00
parent b7acd2e887
commit 8f67916d35
3 changed files with 94 additions and 0 deletions

43
builtin/assertion_test.go Normal file
View File

@@ -0,0 +1,43 @@
package builtin
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestStartsWith(t *testing.T) {
testData := []struct {
raw string
expected string
}{
{"", ""},
{"a", "a"},
{"abc", "a"},
{"abc", "ab"},
}
for _, data := range testData {
if !assert.True(t, StartsWith(t, data.expected, data.raw)) {
t.Fail()
}
}
}
func TestEndsWith(t *testing.T) {
testData := []struct {
raw string
expected string
}{
{"", ""},
{"a", "a"},
{"abc", "c"},
{"abc", "bc"},
}
for _, data := range testData {
if !assert.True(t, EndsWith(t, data.expected, data.raw)) {
t.Fail()
}
}
}