go godebug_test 源码

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

golang godebug_test 代码

文件路径:/src/internal/godebug/godebug_test.go

// Copyright 2021 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 godebug

import "testing"

func TestGet(t *testing.T) {
	tests := []struct {
		godebug string
		key     string
		want    string
	}{
		{"", "", ""},
		{"", "foo", ""},
		{"foo=bar", "foo", "bar"},
		{"foo=bar,after=x", "foo", "bar"},
		{"before=x,foo=bar,after=x", "foo", "bar"},
		{"before=x,foo=bar", "foo", "bar"},
		{",,,foo=bar,,,", "foo", "bar"},
		{"foodecoy=wrong,foo=bar", "foo", "bar"},
		{"foo=", "foo", ""},
		{"foo", "foo", ""},
		{",foo", "foo", ""},
		{"foo=bar,baz", "loooooooong", ""},
	}
	for _, tt := range tests {
		got := get(tt.godebug, tt.key)
		if got != tt.want {
			t.Errorf("get(%q, %q) = %q; want %q", tt.godebug, tt.key, got, tt.want)
		}
	}
}

相关信息

go 源码目录

相关文章

go godebug 源码

0  赞