about summary refs log tree commit diff
path: root/main_test.go
blob: 25061ef1b60f932430ecd5b722d4a23c5e731164 (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
96
97
98
99
100
package main

import (
	"testing"
)

func Test_rho(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 := rho(tt.args.x, tt.args.y, tt.args.z); got != tt.want {
				t.Errorf("rho() = %v, want %v", got, tt.want)
			}
		})
	}
}

func Test_phi(t *testing.T) {
	type args struct {
		x float64
	}
	tests := []struct {
		name string
		args args
		want float64
	}{
		{
			name: "small positive",
			args: args{
				x: 0.1,
			},
			want: -540602.560824974,
		},
		{
			name: "small negative",
			args: args{
				x: -0.1,
			},
			want: -540607.9668716107,
		},
		{
			name: "zero",
			args: args{
				x: 0,
			},
			want: -540605.2638297316,
		},
		{
			name: "large positive",
			args: args{
				x: 98754321,
			},
			want: -503.515863906017,
		},
	}
	for _, tt := range tests {
		t.Run(tt.name, func(t *testing.T) {
			if got := phi(tt.args.x); got != tt.want {
				t.Errorf("phi() = %v, want %v", got, tt.want)
			}
		})
	}
}