...

Source file src/github.com/magiconair/properties/assert/assert_test.go

Documentation: github.com/magiconair/properties/assert

     1  // Copyright 2013-2022 Frank Schroeder. 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 assert
     6  
     7  import "testing"
     8  
     9  func TestEqualEquals(t *testing.T) {
    10  	if got, want := equal(2, "a", "a"), ""; got != want {
    11  		t.Fatalf("got %q want %q", got, want)
    12  	}
    13  }
    14  
    15  func TestEqualFails(t *testing.T) {
    16  	if got, want := equal(2, "a", "b"), "\tassert_test.go:16: got a want b \n"; got != want {
    17  		t.Fatalf("got %q want %q", got, want)
    18  	}
    19  }
    20  
    21  func TestPanicPanics(t *testing.T) {
    22  	if got, want := doesPanic(2, func() { panic("foo") }, ""), ""; got != want {
    23  		t.Fatalf("got %q want %q", got, want)
    24  	}
    25  }
    26  
    27  func TestPanicPanicsAndMatches(t *testing.T) {
    28  	if got, want := doesPanic(2, func() { panic("foo") }, "foo"), ""; got != want {
    29  		t.Fatalf("got %q want %q", got, want)
    30  	}
    31  }
    32  
    33  func TestPanicPanicsAndDoesNotMatch(t *testing.T) {
    34  	if got, want := doesPanic(2, func() { panic("foo") }, "bar"), "\tassert.go:62: got foo which does not match bar\n"; got != want {
    35  		t.Fatalf("got %q want %q", got, want)
    36  	}
    37  }
    38  
    39  func TestPanicPanicsAndDoesNotPanic(t *testing.T) {
    40  	if got, want := doesPanic(2, func() {}, "bar"), "\tassert.go:65: did not panic\n"; got != want {
    41  		t.Fatalf("got %q want %q", got, want)
    42  	}
    43  }
    44  
    45  func TestMatchesMatches(t *testing.T) {
    46  	if got, want := matches(2, "aaa", "a"), ""; got != want {
    47  		t.Fatalf("got %q want %q", got, want)
    48  	}
    49  }
    50  
    51  func TestMatchesDoesNotMatch(t *testing.T) {
    52  	if got, want := matches(2, "aaa", "b"), "\tassert_test.go:52: got aaa which does not match b\n"; got != want {
    53  		t.Fatalf("got %q want %q", got, want)
    54  	}
    55  }
    56  

View as plain text