gobot.io/x/gobot/v2@v2.1.0/examples_test.go (about) 1 package gobot_test 2 3 import ( 4 "fmt" 5 "testing" 6 "time" 7 8 "gobot.io/x/gobot/v2" 9 "gobot.io/x/gobot/v2/gobottest" 10 ) 11 12 func ExampleEvery() { 13 gobot.Every(1*time.Second, func() { 14 fmt.Println("Hello") 15 }) 16 } 17 18 func ExampleAfter() { 19 gobot.After(1*time.Second, func() { 20 fmt.Println("Hello") 21 }) 22 } 23 24 func ExampleRand() { 25 i := gobot.Rand(100) 26 fmt.Printf("%v is > 0 && < 100", i) 27 } 28 29 func ExampleFromScale() { 30 fmt.Println(gobot.FromScale(5, 0, 10)) 31 // Output: 32 // 0.5 33 } 34 35 func ExampleToScale() { 36 fmt.Println(gobot.ToScale(500, 0, 10)) 37 // Output: 38 // 10 39 } 40 41 func ExampleAssert() { 42 t := &testing.T{} 43 var a int = 100 44 var b int = 100 45 gobottest.Assert(t, a, b) 46 } 47 48 func ExampleRefute() { 49 t := &testing.T{} 50 var a int = 100 51 var b int = 200 52 gobottest.Refute(t, a, b) 53 }