From 9e85cba0d06025983a1a747bfc06c9955388d9c0 Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Sun, 16 Jul 2017 23:31:19 +0900 Subject: Reduce memory footprint of Item struct --- src/util/chars_test.go | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) (limited to 'src/util/chars_test.go') 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 { -- cgit v1.2.3