Source file src/go/types/errors_test.go

     1  // Code generated by "go test -run=Generate -write=all"; DO NOT EDIT.
     2  // Source: ../../cmd/compile/internal/types2/errors_test.go
     3  
     4  // Copyright 2020 The Go Authors. All rights reserved.
     5  // Use of this source code is governed by a BSD-style
     6  // license that can be found in the LICENSE file.
     7  
     8  package types
     9  
    10  import "testing"
    11  
    12  func TestError(t *testing.T) {
    13  	var err error_
    14  	want := "no error"
    15  	if got := err.msg(); got != want {
    16  		t.Errorf("empty error: got %q, want %q", got, want)
    17  	}
    18  
    19  	want = "foo 42"
    20  	err.addf(noposn, "foo %d", 42)
    21  	if got := err.msg(); got != want {
    22  		t.Errorf("simple error: got %q, want %q", got, want)
    23  	}
    24  
    25  	want = "foo 42\n\tbar 43"
    26  	err.addf(noposn, "bar %d", 43)
    27  	if got := err.msg(); got != want {
    28  		t.Errorf("simple error: got %q, want %q", got, want)
    29  	}
    30  }
    31  
    32  func TestStripAnnotations(t *testing.T) {
    33  	for _, test := range []struct {
    34  		in, want string
    35  	}{
    36  		{"", ""},
    37  		{"   ", "   "},
    38  		{"foo", "foo"},
    39  		{"foo₀", "foo"},
    40  		{"foo(T₀)", "foo(T)"},
    41  	} {
    42  		got := stripAnnotations(test.in)
    43  		if got != test.want {
    44  			t.Errorf("%q: got %q; want %q", test.in, got, test.want)
    45  		}
    46  	}
    47  }
    48  

View as plain text