go tags_test 源码

  • 2022-07-15
  • 浏览 (864)

golang tags_test 代码

文件路径:/src/encoding/json/tags_test.go

// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package json

import (
	"testing"
)

func TestTagParsing(t *testing.T) {
	name, opts := parseTag("field,foobar,foo")
	if name != "field" {
		t.Fatalf("name = %q, want field", name)
	}
	for _, tt := range []struct {
		opt  string
		want bool
	}{
		{"foobar", true},
		{"foo", true},
		{"bar", false},
	} {
		if opts.Contains(tt.opt) != tt.want {
			t.Errorf("Contains(%q) = %v", tt.opt, !tt.want)
		}
	}
}

相关信息

go 源码目录

相关文章

go bench_test 源码

go decode 源码

go decode_test 源码

go encode 源码

go encode_test 源码

go example_marshaling_test 源码

go example_test 源码

go example_text_marshaling_test 源码

go fold 源码

go fold_test 源码

0  赞