MCPcopy Create free account
hub / github.com/cogentcore/core / TestMatrix2SetString

Function TestMatrix2SetString

math32/matrix2_test.go:57–95  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

55}
56
57func TestMatrix2SetString(t *testing.T) {
58 tests := []struct {
59 str string
60 wantErr bool
61 want Matrix2
62 }{
63 {
64 str: "none",
65 wantErr: false,
66 want: Identity2(),
67 },
68 {
69 str: "matrix(1, 2, 3, 4, 5, 6)",
70 wantErr: false,
71 want: Matrix2{1, 2, 3, 4, 5, 6},
72 },
73 {
74 str: "translate(1, 2)",
75 wantErr: false,
76 want: Matrix2{XX: 1, YX: 0, XY: 0, YY: 1, X0: 1, Y0: 2},
77 },
78 {
79 str: "invalid(1, 2)",
80 wantErr: true,
81 want: Identity2(),
82 },
83 }
84
85 for _, tt := range tests {
86 a := &Matrix2{}
87 err := a.SetString(tt.str)
88 if tt.wantErr {
89 assert.Error(t, err, tt.str)
90 } else {
91 assert.NoError(t, err, tt.str)
92 }
93 assert.Equal(t, tt.want, *a, tt.str)
94 }
95}
96
97func TestMatrix2String(t *testing.T) {
98 tests := []struct {

Callers

nothing calls this directly

Calls 4

SetStringMethod · 0.95
Identity2Function · 0.85
EqualMethod · 0.80
ErrorMethod · 0.65

Tested by

no test coverage detected