diff options
| author | Junegunn Choi <junegunn.c@gmail.com> | 2016-08-14 01:53:06 +0900 |
|---|---|---|
| committer | Junegunn Choi <junegunn.c@gmail.com> | 2016-08-14 02:19:29 +0900 |
| commit | ddc7bb9064042a0d5da9546eaf6ff888dca63f0c (patch) | |
| tree | 0eb63cd7c0cdc221332496ca2ddf3dcfe3cbb876 /src/util/chars_test.go | |
| parent | 1d4057c20907b7d263d6f2b8cb4350a024859dfe (diff) | |
| download | fzf-ddc7bb9064042a0d5da9546eaf6ff888dca63f0c.tar.gz | |
[perf] Optimize AWK-style tokenizer for --nth
Approx. 50% less memory footprint and 40% improvement in query time
Diffstat (limited to 'src/util/chars_test.go')
| -rw-r--r-- | src/util/chars_test.go | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/util/chars_test.go b/src/util/chars_test.go index e42cfb7c..2cb6fc76 100644 --- a/src/util/chars_test.go +++ b/src/util/chars_test.go @@ -34,3 +34,24 @@ func TestCharsToString(t *testing.T) { t.Error() } } + +func TestTrimLength(t *testing.T) { + check := func(str string, exp int) { + chars := ToChars([]byte(str)) + trimmed := chars.TrimLength() + if trimmed != exp { + t.Errorf("Invalid TrimLength result for '%s': %d (expected %d)", + str, trimmed, exp) + } + } + check("hello", 5) + check("hello ", 5) + check("hello ", 5) + check(" hello", 5) + check(" hello", 5) + check(" hello ", 5) + check(" hello ", 5) + check("h o", 5) + check(" h o ", 5) + check(" ", 0) +} |
