|
@@ -1,34 +0,0 @@
|
1
|
|
-package main
|
2
|
|
-
|
3
|
|
-import (
|
4
|
|
- "math"
|
5
|
|
- "testing"
|
6
|
|
-)
|
7
|
|
-
|
8
|
|
-func Test_angleBetween(t *testing.T) {
|
9
|
|
- type args struct {
|
10
|
|
- asteroid1 *asteroid
|
11
|
|
- asteroid2 *asteroid
|
12
|
|
- }
|
13
|
|
- tests := []struct {
|
14
|
|
- name string
|
15
|
|
- args args
|
16
|
|
- want float64
|
17
|
|
- }{
|
18
|
|
- {"above", args{&asteroid{x: 5, y: 5}, &asteroid{x: 5, y: 0}}, 0},
|
19
|
|
- {"below", args{&asteroid{x: 5, y: 5}, &asteroid{x: 5, y: 10}}, math.Pi},
|
20
|
|
- {"right", args{&asteroid{x: 5, y: 5}, &asteroid{x: 10, y: 5}}, math.Pi / 2},
|
21
|
|
- {"left", args{&asteroid{x: 5, y: 5}, &asteroid{x: 0, y: 5}}, 3 * math.Pi / 2},
|
22
|
|
- {"quadrant1", args{&asteroid{x: 5, y: 5}, &asteroid{x: 10, y: 0}}, math.Pi / 4},
|
23
|
|
- {"quadrant2", args{&asteroid{x: 5, y: 5}, &asteroid{x: 10, y: 10}}, 3 * math.Pi / 4},
|
24
|
|
- {"quadrant3", args{&asteroid{x: 5, y: 5}, &asteroid{x: 0, y: 10}}, 5 * math.Pi / 4},
|
25
|
|
- {"quadrant4", args{&asteroid{x: 5, y: 5}, &asteroid{x: 0, y: 0}}, 7 * math.Pi / 4},
|
26
|
|
- }
|
27
|
|
- for _, tt := range tests {
|
28
|
|
- t.Run(tt.name, func(t *testing.T) {
|
29
|
|
- if got := angleBetween(tt.args.asteroid1, tt.args.asteroid2); got != tt.want {
|
30
|
|
- t.Errorf("angleBetween() = %v, want %v", got, tt.want)
|
31
|
|
- }
|
32
|
|
- })
|
33
|
|
- }
|
34
|
|
-}
|