From 9fc32a450f3d7ea3537b07495c3142e7fc01f6c8 Mon Sep 17 00:00:00 2001 From: Casey Marshall Date: Mon, 23 Mar 2015 17:02:29 -0500 Subject: [PATCH] Add negative test values once. --- decimal_test.go | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/decimal_test.go b/decimal_test.go index e4f82fb..7121a5c 100644 --- a/decimal_test.go +++ b/decimal_test.go @@ -28,14 +28,16 @@ var testTable = map[float64]string{ .1000000000000008: "0.1000000000000008", } -func TestNewFromFloat(t *testing.T) { +func init() { // add negatives for f, s := range testTable { if f > 0 { testTable[-f] = "-" + s } } +} +func TestNewFromFloat(t *testing.T) { for f, s := range testTable { d := NewFromFloat(f) if d.String() != s { @@ -60,13 +62,6 @@ func TestNewFromFloat(t *testing.T) { } func TestNewFromString(t *testing.T) { - // add negatives - for f, s := range testTable { - if f > 0 { - testTable[-f] = "-" + s - } - } - for _, s := range testTable { d, err := NewFromString(s) if err != nil {