| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
package oglematchers_test |
| 17 |
|
| 18 |
import ( |
| 19 |
"fmt" |
| 20 |
"testing" |
| 21 |
"time" |
| 22 |
|
| 23 |
. "github.com/jacobsa/oglematchers" |
| 24 |
. "github.com/jacobsa/ogletest" |
| 25 |
) |
| 26 |
|
| 27 |
func TestPassingTest(t *testing.T) { RunTests(t) } |
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
type PassingTest struct { |
| 34 |
} |
| 35 |
|
| 36 |
func init() { RegisterTestSuite(&PassingTest{}) } |
| 37 |
|
| 38 |
func (t *PassingTest) EmptyTestMethod() { |
| 39 |
} |
| 40 |
|
| 41 |
func (t *PassingTest) SuccessfullMatches() { |
| 42 |
ExpectThat(17, Equals(17.0)) |
| 43 |
ExpectThat(16.9, LessThan(17)) |
| 44 |
ExpectThat("taco", HasSubstr("ac")) |
| 45 |
|
| 46 |
AssertThat(17, Equals(17.0)) |
| 47 |
AssertThat(16.9, LessThan(17)) |
| 48 |
AssertThat("taco", HasSubstr("ac")) |
| 49 |
} |
| 50 |
|
| 51 |
func (t *PassingTest) ExpectAliases() { |
| 52 |
ExpectEq(17, 17.0) |
| 53 |
|
| 54 |
ExpectLe(17, 17.0) |
| 55 |
ExpectLe(17, 18.0) |
| 56 |
ExpectLt(17, 18.0) |
| 57 |
|
| 58 |
ExpectGe(17, 17.0) |
| 59 |
ExpectGe(17, 16.0) |
| 60 |
ExpectGt(17, 16.0) |
| 61 |
|
| 62 |
ExpectNe(17, 18.0) |
| 63 |
|
| 64 |
ExpectTrue(true) |
| 65 |
ExpectFalse(false) |
| 66 |
} |
| 67 |
|
| 68 |
func (t *PassingTest) AssertAliases() { |
| 69 |
AssertEq(17, 17.0) |
| 70 |
|
| 71 |
AssertLe(17, 17.0) |
| 72 |
AssertLe(17, 18.0) |
| 73 |
AssertLt(17, 18.0) |
| 74 |
|
| 75 |
AssertGe(17, 17.0) |
| 76 |
AssertGe(17, 16.0) |
| 77 |
AssertGt(17, 16.0) |
| 78 |
|
| 79 |
AssertNe(17, 18.0) |
| 80 |
|
| 81 |
AssertTrue(true) |
| 82 |
AssertFalse(false) |
| 83 |
} |
| 84 |
|
| 85 |
func (t *PassingTest) SlowTest() { |
| 86 |
time.Sleep(37 * time.Millisecond) |
| 87 |
} |
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
type PassingTestWithHelpers struct { |
| 94 |
} |
| 95 |
|
| 96 |
var _ SetUpTestSuiteInterface = &PassingTestWithHelpers{} |
| 97 |
var _ SetUpInterface = &PassingTestWithHelpers{} |
| 98 |
var _ TearDownInterface = &PassingTestWithHelpers{} |
| 99 |
var _ TearDownTestSuiteInterface = &PassingTestWithHelpers{} |
| 100 |
|
| 101 |
func init() { RegisterTestSuite(&PassingTestWithHelpers{}) } |
| 102 |
|
| 103 |
func (t *PassingTestWithHelpers) SetUpTestSuite() { |
| 104 |
fmt.Println("SetUpTestSuite ran.") |
| 105 |
} |
| 106 |
|
| 107 |
func (t *PassingTestWithHelpers) SetUp(ti *TestInfo) { |
| 108 |
fmt.Println("SetUp ran.") |
| 109 |
} |
| 110 |
|
| 111 |
func (t *PassingTestWithHelpers) TearDown() { |
| 112 |
fmt.Println("TearDown ran.") |
| 113 |
} |
| 114 |
|
| 115 |
func (t *PassingTestWithHelpers) TearDownTestSuite() { |
| 116 |
fmt.Println("TearDownTestSuite ran.") |
| 117 |
} |
| 118 |
|
| 119 |
func (t *PassingTestWithHelpers) EmptyTestMethod() { |
| 120 |
} |