From 503934b176c42eb9fed7bfa3c4c8823a0c037517 Mon Sep 17 00:00:00 2001 From: Shulhan Date: Thu, 6 Feb 2025 01:46:56 +0700 Subject: 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%. --- lib/bytes/parser_example_test.go | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'lib/bytes/parser_example_test.go') 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 +// +// 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() { -- cgit v1.3