(t *testing.T)
| 23 | ) |
| 24 | |
| 25 | func TestShape(t *testing.T) { |
| 26 | tests := []struct { |
| 27 | shape Shape |
| 28 | slice []int64 |
| 29 | full bool |
| 30 | str string |
| 31 | }{ |
| 32 | { |
| 33 | shape: ScalarShape(), |
| 34 | slice: make([]int64, 0), |
| 35 | full: true, |
| 36 | str: "[]", |
| 37 | }, |
| 38 | { |
| 39 | shape: MakeShape(-1, 2, -1, 4), |
| 40 | slice: []int64{-1, 2, -1, 4}, |
| 41 | full: false, |
| 42 | str: "[?, 2, ?, 4]", |
| 43 | }, |
| 44 | { |
| 45 | shape: MakeShape(2, 3), |
| 46 | slice: []int64{2, 3}, |
| 47 | full: true, |
| 48 | str: "[2, 3]", |
| 49 | }, |
| 50 | } |
| 51 | for _, test := range tests { |
| 52 | t.Run(fmt.Sprintf("%#v", test.shape), func(t *testing.T) { |
| 53 | if got, want := test.shape.NumDimensions(), len(test.slice); got != want { |
| 54 | t.Errorf("Got %v, want %v", got, want) |
| 55 | } |
| 56 | if gotSlice, err := test.shape.ToSlice(); err != nil || !reflect.DeepEqual(gotSlice, test.slice) { |
| 57 | t.Errorf("Got (%#v, %v), want (%#v, nil)", gotSlice, err, test.slice) |
| 58 | } |
| 59 | if got, want := test.shape.IsFullySpecified(), test.full; got != want { |
| 60 | t.Errorf("Got %v, want %v", got, want) |
| 61 | } |
| 62 | if got, want := test.shape.String(), test.str; got != want { |
| 63 | t.Errorf("Got %v, want %v", got, want) |
| 64 | } |
| 65 | }) |
| 66 | } |
| 67 | |
| 68 | } |
| 69 | |
| 70 | func TestZeroShape(t *testing.T) { |
| 71 | var s Shape |
nothing calls this directly
no test coverage detected