aboutsummaryrefslogtreecommitdiffstats
path: root/plumbing/format/pktline
diff options
context:
space:
mode:
Diffstat (limited to 'plumbing/format/pktline')
-rw-r--r--plumbing/format/pktline/encoder_test.go37
-rw-r--r--plumbing/format/pktline/scanner_test.go31
2 files changed, 0 insertions, 68 deletions
diff --git a/plumbing/format/pktline/encoder_test.go b/plumbing/format/pktline/encoder_test.go
index 4a7c7b8..a6addd6 100644
--- a/plumbing/format/pktline/encoder_test.go
+++ b/plumbing/format/pktline/encoder_test.go
@@ -2,7 +2,6 @@ package pktline_test
import (
"bytes"
- "os"
"strings"
"testing"
@@ -211,39 +210,3 @@ func (s *SuiteEncoder) TestEncodef(c *C) {
expected := []byte("000c foo 42\n")
c.Assert(buf.Bytes(), DeepEquals, expected)
}
-
-func ExampleEncoder() {
- // Create an encoder that writes pktlines to stdout.
- e := pktline.NewEncoder(os.Stdout)
-
- // Encode some data as a new pkt-line.
- _ = e.Encode([]byte("data\n")) // error checks removed for brevity
-
- // Encode a flush-pkt.
- _ = e.Flush()
-
- // Encode a couple of byte slices and a flush in one go. Each of
- // them will end up as payloads of their own pktlines.
- _ = e.Encode(
- []byte("hello\n"),
- []byte("world!\n"),
- pktline.Flush,
- )
-
- // You can also encode strings:
- _ = e.EncodeString(
- "foo\n",
- "bar\n",
- pktline.FlushString,
- )
-
- // You can also format and encode a payload:
- _ = e.Encodef(" %s %d\n", "foo", 42)
- // Output:
- // 0009data
- // 0000000ahello
- // 000bworld!
- // 00000008foo
- // 0008bar
- // 0000000c foo 42
-}
diff --git a/plumbing/format/pktline/scanner_test.go b/plumbing/format/pktline/scanner_test.go
index 479ad77..60b6224 100644
--- a/plumbing/format/pktline/scanner_test.go
+++ b/plumbing/format/pktline/scanner_test.go
@@ -217,34 +217,3 @@ func sectionsExample(c *C, nSections, nLines int) io.Reader {
return &buf
}
-
-func ExampleScanner() {
- // A reader is needed as input.
- input := strings.NewReader("000ahello\n" +
- "000bworld!\n" +
- "0000",
- )
-
- // Create the scanner...
- s := pktline.NewScanner(input)
-
- // and scan every pkt-line found in the input.
- for s.Scan() {
- payload := s.Bytes()
- if len(payload) == 0 { // zero sized payloads correspond to flush-pkts.
- fmt.Println("FLUSH-PKT DETECTED")
- } else { // otherwise, you will be able to access the full payload.
- fmt.Printf("PAYLOAD = %q\n", string(payload))
- }
- }
-
- // this will catch any error when reading from the input, if any.
- if s.Err() != nil {
- fmt.Println(s.Err())
- }
-
- // Output:
- // PAYLOAD = "hello\n"
- // PAYLOAD = "world!\n"
- // FLUSH-PKT DETECTED
-}