-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathassert_true.go
57 lines (46 loc) · 1.12 KB
/
assert_true.go
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
package actually
import (
"reflect"
"testing"
)
// True method asserts that a test data you got is true value of boolean type.
/*
actually.Got(true).True(t) // Truly pass
*/
func (a *testingA) True(t *testing.T, testNames ...string) *testingA {
invalidCall(a)
a.name = a.naming(testNames...)
a.t = t
a.t.Helper()
if !a.isBool() {
wi := a.wi().Got(a.got).Message(notice_Label, "It should be boolean")
return a.fail(wi, reason_WrongType)
}
if a.got != true {
return a.fail(a.wi().Got(a.got), message_ExpectTrue)
}
return a
}
// False method asserts that a test data you got is false value of boolean type.
/*
actually.Got(false).False(t) // pass
*/
func (a *testingA) False(t *testing.T, testNames ...string) *testingA {
invalidCall(a)
a.name = a.naming(testNames...)
a.t = t
a.t.Helper()
if !a.isBool() {
wi := a.wi().Got(a.got).Message(notice_Label, "It should be boolean")
return a.fail(wi, reason_WrongType)
}
if a.got != false {
return a.fail(a.wi().Got(a.got), message_ExpectFalse)
}
return a
}
func (a *testingA) isBool() bool {
v := reflect.ValueOf(a.got)
k := v.Kind()
return k == reflect.Bool
}