本文整理汇总了Golang中github.com/hybridgroup/gobot/gobottest.Refute函数的典型用法代码示例。如果您正苦于以下问题:Golang Refute函数的具体用法?Golang Refute怎么用?Golang Refute使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Refute函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: 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)
}
示例2: TestDirectPinDriverDigitalWrite
func TestDirectPinDriverDigitalWrite(t *testing.T) {
d := initTestDirectPinDriver(newGpioTestAdaptor("adaptor"))
gobottest.Refute(t, d.DigitalWrite(1), nil)
d = initTestDirectPinDriver(&gpioTestBareAdaptor{})
gobottest.Assert(t, d.DigitalWrite(1), ErrDigitalWriteUnsupported)
}
示例3: TestSparkCoreAdaptorSetAPIServer
func TestSparkCoreAdaptorSetAPIServer(t *testing.T) {
a := initTestSparkCoreAdaptor()
apiServer := "new_api_server"
gobottest.Refute(t, a.APIServer, apiServer)
a.setAPIServer(apiServer)
gobottest.Assert(t, a.APIServer, apiServer)
}
示例4: TestEdisonAdaptorConnect
func TestEdisonAdaptorConnect(t *testing.T) {
a, _ := initTestEdisonAdaptor()
gobottest.Assert(t, len(a.Connect()), 0)
a = NewEdisonAdaptor("myAdaptor")
sysfs.SetFilesystem(sysfs.NewMockFilesystem([]string{}))
gobottest.Refute(t, len(a.Connect()), 0)
}
示例5: 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, err := fs.OpenFile("bar", 0, 0666)
gobottest.Refute(t, f4.Fd(), f1.Fd())
}
示例6: 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)
}
示例7: 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)
}
示例8: TestDigisparkAdaptorDigitalWrite
func TestDigisparkAdaptorDigitalWrite(t *testing.T) {
a := initTestDigisparkAdaptor()
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"))
}
示例9: TestEdisonAdaptorFinalize
func TestEdisonAdaptorFinalize(t *testing.T) {
a, _ := initTestEdisonAdaptor()
a.DigitalWrite("3", 1)
a.PwmWrite("5", 100)
sysfs.SetSyscall(&sysfs.MockSyscall{})
a.I2cStart(0xff)
gobottest.Assert(t, len(a.Finalize()), 0)
closeErr = errors.New("close error")
sysfs.SetFilesystem(sysfs.NewMockFilesystem([]string{}))
gobottest.Refute(t, len(a.Finalize()), 0)
}
示例10: TestEventer
func TestEventer(t *testing.T) {
e := NewEventer()
e.AddEvent("test")
if _, ok := e.Events()["test"]; !ok {
t.Errorf("Could not add event to list of Events")
}
event := e.Event("test")
gobottest.Refute(t, event, nil)
event = e.Event("booyeah")
gobottest.Assert(t, event, (*Event)(nil))
}
示例11: TestCommaner
func TestCommaner(t *testing.T) {
c := NewCommander()
c.AddCommand("test", func(map[string]interface{}) interface{} {
return "hi"
})
if _, ok := c.Commands()["test"]; !ok {
t.Errorf("Could not add command to list of Commands")
}
command := c.Command("test")
gobottest.Refute(t, command, nil)
command = c.Command("booyeah")
gobottest.Assert(t, command, (func(map[string]interface{}) interface{})(nil))
}
示例12: TestCameraDriverStart
func TestCameraDriverStart(t *testing.T) {
sem := make(chan bool)
d := initTestCameraDriver()
gobottest.Assert(t, len(d.Start()), 0)
d.On(d.Event("frame"), func(data interface{}) {
sem <- true
})
select {
case <-sem:
case <-time.After(100 * time.Millisecond):
t.Errorf("Event \"frame\" was not published")
}
d = NewCameraDriver("bot", "")
gobottest.Assert(t, len(d.Start()), 0)
d = NewCameraDriver("bot", true)
gobottest.Refute(t, len(d.Start()), 0)
}
示例13: TestParseNotArrowKeys
func TestParseNotArrowKeys(t *testing.T) {
gobottest.Refute(t, Parse(bytes{27, 91, 65}).Key, Escape)
gobottest.Refute(t, Parse(bytes{27, 91, 70}).Key, 70)
}
示例14: TestParseNotAlphaKeys
func TestParseNotAlphaKeys(t *testing.T) {
gobottest.Refute(t, Parse(bytes{132, 0, 0}).Key, 132)
}
示例15: TestParseNotEscape
func TestParseNotEscape(t *testing.T) {
gobottest.Refute(t, Parse(bytes{27, 91, 65}).Key, Escape)
}