matrix_test.go 781 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. // Copyright 2016 The G3N Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. package collision
  5. import "testing"
  6. // Test simple matrix operations
  7. func Test(t *testing.T) {
  8. m := NewMatrix()
  9. // m.Get(1, 1) // panics with "runtime error: index out of range" as expected
  10. m.Set(2,4, true)
  11. m.Set(3,2, true)
  12. if m.Get(1,1) != false {
  13. t.Error("Get failed")
  14. }
  15. if m.Get(2,4) != true {
  16. t.Error("Get failed")
  17. }
  18. if m.Get(3,2) != true {
  19. t.Error("Get failed")
  20. }
  21. m.Set(2,4, false)
  22. m.Set(3,2, false)
  23. if m.Get(2,4) != false {
  24. t.Error("Get failed")
  25. }
  26. if m.Get(3,2) != false {
  27. t.Error("Get failed")
  28. }
  29. // m.Get(100, 100) // panics with "runtime error: index out of range" as expected
  30. }