forked from synapsecns/sanguine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmath_test.go
45 lines (42 loc) · 870 Bytes
/
math_test.go
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
package core_test
import (
"github.com/synapsecns/sanguine/core"
"math/big"
"testing"
)
func TestBigToDecimals(t *testing.T) {
tests := []struct {
name string
bigInt *big.Int
decimals uint8
want float64
}{
{
name: "Basic Conversion",
bigInt: big.NewInt(1000000),
decimals: 2,
want: 10000.00,
},
{
name: "Zero Value",
bigInt: big.NewInt(0),
decimals: 5,
want: 0.0,
},
{
name: "Large Number",
bigInt: big.NewInt(1234567890123456789),
decimals: 9,
want: 1234567890.123456789,
},
// Add more test cases as needed
}
for i := range tests {
tt := tests[i] // capture func literal
t.Run(tt.name, func(t *testing.T) {
if got := core.BigToDecimals(tt.bigInt, tt.decimals); got != tt.want {
t.Errorf("BigToDecimals() = %v, want %v", got, tt.want)
}
})
}
}