1 // Copyright 2012 Google, Inc. All rights reserved.
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
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 {
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},
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)
36 if !test.err && !reflect.DeepEqual(test.want, got) {
37 t.Errorf("%d opts mismatch, want\n%#v", i, test.want)