-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathchomp_test.go
More file actions
29 lines (26 loc) · 765 Bytes
/
chomp_test.go
File metadata and controls
29 lines (26 loc) · 765 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package stringutil
import (
"fmt"
"github.com/wallclockbuilder/testify/assert"
"testing"
)
func ExampleChomp() {
fmt.Println(Chomp("hello", "llo"))
fmt.Println(Chomp("hello\n", ""))
fmt.Println(Chomp("hello\r\n", ""))
// Output: he
// hello
// hello
}
func TestChomp(t *testing.T) {
assert := assert.New(t)
assert.Equal("hello", Chomp("hello", ""))
assert.Equal("hello", Chomp("hello\n", ""))
assert.Equal("hello", Chomp("hello\r\n", ""))
assert.Equal("hello\n", Chomp("hello\n\r", ""))
assert.Equal("hello", Chomp("hello\r", ""))
assert.Equal("hello \n there", Chomp("hello \n there", ""))
assert.Equal("he", Chomp("hello", "llo"))
assert.Equal("hello", Chomp("hello\r\n\r\n", ""))
assert.Equal("hello\r\n\r", Chomp("hello\r\n\r\r\n", ""))
}