bitboard-model-test.scm 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. (use-modules
  2. ;; SRFI 64: unit tests
  3. (srfi srfi-64)
  4. ((bitboard-model) #:prefix bbm:))
  5. (test-begin "bitboard-model-test")
  6. (test-group
  7. "create-bb"
  8. ;; failure cases
  9. (test-error "bits-must-be-integer-test"
  10. 'invalid-bitboard-creation
  11. (bbm:create-bb "1000100010001000" 4 4 'unspecified))
  12. (test-error "bits-must-be-positive-integer-test"
  13. 'invalid-bitboard-creation
  14. (bbm:create-bb #b-1000100010001000 4 4 'unspecified))
  15. (test-error "height-must-be-integer"
  16. 'invalid-bitboard-creation
  17. (bbm:create-bb #b1000100010001000 "4" 4 'unspecified))
  18. (test-error "height-must-be-positive-integer"
  19. 'invalid-bitboard-creation
  20. (bbm:create-bb #b1000100010001000 -4 4 'unspecified))
  21. (test-error "width-must-be-integer"
  22. 'invalid-bitboard-creation
  23. (bbm:create-bb #b1000100010001000 4 "4" 'unspecified))
  24. (test-error "width-must-be-positive-integer"
  25. 'invalid-bitboard-creation
  26. (bbm:create-bb #b1000100010001000 4 -4 'unspecified))
  27. (test-error "kind-must-be-symbol"
  28. 'invalid-bitboard-creation
  29. (bbm:create-bb #b1000100010001000 4 4 "unspecified"))
  30. (test-error "bit-integer-must-be-lower-than-maximum-for-number-of-bits"
  31. 'invalid-bitboard-creation
  32. (bbm:create-bb #b11000100010001000 4 4 'unspecified))
  33. (test-assert "can-create-bitboard-using-create-bb"
  34. (let ([test-bb (bbm:create-bb #b1000100010001000 4 4 'unspecified)])
  35. (and
  36. (= (bbm:bb-bits test-bb) #b1000100010001000)
  37. (= (bbm:bb-height test-bb) 4)
  38. (= (bbm:bb-width test-bb) 4)
  39. (eq? (bbm:bb-kind test-bb) 'unspecified)))))
  40. ;; (test-group
  41. ;; "create-uniform-bb"
  42. ;; )
  43. (test-end "bitboard-model-test")