forked from hybridgroup/gobot
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
90 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package gobot_test | ||
|
||
import ( | ||
"fmt" | ||
"github.com/hybridgroup/gobot" | ||
"testing" | ||
"time" | ||
) | ||
|
||
func ExampleEvery() { | ||
gobot.Every(1*time.Second, func() { | ||
fmt.Println("Hello") | ||
}) | ||
} | ||
|
||
func ExampleAfter() { | ||
gobot.After(1*time.Second, func() { | ||
fmt.Println("Hello") | ||
}) | ||
} | ||
|
||
func ExamplePublish() { | ||
e := gobot.NewEvent() | ||
gobot.Publish(e, 100) | ||
} | ||
|
||
func ExampleOn() { | ||
e := gobot.NewEvent() | ||
gobot.On(e, func(s interface{}) { | ||
fmt.Println(s) | ||
}) | ||
gobot.Publish(e, 100) | ||
gobot.Publish(e, 200) | ||
} | ||
|
||
func ExampleOnce() { | ||
e := gobot.NewEvent() | ||
gobot.Once(e, func(s interface{}) { | ||
fmt.Println(s) | ||
fmt.Println("I will no longer respond to events") | ||
}) | ||
gobot.Publish(e, 100) | ||
gobot.Publish(e, 200) | ||
} | ||
|
||
func ExampleRand() { | ||
i := gobot.Rand(100) | ||
fmt.Sprintln("%v is > 0 && < 100", i) | ||
} | ||
|
||
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 | ||
gobot.Assert(t, a, b) | ||
} | ||
|
||
func ExampleRefute() { | ||
t := &testing.T{} | ||
var a int = 100 | ||
var b int = 200 | ||
gobot.Refute(t, a, b) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters