MCPcopy
hub / github.com/g3n/engine / Test

Function Test

experimental/collision/matrix_test.go:10–38  ·  view source on GitHub ↗

Test simple matrix operations

(t *testing.T)

Source from the content-addressed store, hash-verified

8
9// Test simple matrix operations
10func Test(t *testing.T) {
11
12 m := NewMatrix()
13
14 // m.Get(1, 1) // panics with "runtime error: index out of range" as expected
15
16 m.Set(2, 4, true)
17 m.Set(3, 2, true)
18 if m.Get(1, 1) != false {
19 t.Error("Get failed")
20 }
21 if m.Get(2, 4) != true {
22 t.Error("Get failed")
23 }
24 if m.Get(3, 2) != true {
25 t.Error("Get failed")
26 }
27
28 m.Set(2, 4, false)
29 m.Set(3, 2, false)
30 if m.Get(2, 4) != false {
31 t.Error("Get failed")
32 }
33 if m.Get(3, 2) != false {
34 t.Error("Get failed")
35 }
36
37 // m.Get(100, 100) // panics with "runtime error: index out of range" as expected
38}

Callers

nothing calls this directly

Calls 4

SetMethod · 0.95
GetMethod · 0.95
NewMatrixFunction · 0.85
ErrorMethod · 0.80

Tested by

no test coverage detected