mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-11-24 06:25:55 +00:00
40 lines
619 B
Go
40 lines
619 B
Go
package utils
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func TestValidateAmountFormat(t *testing.T) {
|
|
validCases := []string{
|
|
"0",
|
|
"1",
|
|
"1.0",
|
|
"0.1",
|
|
"0.12345678",
|
|
}
|
|
|
|
for _, testCase := range validCases {
|
|
err := ValidateAmountFormat(testCase)
|
|
|
|
if err != nil {
|
|
t.Error(err)
|
|
}
|
|
}
|
|
|
|
invalidCases := []string{
|
|
"",
|
|
"a",
|
|
"-1",
|
|
"0.123456789", // 9 decimal digits
|
|
".1", // decimal but no integer component
|
|
}
|
|
|
|
for _, testCase := range invalidCases {
|
|
err := ValidateAmountFormat(testCase)
|
|
|
|
if err == nil {
|
|
t.Errorf("Expected an error but succeeded validation for test case %s", testCase)
|
|
}
|
|
}
|
|
}
|