mirror of https://github.com/v2ray/v2ray-core
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
728 B
43 lines
728 B
package assert
|
|
|
|
import (
|
|
"strconv"
|
|
)
|
|
|
|
// Assert on a boolean variable.
|
|
func (v *Assert) Bool(value bool) *BoolSubject {
|
|
return &BoolSubject{
|
|
Subject: Subject{
|
|
disp: strconv.FormatBool(value),
|
|
a: v,
|
|
},
|
|
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")
|
|
}
|
|
}
|