added support for string type
[govpp.git] / vendor / github.com / google / gopacket / afpacket / afpacket_test.go
1 // Copyright 2012 Google, Inc. All rights reserved.
2 //
3 // Use of this source code is governed by a BSD-style license
4 // that can be found in the LICENSE file in the root of the source
5 // tree.
6
7 // +build linux
8
9 package afpacket
10
11 import (
12         "reflect"
13         "testing"
14 )
15
16 func TestParseOptions(t *testing.T) {
17         wanted1 := defaultOpts
18         wanted1.frameSize = 1 << 10
19         wanted1.framesPerBlock = wanted1.blockSize / wanted1.frameSize
20         for i, test := range []struct {
21                 opts []interface{}
22                 want options
23                 err  bool
24         }{
25                 {opts: []interface{}{OptBlockSize(2)}, err: true},
26                 {opts: []interface{}{OptFrameSize(333)}, err: true},
27                 {opts: []interface{}{OptTPacketVersion(-3)}, err: true},
28                 {opts: []interface{}{OptTPacketVersion(5)}, err: true},
29                 {opts: []interface{}{OptFrameSize(1 << 10)}, want: wanted1},
30         } {
31                 got, err := parseOptions(test.opts...)
32                 t.Logf("got: %#v\nerr: %v", got, err)
33                 if test.err && err == nil || !test.err && err != nil {
34                         t.Errorf("%d error mismatch, want error? %v.  error: %v", i, test.err, err)
35                 }
36                 if !test.err && !reflect.DeepEqual(test.want, got) {
37                         t.Errorf("%d opts mismatch, want\n%#v", i, test.want)
38                 }
39         }
40 }