mirror of
https://github.com/hanzo-fi/numscript.git
synced 2026-10-30 20:54:52 +00:00
27 lines
606 B
Go
27 lines
606 B
Go
package parser_test
|
|
|
|
import (
|
|
"math/big"
|
|
"testing"
|
|
|
|
"github.com/hanzo-fi/numscript/internal/parser"
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestPercentageLiteralToRatio(t *testing.T) {
|
|
assert.Equal(t, big.NewRat(123, 100), parser.PercentageLiteral{
|
|
Amount: big.NewInt(123),
|
|
FloatingDigits: 0,
|
|
}.ToRatio())
|
|
|
|
assert.Equal(t, big.NewRat(123, 1000), parser.PercentageLiteral{
|
|
Amount: big.NewInt(123),
|
|
FloatingDigits: 1,
|
|
}.ToRatio())
|
|
|
|
assert.Equal(t, big.NewRat(123, 10000), parser.PercentageLiteral{
|
|
Amount: big.NewInt(123),
|
|
FloatingDigits: 2,
|
|
}.ToRatio())
|
|
}
|