aboutsummaryrefslogtreecommitdiff
path: root/vendor/golang.org/x/net/ipv6/header_test.go
diff options
context:
space:
mode:
authorGravatar Frédéric Guillot <fred@miniflux.net> 2017-11-19 21:10:04 -0800
committerGravatar Frédéric Guillot <fred@miniflux.net> 2017-11-19 22:01:46 -0800
commit8ffb773f43c8dc54801ca1d111854e7e881c93c9 (patch)
tree38133a2fc612597a75fed1d13e5b4042f58a2b7e /vendor/golang.org/x/net/ipv6/header_test.go
downloadv2-8ffb773f43c8dc54801ca1d111854e7e881c93c9.tar.gz
v2-8ffb773f43c8dc54801ca1d111854e7e881c93c9.tar.zst
v2-8ffb773f43c8dc54801ca1d111854e7e881c93c9.zip
First commit
Diffstat (limited to 'vendor/golang.org/x/net/ipv6/header_test.go')
-rw-r--r--vendor/golang.org/x/net/ipv6/header_test.go55
1 files changed, 55 insertions, 0 deletions
diff --git a/vendor/golang.org/x/net/ipv6/header_test.go b/vendor/golang.org/x/net/ipv6/header_test.go
new file mode 100644
index 00000000..ca11dc23
--- /dev/null
+++ b/vendor/golang.org/x/net/ipv6/header_test.go
@@ -0,0 +1,55 @@
+// Copyright 2014 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package ipv6_test
+
+import (
+ "net"
+ "reflect"
+ "strings"
+ "testing"
+
+ "golang.org/x/net/internal/iana"
+ "golang.org/x/net/ipv6"
+)
+
+var (
+ wireHeaderFromKernel = [ipv6.HeaderLen]byte{
+ 0x69, 0x8b, 0xee, 0xf1,
+ 0xca, 0xfe, 0x2c, 0x01,
+ 0x20, 0x01, 0x0d, 0xb8,
+ 0x00, 0x01, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x01,
+ 0x20, 0x01, 0x0d, 0xb8,
+ 0x00, 0x02, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x01,
+ }
+
+ testHeader = &ipv6.Header{
+ Version: ipv6.Version,
+ TrafficClass: iana.DiffServAF43,
+ FlowLabel: 0xbeef1,
+ PayloadLen: 0xcafe,
+ NextHeader: iana.ProtocolIPv6Frag,
+ HopLimit: 1,
+ Src: net.ParseIP("2001:db8:1::1"),
+ Dst: net.ParseIP("2001:db8:2::1"),
+ }
+)
+
+func TestParseHeader(t *testing.T) {
+ h, err := ipv6.ParseHeader(wireHeaderFromKernel[:])
+ if err != nil {
+ t.Fatal(err)
+ }
+ if !reflect.DeepEqual(h, testHeader) {
+ t.Fatalf("got %#v; want %#v", h, testHeader)
+ }
+ s := h.String()
+ if strings.Contains(s, ",") {
+ t.Fatalf("should be space-separated values: %s", s)
+ }
+}