hybridgroup.gobot/examples_test.go

54 lines
756 B
Go
Raw Normal View History

2014-11-13 07:00:40 +08:00
package gobot_test
import (
"fmt"
"testing"
"time"
"gobot.io/x/gobot"
"gobot.io/x/gobot/gobottest"
2014-11-13 07:00:40 +08:00
)
func ExampleEvery() {
gobot.Every(1*time.Second, func() {
fmt.Println("Hello")
})
}
func ExampleAfter() {
gobot.After(1*time.Second, func() {
fmt.Println("Hello")
})
}
func ExampleRand() {
i := gobot.Rand(100)
2016-07-14 01:21:17 +08:00
fmt.Printf("%v is > 0 && < 100", i)
2014-11-13 07:00:40 +08:00
}
func ExampleFromScale() {
fmt.Println(gobot.FromScale(5, 0, 10))
// Output:
// 0.5
}
func ExampleToScale() {
fmt.Println(gobot.ToScale(500, 0, 10))
// Output:
// 10
}
func ExampleAssert() {
t := &testing.T{}
var a int = 100
var b int = 100
gobottest.Assert(t, a, b)
2014-11-13 07:00:40 +08:00
}
func ExampleRefute() {
t := &testing.T{}
var a int = 100
var b int = 200
gobottest.Refute(t, a, b)
2014-11-13 07:00:40 +08:00
}