about summary refs log tree commit diff
path: root/main_test.go
blob: 1b5ddc747814d4720817bcb31d70d3a497d019a3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
package main

import (
	"testing"
)

func Test_netNFW(t *testing.T) {
	type args struct {
		x float64
		y float64
		z float64
	}
	tests := []struct {
		name string
		args args
		want float64
	}{
		{
			name: "small values",
			args: args{
				x: 10,
				y: 20,
				z: 30,
			},
			want: 1440.368257365208,
		},
		{
			name: "negative values",
			args: args{
				x: -30,
				y: -40,
				z: -530,
			},
			want: 1043.5804324231447,
		},
		{
			name: "big values",
			args: args{
				x: 10000,
				y: 200000,
				z: 5,
			},
			want: 0.015581605046317826,
		},
	}
	for _, tt := range tests {
		t.Run(tt.name, func(t *testing.T) {
			if got, _ := netNFW(tt.args.x, tt.args.y, tt.args.z); got != tt.want {
				t.Errorf("netNFW() = %v, want %v", got, tt.want)
			}
		})
	}
}

func Test_gen(t *testing.T) {
	type args struct {
		galaxyRange float64
	}
	tests := []struct {
		name string
		args args
		want point
	}{
		{
			name: "Generate a single star (range=1e4)",
			args: args{
				galaxyRange: 1e4,
			},
			want: point{
				x: 0,
				y: 0,
				z: 0,
			},
		},
		{
			name: "Generate a single star (range=1e5)",
			args: args{
				galaxyRange: 1e5,
			},
			want: point{
				x: 0,
				y: 0,
				z: 0,
			},
		},
	}
	for _, tt := range tests {
		t.Run(tt.name, func(t *testing.T) {
			got := gen(tt.args.galaxyRange)
			if got == (point{}) {
				t.Errorf("gen() = %v, want %v", got, tt.want)
			}
		})
	}
}