Upstream gookit/goutil state of the touched files before 71dcf88743
This commit is contained in:
1 parent
fd69f1aadd
commit
1ffc0f390b
3 files changed
-85
No files matched your search
@@ -166,12 +166,6 @@ func Substr(s string, pos, length int) string {
|
||||
stopIdx = strLn + length
|
||||
}
|
||||
|
||||
// A negative length can move stopIdx before pos; clamp to avoid an
|
||||
// out-of-range slice.
|
||||
if stopIdx < pos {
|
||||
stopIdx = pos
|
||||
}
|
||||
|
||||
return string(runes[pos:stopIdx])
|
||||
}
|
||||
|
||||
|
||||
@@ -120,12 +120,6 @@ func TestSubstr(t *testing.T) {
|
||||
assert.Eq(t, "", strutil.Substr("abcDEF", 23, 5))
|
||||
assert.Eq(t, "cDEF12", strutil.Substr("abcDEF123", 2, -1))
|
||||
assert.Eq(t, "cDEF", strutil.Substr("abcDEF123", 2, -3))
|
||||
|
||||
// negative length trimming more than the remaining substring must not
|
||||
// panic; it should yield an empty string.
|
||||
assert.Eq(t, "", strutil.Substr("hello", 4, -3))
|
||||
assert.Eq(t, "", strutil.Substr("hello", 3, -5))
|
||||
assert.Eq(t, "", strutil.Substr("abcDEF123", 8, -3))
|
||||
}
|
||||
|
||||
func TestSplitInlineComment(t *testing.T) {
|
||||
|
||||
Reference in new issue
Block a user