diff options
| author | Shulhan <ms@kilabit.info> | 2025-02-06 01:46:56 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2025-04-18 13:59:35 +0700 |
| commit | 503934b176c42eb9fed7bfa3c4c8823a0c037517 (patch) | |
| tree | 76f26a8b797ded62dc49f36cde4180d8ed7b5b7b | |
| parent | 5277331521768c9339093d52cf961376db773050 (diff) | |
| download | pakakeh.go-503934b176c42eb9fed7bfa3c4c8823a0c037517.tar.xz | |
lib/bytes: complete the SkipLine example until the end
This is to see the return value when no token can be parsed
and to make the test coverage become 100%.
| -rw-r--r-- | lib/bytes/parser_example_test.go | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/lib/bytes/parser_example_test.go b/lib/bytes/parser_example_test.go index 2a1c6d8c..b6582542 100644 --- a/lib/bytes/parser_example_test.go +++ b/lib/bytes/parser_example_test.go @@ -1,3 +1,7 @@ +// SPDX-FileCopyrightText: 2023 M. Shulhan <ms@kilabit.info> +// +// SPDX-License-Identifier: BSD-3-Clause + package bytes_test import ( @@ -219,15 +223,21 @@ func ExampleParser_SkipLine() { ) parser.SkipLine() - token, _ := parser.Read() - fmt.Printf("token:'%s'\n", token) + token, c := parser.Read() + fmt.Printf("token=%q c=%q\n", token, c) parser.SkipLine() - token, _ = parser.Read() - fmt.Printf("token:'%s'\n", token) + token, c = parser.Read() + fmt.Printf("token=%q c=%q\n", token, c) + + parser.SkipLine() + token, c = parser.Read() + fmt.Printf("token=%q c=%q\n", token, c) + // Output: - // token:'b' - // token:'d e' + // token="b" c='\n' + // token="d e" c='\n' + // token="" c='\x00' } func ExampleParser_SkipN() { |
