mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-18 21:11:19 +02:00
Rename Substr to Slice
That is whas was implemented, not Substr. Also make the API more similar to Go's internal slice by making both the start and end indices optional. See #990
This commit is contained in:
@@ -276,7 +276,7 @@ func TestIn(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestSubstr(t *testing.T) {
|
||||
func TestSlice(t *testing.T) {
|
||||
for i, this := range []struct {
|
||||
v1 interface{}
|
||||
v2 int
|
||||
@@ -286,14 +286,17 @@ func TestSubstr(t *testing.T) {
|
||||
{"abc", 1, 2, "b"},
|
||||
{"abc", 1, 3, "bc"},
|
||||
{"abc", 0, 1, "a"},
|
||||
{"abcdef", -1, -1, "abcdef"},
|
||||
{"abcdef", -1, 2, "ab"},
|
||||
{"abcdef", 2, -1, "cdef"},
|
||||
{123, 1, 3, "23"},
|
||||
{tstNoStringer{}, 0, 1, false},
|
||||
} {
|
||||
result, err := Substr(this.v1, this.v2, this.v3)
|
||||
result, err := Slice(this.v1, this.v2, this.v3)
|
||||
|
||||
if b, ok := this.expect.(bool); ok && !b {
|
||||
if err == nil {
|
||||
t.Errorf("[%d] Substr didn't return an expected error", i)
|
||||
t.Errorf("[%d] Slice didn't return an expected error", i)
|
||||
}
|
||||
} else {
|
||||
if err != nil {
|
||||
|
Reference in New Issue
Block a user