Source file src/encoding/json/tags_test.go

     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  
     5  package json
     6  
     7  import "testing"
     8  
     9  func TestTagParsing(t *testing.T) {
    10  	name, opts := parseTag("field,foobar,foo")
    11  	if name != "field" {
    12  		t.Fatalf("name = %q, want field", name)
    13  	}
    14  	for _, tt := range []struct {
    15  		opt  string
    16  		want bool
    17  	}{
    18  		{"foobar", true},
    19  		{"foo", true},
    20  		{"bar", false},
    21  	} {
    22  		if opts.Contains(tt.opt) != tt.want {
    23  			t.Errorf("Contains(%q) = %v, want %v", tt.opt, !tt.want, tt.want)
    24  		}
    25  	}
    26  }
    27  

View as plain text