• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang gobottest.Refute函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中gobot/io/x/gobot/gobottest.Refute函数的典型用法代码示例。如果您正苦于以下问题:Golang Refute函数的具体用法?Golang Refute怎么用?Golang Refute使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了Refute函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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)
}
开发者ID:hybridgroup,项目名称:gobot,代码行数:7,代码来源:utils_test.go


示例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)
}
开发者ID:hybridgroup,项目名称:gobot,代码行数:11,代码来源:api_test.go


示例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)
}
开发者ID:hybridgroup,项目名称:gobot,代码行数:7,代码来源:direct_pin_driver_test.go


示例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"))

}
开发者ID:hybridgroup,项目名称:gobot,代码行数:28,代码来源:led_driver_test.go


示例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)
}
开发者ID:hybridgroup,项目名称:gobot,代码行数:7,代码来源:button_driver_test.go


示例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"))

}
开发者ID:hybridgroup,项目名称:gobot,代码行数:31,代码来源:rgb_led_driver_test.go


示例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"))

}
开发者ID:hybridgroup,项目名称:gobot,代码行数:25,代码来源:servo_driver_test.go


示例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)
}
开发者ID:hybridgroup,项目名称:gobot,代码行数:8,代码来源:edison_adaptor_test.go


示例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)
}
开发者ID:hybridgroup,项目名称:gobot,代码行数:8,代码来源:wiichuck_driver_test.go


示例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)
}
开发者ID:hybridgroup,项目名称:gobot,代码行数:8,代码来源:mpu6050_driver_test.go


示例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)
}
开发者ID:hybridgroup,项目名称:gobot,代码行数:8,代码来源:adaptor_test.go


示例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)
}
开发者ID:hybridgroup,项目名称:gobot,代码行数:9,代码来源:makey_button_driver_test.go


示例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())
}
开发者ID:hybridgroup,项目名称:gobot,代码行数:19,代码来源:fs_mock_test.go


示例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)
}
开发者ID:hybridgroup,项目名称:gobot,代码行数:10,代码来源:mcp23017_driver_test.go


示例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)
}
开发者ID:hybridgroup,项目名称:gobot,代码行数:11,代码来源:audio_driver_test.go


示例16: TestNewHMC6352Driver

func TestNewHMC6352Driver(t *testing.T) {
	// Does it return a pointer to an instance of HMC6352Driver?
	var bm interface{} = NewHMC6352Driver(newI2cTestAdaptor())
	_, ok := bm.(*HMC6352Driver)
	if !ok {
		t.Errorf("NewHMC6352Driver() should have returned a *HMC6352Driver")
	}

	b := NewHMC6352Driver(newI2cTestAdaptor())
	gobottest.Refute(t, b.Connection(), nil)
}
开发者ID:hybridgroup,项目名称:gobot,代码行数:11,代码来源:hmc6352_driver_test.go


示例17: TestMavlinkDriver

func TestMavlinkDriver(t *testing.T) {
	m := NewAdaptor("/dev/null")
	m.sp = nullReadWriteCloser{}
	m.connect = func(port string) (io.ReadWriteCloser, error) { return nil, nil }

	d := NewDriver(m)
	gobottest.Refute(t, d.Connection(), nil)
	gobottest.Assert(t, d.interval, 10*time.Millisecond)

	d = NewDriver(m, 100*time.Millisecond)
	gobottest.Assert(t, d.interval, 100*time.Millisecond)
}
开发者ID:hybridgroup,项目名称:gobot,代码行数:12,代码来源:mavlink_driver_test.go


示例18: TestNewI2cDevice

func TestNewI2cDevice(t *testing.T) {
	fs := NewMockFilesystem([]string{})
	SetFilesystem(fs)

	i, err := NewI2cDevice(os.DevNull, 0xff)
	gobottest.Refute(t, err, nil)

	fs = NewMockFilesystem([]string{
		"/dev/i2c-1",
	})

	SetFilesystem(fs)

	i, err = NewI2cDevice("/dev/i2c-1", 0xff)
	gobottest.Refute(t, err, nil)

	SetSyscall(&MockSyscall{})

	i, err = NewI2cDevice("/dev/i2c-1", 0xff)
	var _ I2cDevice = i

	gobottest.Assert(t, err, nil)

	gobottest.Assert(t, i.SetAddress(0xff), nil)

	buf := []byte{0x01, 0x02, 0x03}

	n, err := i.Write(buf)

	gobottest.Assert(t, n, len(buf))
	gobottest.Assert(t, err, nil)

	buf = make([]byte, 4)

	n, err = i.Read(buf)

	gobottest.Assert(t, n, 3)
	gobottest.Assert(t, err, nil)

}
开发者ID:hybridgroup,项目名称:gobot,代码行数:40,代码来源:i2c_device_test.go


示例19: TestCORS

func TestCORS(t *testing.T) {
	api := initTestAPI()

	// Accepted origin
	allowedOrigin := []string{"http://server.com"}
	api.AddHandler(AllowRequestsFrom(allowedOrigin[0]))

	request, _ := http.NewRequest("GET", "/api/", nil)
	request.Header.Set("Origin", allowedOrigin[0])
	response := httptest.NewRecorder()
	api.ServeHTTP(response, request)
	gobottest.Assert(t, response.Header()["Access-Control-Allow-Origin"], allowedOrigin)

	// Not accepted Origin
	disallowedOrigin := []string{"http://disallowed.com"}
	request, _ = http.NewRequest("GET", "/api/", nil)
	request.Header.Set("Origin", disallowedOrigin[0])
	response = httptest.NewRecorder()
	api.ServeHTTP(response, request)
	gobottest.Refute(t, response.Header()["Access-Control-Allow-Origin"], disallowedOrigin)
	gobottest.Refute(t, response.Header()["Access-Control-Allow-Origin"], allowedOrigin)
}
开发者ID:hybridgroup,项目名称:gobot,代码行数:22,代码来源:cors_test.go


示例20: TestAdaptorDigitalWrite

func TestAdaptorDigitalWrite(t *testing.T) {
	a := initTestAdaptor()
	err := a.DigitalWrite("0", uint8(1))
	gobottest.Assert(t, err, nil)
	gobottest.Assert(t, a.littleWire.(*mock).pin, uint8(0))
	gobottest.Assert(t, a.littleWire.(*mock).state, uint8(1))

	err = a.DigitalWrite("?", uint8(1))
	gobottest.Refute(t, err, nil)

	errorFunc = func() error { return errors.New("pin mode error") }
	err = a.DigitalWrite("0", uint8(1))
	gobottest.Assert(t, err, errors.New("pin mode error"))
}
开发者ID:hybridgroup,项目名称:gobot,代码行数:14,代码来源:digispark_adaptor_test.go



注:本文中的gobot/io/x/gobot/gobottest.Refute函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang gocheck.C类代码示例发布时间:2022-05-28
下一篇:
Golang gobottest.Assert函数代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap