diff options
| author | Shulhan <ms@kilabit.info> | 2023-04-10 20:27:00 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2023-04-13 01:30:56 +0700 |
| commit | 2409f21063c5aeff7fc8cf4ba703ee07bd797bee (patch) | |
| tree | 3bbfb1b4461c1e6913b931080319f4e72397e8c8 /lib/bytes/parser_test.go | |
| parent | 5120d36fdb9e374cb77f7aa21f7caca170d0a4b8 (diff) | |
| download | pakakeh.go-2409f21063c5aeff7fc8cf4ba703ee07bd797bee.tar.xz | |
lib/bytes: move unit Test for Read and SkipLine to Example
Using an example not only test the code but also provide example snippet
when opened in the godoc.
Diffstat (limited to 'lib/bytes/parser_test.go')
| -rw-r--r-- | lib/bytes/parser_test.go | 77 |
1 files changed, 0 insertions, 77 deletions
diff --git a/lib/bytes/parser_test.go b/lib/bytes/parser_test.go deleted file mode 100644 index 4df84830..00000000 --- a/lib/bytes/parser_test.go +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright 2023, Shulhan <ms@kilabit.info>. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package bytes - -import ( - "testing" - - "github.com/shuLhan/share/lib/test" -) - -func TestParserRead(t *testing.T) { - type testCase struct { - expToken []byte - expDelim byte - } - - var ( - parser = NewParser([]byte("a b\tc"), []byte(" \t")) - - cases = []testCase{{ - expToken: []byte(`a`), - expDelim: ' ', - }, { - expToken: []byte(`b`), - expDelim: '\t', - }, { - expToken: []byte(`c`), - expDelim: 0, - }, { - // empty. - }} - - c testCase - token []byte - d byte - ) - - for _, c = range cases { - token, d = parser.Read() - test.Assert(t, `token`, c.expToken, token) - test.Assert(t, `delimiter`, c.expDelim, d) - } -} - -func TestParserSkipLine(t *testing.T) { - type testCase struct { - expToken []byte - expDelim byte - } - - var ( - parser = NewParser([]byte("a\nb\nc\nd e\n"), []byte("\n")) - - cases = []testCase{{ - expToken: []byte(`b`), - expDelim: '\n', - }, { - expToken: []byte(`d e`), - expDelim: '\n', - }, { - // empty. - }} - - c testCase - token []byte - d byte - ) - - for _, c = range cases { - parser.SkipLine() - token, d = parser.Read() - test.Assert(t, `token`, c.expToken, token) - test.Assert(t, `delimiter`, c.expDelim, d) - } -} |
