Refactor(Tests): Add proper (pp1 tests) unit tests for all logic ADTs
Tests for Positie, Doolhof, Pac-Man, Score, and Tijdslimiet ADTs using check/check-eq?/run-test from (pp1 tests) library. Centralized test runner in alle-testen.rkt with prefix imports. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
59
pacman-project/tests/test-doolhof.rkt
Normal file
59
pacman-project/tests/test-doolhof.rkt
Normal file
@@ -0,0 +1,59 @@
|
||||
#lang r7rs
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; Tests: Doolhof ADT ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(define-library (pacman-project tests test-doolhof)
|
||||
(import (scheme base)
|
||||
(pp1 tests)
|
||||
(pacman-project constanten)
|
||||
(pacman-project adt-doolhof))
|
||||
(export test)
|
||||
|
||||
(begin
|
||||
|
||||
;; Test dimensies
|
||||
(define (test-dimensies)
|
||||
(define d (maak-doolhof))
|
||||
(check-eq? (d 'rijen) 31 "Doolhof moet 31 rijen hebben")
|
||||
(check-eq? (d 'kolommen) 28 "Doolhof moet 28 kolommen hebben"))
|
||||
|
||||
;; Test muur detectie (rij 0 is volledig muur)
|
||||
(define (test-muur)
|
||||
(define d (maak-doolhof))
|
||||
(check ((d 'muur?) 0 0) "Cel (0,0) moet een muur zijn")
|
||||
(check ((d 'muur?) 0 14) "Cel (0,14) moet een muur zijn"))
|
||||
|
||||
;; Test muntje detectie
|
||||
(define (test-muntje)
|
||||
(define d (maak-doolhof))
|
||||
(check ((d 'muntje?) 1 1) "Cel (1,1) moet een muntje zijn")
|
||||
(check (not ((d 'muntje?) 0 0)) "Cel (0,0) mag geen muntje zijn"))
|
||||
|
||||
;; Test deur detectie
|
||||
(define (test-deur)
|
||||
(define d (maak-doolhof))
|
||||
(check ((d 'deur?) 4 3) "Cel (4,3) moet een deur zijn")
|
||||
(check (not ((d 'deur?) 1 1)) "Cel (1,1) mag geen deur zijn"))
|
||||
|
||||
;; Test cel-set! en verwijder-deur!
|
||||
(define (test-mutatie)
|
||||
(define d (maak-doolhof))
|
||||
((d 'verwijder-deur!) 4 3)
|
||||
(check ((d 'leeg?) 4 3) "Cel (4,3) moet leeg zijn na verwijder-deur!")
|
||||
(check (not ((d 'deur?) 4 3)) "Cel (4,3) mag geen deur meer zijn"))
|
||||
|
||||
;; Test dat Pac-Man niet door muur kan (muur blokkeert)
|
||||
(define (test-muur-blokkade)
|
||||
(define d (maak-doolhof))
|
||||
;; Pac-Man staat op (1,1) en wil naar links (1,0) -> dat is een muur
|
||||
(check ((d 'muur?) 1 0) "Cel (1,0) is een muur, Pac-Man kan niet door"))
|
||||
|
||||
(define (test)
|
||||
(run-test test-dimensies "Doolhof: dimensies")
|
||||
(run-test test-muur "Doolhof: muur detectie")
|
||||
(run-test test-muntje "Doolhof: muntje detectie")
|
||||
(run-test test-deur "Doolhof: deur detectie")
|
||||
(run-test test-mutatie "Doolhof: cel mutatie")
|
||||
(run-test test-muur-blokkade "Doolhof: muur blokkeert beweging"))))
|
||||
Reference in New Issue
Block a user