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.
46 lines
931 B
46 lines
931 B
9 years ago
|
package assert
|
||
9 years ago
|
|
||
|
import (
|
||
|
"strconv"
|
||
|
)
|
||
|
|
||
9 years ago
|
func Bool(value bool) *BoolSubject {
|
||
|
return &BoolSubject{value: value}
|
||
9 years ago
|
}
|
||
|
|
||
9 years ago
|
type BoolSubject struct {
|
||
|
Subject
|
||
|
value bool
|
||
9 years ago
|
}
|
||
|
|
||
|
func (subject *BoolSubject) Named(name string) *BoolSubject {
|
||
|
subject.Subject.Named(name)
|
||
|
return subject
|
||
|
}
|
||
|
|
||
|
func (subject *BoolSubject) Fail(verb string, other bool) {
|
||
|
subject.FailWithMessage("Not true that " + subject.DisplayString() + " " + verb + " <" + strconv.FormatBool(other) + ">.")
|
||
|
}
|
||
|
|
||
|
func (subject *BoolSubject) DisplayString() string {
|
||
|
return subject.Subject.DisplayString(strconv.FormatBool(subject.value))
|
||
|
}
|
||
|
|
||
|
func (subject *BoolSubject) Equals(expectation bool) {
|
||
|
if subject.value != expectation {
|
||
|
subject.Fail("is equal to", expectation)
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func (subject *BoolSubject) IsTrue() {
|
||
|
if subject.value != true {
|
||
|
subject.Fail("is", true)
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func (subject *BoolSubject) IsFalse() {
|
||
|
if subject.value != false {
|
||
|
subject.Fail("is", false)
|
||
|
}
|
||
|
}
|