aboutsummaryrefslogtreecommitdiff
path: root/lib/bytes/bytes_example_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'lib/bytes/bytes_example_test.go')
-rw-r--r--lib/bytes/bytes_example_test.go16
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/bytes/bytes_example_test.go b/lib/bytes/bytes_example_test.go
index 314275d2..da8dcce2 100644
--- a/lib/bytes/bytes_example_test.go
+++ b/lib/bytes/bytes_example_test.go
@@ -351,6 +351,22 @@ func ExampleSnippetByIndexes() {
// reserved.
}
+func ExampleSplitEach() {
+ var data = []byte(`Hello`)
+
+ fmt.Printf("%s\n", SplitEach(data, 0))
+ fmt.Printf("%s\n", SplitEach(data, 1))
+ fmt.Printf("%s\n", SplitEach(data, 2))
+ fmt.Printf("%s\n", SplitEach(data, 5))
+ fmt.Printf("%s\n", SplitEach(data, 10))
+ // Output:
+ // [Hello]
+ // [H e l l o]
+ // [He ll o]
+ // [Hello]
+ // [Hello]
+}
+
func ExampleTokenFind() {
text := []byte("// Copyright 2018, Shulhan <ms@kilabit.info>. All rights reserved.")