| 32 | } |
| 33 | |
| 34 | func TestClockFPS(t *testing.T) { |
| 35 | data := []struct { |
| 36 | fps int |
| 37 | }{ |
| 38 | {5}, |
| 39 | {10}, |
| 40 | {20}, |
| 41 | {30}, |
| 42 | {60}, |
| 43 | } |
| 44 | for _, d := range data { |
| 45 | theTimer = testTime{0} |
| 46 | clock := NewClock() |
| 47 | tickTime := 1000000000 / d.fps |
| 48 | curTime := int64(0) |
| 49 | for i := 0; i < d.fps; i++ { |
| 50 | curTime += int64(tickTime) + 1 |
| 51 | theTimer = testTime{curTime} |
| 52 | clock.Tick() |
| 53 | } |
| 54 | if clock.FPS() != float32(d.fps) { |
| 55 | t.Errorf("Clock's FPS did not match %v fps, was %v", d.fps, clock.FPS()) |
| 56 | } |
| 57 | } |
| 58 | } |
| 59 | |
| 60 | func TestClockDelta(t *testing.T) { |
| 61 | data := []struct { |