From c3b5259784b99f3e0d87d23d2a9d59a5b63a9aed Mon Sep 17 00:00:00 2001 From: Ben Hoyt Date: Sat, 14 Sep 2024 15:53:19 +1200 Subject: [PATCH] Test for macOS issue --- interp/interp_test.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/interp/interp_test.go b/interp/interp_test.go index 20cb3f1..6b91e70 100644 --- a/interp/interp_test.go +++ b/interp/interp_test.go @@ -2860,3 +2860,21 @@ func BenchmarkCSVOutputWriter(b *testing.B) { func normalizeNewlines(s string) string { return strings.Replace(s, "\r\n", "\n", -1) } + +func TestFmtNegativeUnsigned1(t *testing.T) { + n := -42.0 + result := fmt.Sprintf("%d %o %x %X", uint64(n), uint64(n), uint64(n), uint64(n)) + expected := "18446744073709551574 1777777777777777777726 ffffffffffffffd6 FFFFFFFFFFFFFFD6" + if result != expected { + t.Errorf("got %q, want %q", result, expected) + } +} + +func TestFmtNegativeUnsigned2(t *testing.T) { + n := int64(-42.0) + result := fmt.Sprintf("%d %o %x %X", uint64(n), uint64(n), uint64(n), uint64(n)) + expected := "18446744073709551574 1777777777777777777726 ffffffffffffffd6 FFFFFFFFFFFFFFD6" + if result != expected { + t.Errorf("got %q, want %q", result, expected) + } +}