MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / TestShape

Function TestShape

tensorflow/go/shape_test.go:25–68  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

23)
24
25func 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
70func TestZeroShape(t *testing.T) {
71 var s Shape

Callers

nothing calls this directly

Calls 8

makeFunction · 0.85
MakeShapeFunction · 0.85
NumDimensionsMethod · 0.80
ToSliceMethod · 0.80
IsFullySpecifiedMethod · 0.80
ScalarShapeFunction · 0.70
RunMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected