github.com/mtsmfm/go/src@v0.0.0-20221020090648-44bdcb9f8fde/internal/godebug/godebug_test.go (about)

     1  // Copyright 2021 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 godebug_test
     6  
     7  import (
     8  	. "internal/godebug"
     9  	"testing"
    10  )
    11  
    12  func TestGet(t *testing.T) {
    13  	tests := []struct {
    14  		godebug string
    15  		key     string
    16  		want    string
    17  	}{
    18  		{"", "", ""},
    19  		{"", "foo", ""},
    20  		{"foo=bar", "foo", "bar"},
    21  		{"foo=bar,after=x", "foo", "bar"},
    22  		{"before=x,foo=bar,after=x", "foo", "bar"},
    23  		{"before=x,foo=bar", "foo", "bar"},
    24  		{",,,foo=bar,,,", "foo", "bar"},
    25  		{"foodecoy=wrong,foo=bar", "foo", "bar"},
    26  		{"foo=", "foo", ""},
    27  		{"foo", "foo", ""},
    28  		{",foo", "foo", ""},
    29  		{"foo=bar,baz", "loooooooong", ""},
    30  	}
    31  	for _, tt := range tests {
    32  		got := Xget(tt.godebug, tt.key)
    33  		if got != tt.want {
    34  			t.Errorf("get(%q, %q) = %q; want %q", tt.godebug, tt.key, got, tt.want)
    35  		}
    36  	}
    37  }