-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstrbuffer_test.go
More file actions
44 lines (38 loc) · 848 Bytes
/
strbuffer_test.go
File metadata and controls
44 lines (38 loc) · 848 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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package toolkit
import (
"testing"
)
func TestAdd(t *testing.T) {
sb := new(StrBuffer)
sb.Add("Hello").Add(" ").Add("World")
if "Hello World" != sb.String() {
t.Error("Expected \"Hello World\", got ", sb.String())
}
if sb.Size() != 11 {
t.Error("Expected 11, got ", sb.Size())
}
x := new(StrBuffer)
x.Add(" teste ")
sb.Add(x).Add(1).Add(true)
if "Hello World teste 1true" != sb.String() {
t.Error("\"Hello World teste 1true\", got ", sb.String())
}
}
func TestEquals(t *testing.T) {
sb1 := new(StrBuffer)
sb1.Add("Hello")
sb2 := new(StrBuffer)
sb2.Add("Hello")
if !sb1.Equals(sb2) {
t.Error("The StrBuffers are not equal")
}
}
func TestClone(t *testing.T) {
sb1 := new(StrBuffer)
sb1.Add("Hello")
sb2 := sb1.Clone().(*StrBuffer)
sb2.Add(" World")
if sb1.Equals(sb2) {
t.Error("The StrBuffers are equal")
}
}