本文整理汇总了Golang中gobot/io/x/gobot/gobottest.Refute函数的典型用法代码示例。如果您正苦于以下问题:Golang Refute函数的具体用法?Golang Refute怎么用?Golang Refute使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Refute函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestUtils
func TestUtils(t *testing.T) {
_, currentfile, _, _ := runtime.Caller(0)
image := cv.LoadImage(path.Join(path.Dir(currentfile), "lena-256x256.jpg"))
rect := DetectFaces("haarcascade_frontalface_alt.xml", image)
gobottest.Refute(t, len(rect), 0)
gobottest.Refute(t, DrawRectangles(image, rect, 0, 0, 0, 0), nil)
}
示例2: TestMcp
func TestMcp(t *testing.T) {
a := initTestAPI()
request, _ := http.NewRequest("GET", "/api/", nil)
response := httptest.NewRecorder()
a.ServeHTTP(response, request)
var body map[string]interface{}
json.NewDecoder(response.Body).Decode(&body)
gobottest.Refute(t, body["MCP"].(map[string]interface{})["robots"], nil)
gobottest.Refute(t, body["MCP"].(map[string]interface{})["commands"], nil)
}
示例3: TestDirectPinDriverPwmWrite
func TestDirectPinDriverPwmWrite(t *testing.T) {
d := initTestDirectPinDriver(newGpioTestAdaptor())
gobottest.Refute(t, d.PwmWrite(1), nil)
d = initTestDirectPinDriver(&gpioTestBareAdaptor{})
gobottest.Assert(t, d.PwmWrite(1), ErrPwmWriteUnsupported)
}
示例4: TestLedDriver
func TestLedDriver(t *testing.T) {
var err interface{}
d := initTestLedDriver(newGpioTestAdaptor())
gobottest.Assert(t, d.Pin(), "1")
gobottest.Refute(t, d.Connection(), nil)
testAdaptorDigitalWrite = func() (err error) {
return errors.New("write error")
}
testAdaptorPwmWrite = func() (err error) {
return errors.New("pwm error")
}
err = d.Command("Toggle")(nil)
gobottest.Assert(t, err.(error), errors.New("write error"))
err = d.Command("On")(nil)
gobottest.Assert(t, err.(error), errors.New("write error"))
err = d.Command("Off")(nil)
gobottest.Assert(t, err.(error), errors.New("write error"))
err = d.Command("Brightness")(map[string]interface{}{"level": 100.0})
gobottest.Assert(t, err.(error), errors.New("pwm error"))
}
示例5: TestButtonDriver
func TestButtonDriver(t *testing.T) {
d := NewButtonDriver(newGpioTestAdaptor(), "1")
gobottest.Refute(t, d.Connection(), nil)
d = NewButtonDriver(newGpioTestAdaptor(), "1", 30*time.Second)
gobottest.Assert(t, d.interval, 30*time.Second)
}
示例6: TestRgbLedDriver
func TestRgbLedDriver(t *testing.T) {
var err interface{}
d := initTestRgbLedDriver(newGpioTestAdaptor())
gobottest.Assert(t, d.Pin(), "r=1, g=2, b=3")
gobottest.Assert(t, d.RedPin(), "1")
gobottest.Assert(t, d.GreenPin(), "2")
gobottest.Assert(t, d.BluePin(), "3")
gobottest.Refute(t, d.Connection(), nil)
testAdaptorDigitalWrite = func() (err error) {
return errors.New("write error")
}
testAdaptorPwmWrite = func() (err error) {
return errors.New("pwm error")
}
err = d.Command("Toggle")(nil)
gobottest.Assert(t, err.(error), errors.New("pwm error"))
err = d.Command("On")(nil)
gobottest.Assert(t, err.(error), errors.New("pwm error"))
err = d.Command("Off")(nil)
gobottest.Assert(t, err.(error), errors.New("pwm error"))
err = d.Command("SetRGB")(map[string]interface{}{"r": 0xff, "g": 0xff, "b": 0xff})
gobottest.Assert(t, err.(error), errors.New("pwm error"))
}
示例7: TestServoDriver
func TestServoDriver(t *testing.T) {
var err interface{}
d := initTestServoDriver()
gobottest.Assert(t, d.Pin(), "1")
gobottest.Refute(t, d.Connection(), nil)
testAdaptorServoWrite = func() (err error) {
return errors.New("pwm error")
}
err = d.Command("Min")(nil)
gobottest.Assert(t, err.(error), errors.New("pwm error"))
err = d.Command("Center")(nil)
gobottest.Assert(t, err.(error), errors.New("pwm error"))
err = d.Command("Max")(nil)
gobottest.Assert(t, err.(error), errors.New("pwm error"))
err = d.Command("Move")(map[string]interface{}{"angle": 100.0})
gobottest.Assert(t, err.(error), errors.New("pwm error"))
}
示例8: TestAdaptorConnect
func TestAdaptorConnect(t *testing.T) {
a, _ := initTestAdaptor()
gobottest.Assert(t, a.Connect(), nil)
a = NewAdaptor()
sysfs.SetFilesystem(sysfs.NewMockFilesystem([]string{}))
gobottest.Refute(t, a.Connect(), nil)
}
示例9: TestWiichuckDriver
func TestWiichuckDriver(t *testing.T) {
wii := initTestWiichuckDriver()
gobottest.Refute(t, wii.Connection(), nil)
gobottest.Assert(t, wii.interval, 10*time.Millisecond)
wii = NewWiichuckDriver(newI2cTestAdaptor(), 100*time.Millisecond)
gobottest.Assert(t, wii.interval, 100*time.Millisecond)
}
示例10: TestMPU6050Driver
func TestMPU6050Driver(t *testing.T) {
mpu := initTestMPU6050Driver()
gobottest.Refute(t, mpu.Connection(), nil)
gobottest.Assert(t, mpu.interval, 10*time.Millisecond)
mpu = NewMPU6050Driver(newI2cTestAdaptor(), 100*time.Millisecond)
gobottest.Assert(t, mpu.interval, 100*time.Millisecond)
}
示例11: TestAdaptorSetAPIServer
func TestAdaptorSetAPIServer(t *testing.T) {
a := initTestAdaptor()
apiServer := "new_api_server"
gobottest.Refute(t, a.APIServer, apiServer)
a.setAPIServer(apiServer)
gobottest.Assert(t, a.APIServer, apiServer)
}
示例12: TestMakeyButtonDriver
func TestMakeyButtonDriver(t *testing.T) {
d := initTestMakeyButtonDriver()
gobottest.Assert(t, d.Pin(), "1")
gobottest.Refute(t, d.Connection(), nil)
gobottest.Assert(t, d.interval, 10*time.Millisecond)
d = NewMakeyButtonDriver(newGpioTestAdaptor(), "1", 30*time.Second)
gobottest.Assert(t, d.interval, MAKEY_TEST_DELAY*time.Second)
}
示例13: TestMockFilesystemOpen
func TestMockFilesystemOpen(t *testing.T) {
fs := NewMockFilesystem([]string{"foo"})
f1 := fs.Files["foo"]
gobottest.Assert(t, f1.Opened, false)
f2, err := fs.OpenFile("foo", 0, 0666)
gobottest.Assert(t, f1, f2)
gobottest.Assert(t, err, nil)
err = f2.Sync()
gobottest.Assert(t, err, nil)
_, err = fs.OpenFile("bar", 0, 0666)
gobottest.Refute(t, err, nil)
fs.Add("bar")
f4, _ := fs.OpenFile("bar", 0, 0666)
gobottest.Refute(t, f4.Fd(), f1.Fd())
}
示例14: TestNewMCP23017Driver
func TestNewMCP23017Driver(t *testing.T) {
var bm interface{} = NewMCP23017Driver(newMcpI2cTestAdaptor(), MCP23017Config{}, 0x20)
_, ok := bm.(*MCP23017Driver)
if !ok {
t.Errorf("NewMCP23017Driver() should have returned a *MCP23017Driver")
}
b := NewMCP23017Driver(newMcpI2cTestAdaptor(), MCP23017Config{}, 0x20)
gobottest.Refute(t, b.Connection(), nil)
}
示例15: TestAudioDriver
func TestAudioDriver(t *testing.T) {
d := NewDriver(NewAdaptor(), "../../examples/laser.mp3")
gobottest.Assert(t, d.Filename(), "../../examples/laser.mp3")
gobottest.Refute(t, d.Connection(), nil)
gobottest.Assert(t, d.Start(), nil)
gobottest.Assert(t, d.Halt(), nil)
}