Download this file
| 1 | package render |
| 2 | |
| 3 | import ( |
| 4 | "math" |
| 5 | "testing" |
| 6 | |
| 7 | "amadan.net/oficina/slides/internal/slides/deck" |
| 8 | ) |
| 9 | |
| 10 | // TestNumbersNeverWriteNegativeZero: a zero written into a style or an |
| 11 | // attribute is "0", whatever its sign (arm64 can make -0 where amd64 |
| 12 | // makes 0). |
| 13 | func TestNumbersNeverWriteNegativeZero(t *testing.T) { |
| 14 | neg := math.Copysign(0, -1) |
| 15 | for _, v := range []float64{neg, -0.0000001} { |
| 16 | if got := num(v); got != "0" { |
| 17 | t.Errorf("num(%v) = %q, want 0", v, got) |
| 18 | } |
| 19 | if got := pct(v); got != "0%" { |
| 20 | t.Errorf("pct(%v) = %q, want 0%%", v, got) |
| 21 | } |
| 22 | } |
| 23 | if got := fracs(deck.Box{X: neg, Y: -0.00001, W: 0.5, H: 1}); got != "0.0000,0.0000,0.5000,1.0000" { |
| 24 | t.Errorf("fracs = %q, want no negative zero", got) |
| 25 | } |
| 26 | } |
| 27 | |