| 68 | } |
| 69 | |
| 70 | func TestDecimal(t *testing.T) { |
| 71 | numberTests := []struct { |
| 72 | number string |
| 73 | expected string |
| 74 | }{ |
| 75 | {"", ""}, |
| 76 | {"0", "0"}, |
| 77 | {".0", "0"}, |
| 78 | {"1.0", "1"}, |
| 79 | {"0.1", ".1"}, |
| 80 | {"+1", "1"}, |
| 81 | {"-1", "-1"}, |
| 82 | {"-0.1", "-.1"}, |
| 83 | {"10", "10"}, |
| 84 | {"100", "100"}, |
| 85 | {"1000", "1000"}, |
| 86 | {"0.001", ".001"}, |
| 87 | {"0.0001", ".0001"}, |
| 88 | {"0.252", ".252"}, |
| 89 | {"1.252", "1.252"}, |
| 90 | {"-1.252", "-1.252"}, |
| 91 | {"0.075", ".075"}, |
| 92 | {"789012345678901234567890123456789e9234567890123456789", "789012345678901234567890123456789e9234567890123456789"}, |
| 93 | {".000100009", ".000100009"}, |
| 94 | {".0001000009", ".0001000009"}, |
| 95 | {".0001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000009", ".0001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000009"}, |
| 96 | {"E\x1f", "E\x1f"}, // fuzz |
| 97 | } |
| 98 | for _, tt := range numberTests { |
| 99 | t.Run(tt.number, func(t *testing.T) { |
| 100 | number := Decimal([]byte(tt.number), -1) |
| 101 | test.Minify(t, tt.number, nil, string(number), tt.expected) |
| 102 | }) |
| 103 | } |
| 104 | } |
| 105 | |
| 106 | func TestDecimalTruncate(t *testing.T) { |
| 107 | numberTests := []struct { |