2016-05-24 15:55:46 -04:00
|
|
|
package assert
|
|
|
|
|
|
|
|
import (
|
|
|
|
"strconv"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Assert on a boolean variable.
|
2016-11-27 15:39:09 -05:00
|
|
|
func (v *Assert) Bool(value bool) *BoolSubject {
|
2016-05-24 15:55:46 -04:00
|
|
|
return &BoolSubject{
|
|
|
|
Subject: Subject{
|
|
|
|
disp: strconv.FormatBool(value),
|
2016-11-27 15:39:09 -05:00
|
|
|
a: v,
|
2016-05-24 15:55:46 -04:00
|
|
|
},
|
|
|
|
value: value,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
type BoolSubject struct {
|
|
|
|
Subject
|
|
|
|
value bool
|
|
|
|
}
|
|
|
|
|
|
|
|
// to be equal to another boolean variable.
|
|
|
|
func (subject *BoolSubject) Equals(expectation bool) {
|
|
|
|
if subject.value != expectation {
|
|
|
|
subject.Fail("is equal to", strconv.FormatBool(expectation))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// to be true.
|
|
|
|
func (subject *BoolSubject) IsTrue() {
|
|
|
|
if subject.value != true {
|
|
|
|
subject.Fail("is", "True")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// to be false.
|
|
|
|
func (subject *BoolSubject) IsFalse() {
|
|
|
|
if subject.value != false {
|
|
|
|
subject.Fail("is", "False")
|
|
|
|
}
|
|
|
|
}
|