summaryrefslogtreecommitdiffstats
path: root/src/util/chars_test.go
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2017-07-16 23:31:19 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2017-07-16 23:34:32 +0900
commit9e85cba0d06025983a1a747bfc06c9955388d9c0 (patch)
tree8fe8dc1fd62ad3ecfbfd02e440fac6cfedcd313c /src/util/chars_test.go
parent4b59ced08f1d417530a25af8fe13aa5d40579220 (diff)
Reduce memory footprint of Item struct
Diffstat (limited to 'src/util/chars_test.go')
-rw-r--r--src/util/chars_test.go20
1 files changed, 5 insertions, 15 deletions
diff --git a/src/util/chars_test.go b/src/util/chars_test.go
index 12c629d5..07b8dea5 100644
--- a/src/util/chars_test.go
+++ b/src/util/chars_test.go
@@ -2,27 +2,16 @@ package util
import "testing"
-func TestToCharsNil(t *testing.T) {
- bs := Chars{bytes: []byte{}}
- if bs.bytes == nil || bs.runes != nil {
- t.Error()
- }
- rs := RunesToChars([]rune{})
- if rs.bytes != nil || rs.runes == nil {
- t.Error()
- }
-}
-
func TestToCharsAscii(t *testing.T) {
chars := ToChars([]byte("foobar"))
- if chars.ToString() != "foobar" || chars.runes != nil {
+ if !chars.inBytes || chars.ToString() != "foobar" || !chars.inBytes {
t.Error()
}
}
func TestCharsLength(t *testing.T) {
chars := ToChars([]byte("\tabc한글 "))
- if chars.Length() != 8 || chars.TrimLength() != 5 {
+ if chars.inBytes || chars.Length() != 8 || chars.TrimLength() != 5 {
t.Error()
}
}
@@ -36,7 +25,7 @@ func TestCharsToString(t *testing.T) {
}
func TestTrimLength(t *testing.T) {
- check := func(str string, exp int) {
+ check := func(str string, exp uint16) {
chars := ToChars([]byte(str))
trimmed := chars.TrimLength()
if trimmed != exp {
@@ -61,7 +50,8 @@ func TestSplit(t *testing.T) {
input := ToChars([]byte(str))
result := input.Split(delim)
if len(result) != len(tokens) {
- t.Errorf("Invalid Split result for '%s': %d tokens found (expected %d): %s",
+ t.Errorf(
+ "Invalid Split result for '%s': %d tokens found (expected %d): %s",
str, len(result), len(tokens), result)
}
for idx, token := range tokens {