init: initial commit
Checks / verify (push) Canceled after 41s

This commit is contained in:
2026-10-06 11:24:02 +08:00
parent 456e87d4f2
commit ba6dfffab7
63 changed files with 7223 additions and 0 deletions
@@ -0,0 +1,21 @@
package domain
import "testing"
func TestExactMoney(t *testing.T) {
for _, tc := range []struct {
input string
minor int64
formatted string
}{{"0", 0, "0.00"}, {"0.01", 1, "0.01"}, {"100000.10", 10000010, "100000.10"}, {"3.1", 310, "3.10"}, {"1000000000.00", 100000000000, "1000000000.00"}} {
amount, err := ParseMoney(tc.input)
if err != nil || amount != tc.minor || FormatMoney(amount) != tc.formatted {
t.Fatalf("%s: amount=%d err=%v", tc.input, amount, err)
}
}
for _, input := range []string{"-1", "1.001", "1e3", "NaN", " 1", "01", "1.", "1000000000.01", "999999999999999999999", ""} {
if _, err := ParseMoney(input); err == nil {
t.Fatalf("accepted invalid amount %q", input)
}
}
}