Skip to content

Commit 562ed24

Browse files
committed
✨ (clockface): add sample for unit circle
1 parent e20950c commit 562ed24

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

clockface/clockface.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,7 @@ func simpleTime(hours, minutes, seconds int) time.Time {
2828
func testName(t time.Time) string {
2929
return t.Format("15:04:05")
3030
}
31+
32+
func secondHandPoint(t time.Time) Point {
33+
return Point{0, -1}
34+
}

clockface/clockface_test.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,21 @@ func TestSecondsInRadians(t *testing.T) {
2626
})
2727
}
2828
}
29+
30+
func TestSecondHandPoint(t *testing.T) {
31+
cases := []struct {
32+
time time.Time
33+
point Point
34+
}{
35+
{simpleTime(0, 0, 30), Point{0, -1}},
36+
}
37+
38+
for _, c := range cases {
39+
t.Run(testName(c.time), func(t *testing.T) {
40+
got := secondHandPoint(c.time)
41+
if got != c.point {
42+
t.Fatalf("Wanted %v Point, but got %v", c.point, got)
43+
}
44+
})
45+
}
46+
}

0 commit comments

Comments
 (0)