1
2
3
4
5 package specexpr
6
7 import "testing"
8
9 func TestMkWidth(t *testing.T) {
10 tests := []struct {
11 num, denom int
12 want ScalableWidth
13 }{
14 {4, 8, ScalableWidth{1, 2}},
15 {3, 9, ScalableWidth{1, 3}},
16 {12, 18, ScalableWidth{2, 3}},
17 {0, 5, ScalableWidth{0, 1}},
18
19 {-4, 8, ScalableWidth{-1, 2}},
20 {4, -8, ScalableWidth{-1, 2}},
21 {-4, -8, ScalableWidth{1, 2}},
22 }
23 for _, tc := range tests {
24 got := mkWidth(tc.num, tc.denom)
25 if got != tc.want {
26 t.Errorf("mkWidth(%d, %d) = %v; want %v", tc.num, tc.denom, got, tc.want)
27 }
28 }
29 }
30
View as plain text