1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00
moby--moby/vendor/github.com/vdemeester/shakers/bool.go
Alexander Morozov f2614f2107 project: use vndr for vendoring
Signed-off-by: Alexander Morozov <lk4d4@docker.com>
2016-11-03 15:31:46 -07:00

46 lines
882 B
Go

package shakers
import (
"github.com/go-check/check"
)
// True checker verifies the obtained value is true
//
// c.Assert(myBool, True)
//
var True check.Checker = &boolChecker{
&check.CheckerInfo{
Name: "True",
Params: []string{"obtained"},
},
true,
}
// False checker verifies the obtained value is false
//
// c.Assert(myBool, False)
//
var False check.Checker = &boolChecker{
&check.CheckerInfo{
Name: "False",
Params: []string{"obtained"},
},
false,
}
type boolChecker struct {
*check.CheckerInfo
expected bool
}
func (checker *boolChecker) Check(params []interface{}, names []string) (bool, string) {
return is(checker.expected, params[0])
}
func is(expected bool, obtained interface{}) (bool, string) {
obtainedBool, ok := obtained.(bool)
if !ok {
return false, "obtained value must be a bool."
}
return obtainedBool == expected, ""
}