tags_test.go 566 B

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