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