Skip to content

Testing Strategy

The testing strategy validates four guarantees:

  • parser correctness on valid and invalid .cub inputs
  • map safety before runtime (spawn rules, symbol rules, enclosure)
  • runtime stability (init/render loop/exit paths)
  • resource safety (no leaks, no file-descriptor leaks, clean shutdown)

Scope:

  • extension checks
  • unknown identifiers
  • duplicates/missing headers
  • texture path/extension failures
  • RGB format/range errors

Assets:

  • tests/mandatory/parser/
  • tests/mandatory/init/

Execution:

  • make test
  • targeted runs: ./cub3D <test_map.cub>

Expected result:

  • valid files enter the runtime path, which the smoke script currently treats as a timeout-based “still running” success
  • invalid files fail early with controlled Error\n...

Scope:

  • allowed/forbidden symbols
  • single player spawn requirement
  • open map detection
  • irregular row handling
  • unreachable/open leak detection

Assets:

  • tests/mandatory/validation/

Execution:

  • make test
  • manual targeted run for edge maps

Expected result:

  • invalid topology rejected before MLX init
  • valid enclosed maps accepted before runtime starts

Scope:

  • window init
  • frame loop stability
  • textured wall rendering path
  • movement/rotation response
  • clean close on ESC/window destroy

Assets:

  • tests/mandatory/render/
  • nominal valid maps under tests/mandatory/...

Execution:

  • make test
  • manual visual checks in graphical session

Expected result:

  • no crashes in normal control flow
  • visible reaction to input and rendering updates

Scope:

  • bonus symbol linkage
  • minimap/sprite/door/pickup runtime path
  • retro flow and bonus maps
  • next-level trigger path (F4)

Assets:

  • tests/bonus/
  • tests/run_bonus.sh

Execution:

  • make test_bonus
  • optional direct run: ./cub3D_bonus <bonus_map.cub>

Expected result:

  • bonus binary enters stable runtime on valid bonus maps
  • invalid bonus-related setup still fails safely
  • tests/run.sh
  • tests/run_bonus.sh
  • Makefile targets (test, test_bonus)

Practical note:

  • the repository smoke scripts rely on helpers such as timeout, python3, and optionally nm for bonus symbol checks
  • movement smoothness and collision behavior
  • texture orientation correctness (N/S/E/W)
  • door interaction consistency (open/close/passability)
  • HUD readability and sprite occlusion behavior
  • level transition (F4) in active bonus session
  • norminette include srcs srcs_bonus

Goal:

  • 42 style compliance before submission

Recommended commands:

Terminal window
valgrind --leak-check=full --track-fds=yes ./cub3D <map.cub>
valgrind --leak-check=full --track-fds=yes ./cub3D_bonus <map.cub>

Goal:

  • no leak regressions
  • no project-owned file descriptors leaked at exit

After any change in parsing/render/bonus subsystems:

  • make
  • make bonus
  • make test
  • make test_bonus
  • targeted manual scenario for edited subsystem
  • norminette + valgrind spot check

This sequence catches most functional and cleanup regressions before the defense.

In headless environments, mlx_init may fail even when parser/tests are otherwise correct. Because valid-map smoke tests expect the binary to stay alive long enough for timeout to return 124, headless runs can produce false negatives on otherwise valid parsing paths. Parser and validation failures remain meaningful in such environments, but full runtime smoke tests require an active X11 session.