mirror of
https://github.com/crazybber/go-pattern-examples.git
synced 2024-11-25 05:06:03 +03:00
44 lines
762 B
Go
44 lines
762 B
Go
package state
|
|
|
|
import "testing"
|
|
|
|
func TestState(t *testing.T) {
|
|
|
|
expect := "vibrating humming ... vibrating humming...vibrating humming..." +
|
|
"vibrating humming ... vibrating humming...vibrating humming..." +
|
|
"sun rise ,get up ,get up get up..."
|
|
|
|
mobile := NewMobileAlert()
|
|
|
|
result := mobile.Alert()
|
|
result += mobile.Alert()
|
|
|
|
mobile.SetState(&MobileAlertSong{})
|
|
|
|
result += mobile.Alert()
|
|
|
|
if result != expect {
|
|
t.Errorf("Expect result to equal %s, but %s.\n", expect, result)
|
|
}
|
|
}
|
|
func TestWeeks(t *testing.T) {
|
|
ctx := NewDayContext()
|
|
todayAndNext := func() {
|
|
ctx.Today()
|
|
ctx.Next()
|
|
}
|
|
|
|
for i := 0; i < 8; i++ {
|
|
todayAndNext()
|
|
}
|
|
// Output:
|
|
// Sunday
|
|
// Monday
|
|
// Tuesday
|
|
// Wednesday
|
|
// Thursday
|
|
// Friday
|
|
// Saturday
|
|
// Sunday
|
|
}
|