| 1 | // Copyright 2016 Richard Gibson. All rights reserved. |
| 2 | // Copyright 2011 The Go Authors. All rights reserved. |
| 3 | // Use of this source code is governed by a BSD-style |
| 4 | // license that can be found in the LICENSE file. |
| 5 | |
| 6 | package canonicaljson |
| 7 | |
| 8 | import ( |
| 9 | "testing" |
| 10 | ) |
| 11 | |
| 12 | func TestTagParsing(t *testing.T) { |
| 13 | name, opts := parseTag("field,foobar,foo") |
| 14 | if name != "field" { |
| 15 | t.Fatalf("name = %q, want field", name) |
| 16 | } |
| 17 | for _, tt := range []struct { |
| 18 | opt string |
| 19 | want bool |
| 20 | }{ |
| 21 | {"foobar", true}, |
| 22 | {"foo", true}, |
| 23 | {"bar", false}, |
| 24 | } { |
| 25 | if opts.Contains(tt.opt) != tt.want { |
| 26 | t.Errorf("Contains(%q) = %v", tt.opt, !tt.want) |
| 27 | } |
| 28 | } |
| 29 | } |