1 // Copyright 2017 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.
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)
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)
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)
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)
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)
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)
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)
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)