feat: add Go backend

This commit is contained in:
richjohnrambo
2026-10-10 20:56:17 +08:00
parent 50fcfd2d3d
commit f6024f0964
1040 changed files with 107169 additions and 0 deletions
+32
View File
@@ -0,0 +1,32 @@
package sys
import "testing"
func TestParseCents(t *testing.T) {
tests := []struct {
value string
want int64
}{
{"0", 0},
{"0.01", 1},
{"12.3", 1230},
{"999.99", 99999},
}
for _, item := range tests {
got, err := parseCents(item.value)
if err != nil {
t.Fatalf("parseCents(%q) returned error: %v", item.value, err)
}
if got != item.want {
t.Fatalf("parseCents(%q)=%d, want %d", item.value, got, item.want)
}
}
}
func TestParseCentsRejectsInvalidValues(t *testing.T) {
for _, value := range []string{"", "-1", "1.001", "abc", "1.2.3"} {
if _, err := parseCents(value); err == nil {
t.Fatalf("parseCents(%q) should fail", value)
}
}
}