-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcore_test.go
More file actions
72 lines (62 loc) · 1.55 KB
/
core_test.go
File metadata and controls
72 lines (62 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package testingExtensions_test
import (
"testing"
"github.com/eviltofu/testingExtensions"
)
func TestBoolAssertTruePass(t *testing.T) {
tT := new(testing.T)
testUnit := testingExtensions.TestUnit{T: tT}
testUnit.AssertTrue(true)
expectPass(tT, t)
}
func TestBoolAssertTrueFail(t *testing.T) {
tT := new(testing.T)
testUnit := testingExtensions.TestUnit{T: tT}
testUnit.AssertTrue(false)
expectFail(tT, t)
}
func TestBoolAssertFalsePass(t *testing.T) {
tT := new(testing.T)
testUnit := testingExtensions.TestUnit{T: tT}
testUnit.AssertFalse(false)
expectPass(tT, t)
}
func TestBoolAssertFalseFail(t *testing.T) {
tT := new(testing.T)
testUnit := testingExtensions.TestUnit{T: tT}
testUnit.AssertFalse(true)
expectFail(tT, t)
}
func TestBoolAssertEqual(t *testing.T) {
type data struct {
first, second bool
pass bool
}
testData := []data{
data{first: true, second: true, pass: true},
data{first: true, second: false, pass: false},
data{first: false, second: true, pass: false},
data{first: false, second: false, pass: true}}
for _, value := range testData {
tT := new(testing.T)
testUnit := testingExtensions.TestUnit{T: tT}
testUnit.AssertBoolEqual(value.first, value.second)
switch value.pass {
case true:
expectPass(tT, t)
case false:
expectFail(tT, t)
}
}
}
// Private functions
func expectPass(tT *testing.T, t *testing.T) {
if tT.Failed() != false {
t.Error("Expected pass but got fail")
}
}
func expectFail(tT *testing.T, t *testing.T) {
if tT.Failed() != true {
t.Error("Expected fail but got pass")
}
}