aboutsummaryrefslogtreecommitdiff
path: root/lib/bytes/parser_example_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'lib/bytes/parser_example_test.go')
-rw-r--r--lib/bytes/parser_example_test.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/bytes/parser_example_test.go b/lib/bytes/parser_example_test.go
index c62258fe..a30bda5a 100644
--- a/lib/bytes/parser_example_test.go
+++ b/lib/bytes/parser_example_test.go
@@ -37,6 +37,24 @@ func ExampleParser_Delimiters() {
// =;
}
+func ExampleParser_ReadLine() {
+ var (
+ content = []byte("a=b;\nc=d;")
+ delims = []byte{'=', ';'}
+ parser = libbytes.NewParser(content, delims)
+ )
+
+ token, c := parser.ReadLine()
+ fmt.Printf("token:%s c:%d\n", token, c)
+
+ token, c = parser.ReadLine()
+ fmt.Printf("token:%s c:%d\n", token, c)
+
+ // Output:
+ // token:a=b; c:10
+ // token:c=d; c:0
+}
+
func ExampleParser_ReadN() {
var (
content = []byte(`a=b;c=d;`)