-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmath_test.go
More file actions
31 lines (25 loc) · 820 Bytes
/
math_test.go
File metadata and controls
31 lines (25 loc) · 820 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
package gutil
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestPercentOf(t *testing.T) {
assert.Equal(t, float64(0), PercentOf(0, 50))
assert.Equal(t, float64(5), PercentOf(100, 5))
assert.Equal(t, float64(50), PercentOf(100, 50))
}
func TestPercent(t *testing.T) {
assert.Equal(t, float64(0), Percent(0, 20))
assert.Equal(t, float64(20), Percent(100, 20))
assert.Equal(t, float64(5), Percent(100, 5))
}
func TestPercentInt(t *testing.T) {
assert.Equal(t, float64(0), PercentInt(0, 20))
assert.Equal(t, float64(20), PercentInt(100, 20))
assert.Equal(t, float64(40), PercentInt(200, 20))
}
func TestPercentFloat(t *testing.T) {
assert.Equal(t, float64(0), PercentFloat(0, 20))
assert.Equal(t, float64(20), PercentFloat(100, 20))
assert.Equal(t, float64(40), PercentFloat(200, 20))
}