matrix_test.go 863 B

123456789101112131415161718192021222324252627282930313233343536373839
  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 implements collision related algorithms and data structures.
  5. package collision
  6. import "testing"
  7. // Test simple matrix operations
  8. func Test(t *testing.T) {
  9. m := NewMatrix()
  10. // m.Get(1, 1) // panics with "runtime error: index out of range" as expected
  11. m.Set(2,4, true)
  12. m.Set(3,2, true)
  13. if m.Get(1,1) != false {
  14. t.Error("Get failed")
  15. }
  16. if m.Get(2,4) != true {
  17. t.Error("Get failed")
  18. }
  19. if m.Get(3,2) != true {
  20. t.Error("Get failed")
  21. }
  22. m.Set(2,4, false)
  23. m.Set(3,2, false)
  24. if m.Get(2,4) != false {
  25. t.Error("Get failed")
  26. }
  27. if m.Get(3,2) != false {
  28. t.Error("Get failed")
  29. }
  30. // m.Get(100, 100) // panics with "runtime error: index out of range" as expected
  31. }