-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathangularspeed_test.go
More file actions
39 lines (34 loc) · 940 Bytes
/
angularspeed_test.go
File metadata and controls
39 lines (34 loc) · 940 Bytes
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
package unit
import (
"math"
"testing"
"gotest.tools/v3/assert"
)
func TestAngularSpeed_Get(t *testing.T) {
assert.Equal(t, float64(9.549296585513721), RadianPerSecond.Get(RPM))
assert.Equal(t, float64(57.29577951308232), RadianPerSecond.Get(DegreePerSecond))
}
func TestAngularSpeed_String(t *testing.T) {
for _, tt := range []struct {
a AngularSpeed
str string
}{
{a: 0, str: "0rad/s"},
{a: 2.3 * RadianPerSecond, str: "2.3rad/s"},
{a: 3 * Milli * RadianPerSecond, str: "0.003rad/s"},
} {
t.Run(tt.str, func(t *testing.T) {
t.Run("marshal", func(t *testing.T) {
assert.Equal(t, tt.str, tt.a.String())
})
t.Run("unmarshal", func(t *testing.T) {
var s AngularSpeed
assert.NilError(t, s.UnmarshalString(tt.str))
assert.Equal(t, tt.a, s)
})
})
}
}
func TestAngularSpeed_DegreesPerSecond(t *testing.T) {
assert.Equal(t, (math.Pi * RadianPerSecond).DegreesPerSecond(), float64(180))
}