Skip to content

Commit

Permalink
test: adding some tests to Substring (see #288)
Browse files Browse the repository at this point in the history
  • Loading branch information
samber committed Mar 20, 2023
1 parent cccebf9 commit 9ec076e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
6 changes: 6 additions & 0 deletions string_example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,20 @@ func ExampleSubstring() {
result1 := Substring("hello", 2, 3)
result2 := Substring("hello", -4, 3)
result3 := Substring("hello", -2, math.MaxUint)
result4 := Substring("🏠🐶🐱", 0, 2)
result5 := Substring("你好,世界", 0, 3)

fmt.Printf("%v\n", result1)
fmt.Printf("%v\n", result2)
fmt.Printf("%v\n", result3)
fmt.Printf("%v\n", result4)
fmt.Printf("%v\n", result5)
// Output:
// llo
// ell
// lo
// 🏠🐶
// 你好,
}

func ExampleChunkString() {
Expand Down
2 changes: 2 additions & 0 deletions string_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ func TestSubstring(t *testing.T) {
str11 := Substring("hello", -4, 1)
str12 := Substring("hello", -4, math.MaxUint)
str13 := Substring("🏠🐶🐱", 0, 2)
str14 := Substring("你好,世界", 0, 3)

is.Equal("", str1)
is.Equal("", str2)
Expand All @@ -89,6 +90,7 @@ func TestSubstring(t *testing.T) {
is.Equal("e", str11)
is.Equal("ello", str12)
is.Equal("🏠🐶", str13)
is.Equal("你好,", str14)
}

func TestRuneLength(t *testing.T) {
Expand Down

0 comments on commit 9ec076e

Please sign in to comment.