From 6dfe5632579e5b3f730eb9df93700228e2989576 Mon Sep 17 00:00:00 2001 From: whaffman Date: Tue, 27 May 2025 20:07:37 +0200 Subject: [PATCH] tests --- maps/invalid/double_floor_color.cub | 13 +++++++++++ maps/invalid/double_player.cub | 12 +++++++++++ maps/invalid/double_wall_texture.cub | 13 +++++++++++ maps/invalid/empty_line_in_map.cub | 13 +++++++++++ maps/invalid/invalid_color.cub | 12 +++++++++++ maps/invalid/missing_floor_color.cub | 11 ++++++++++ maps/invalid/missing_wall_texture.cub | 11 ++++++++++ maps/invalid/no_player.cub | 12 +++++++++++ maps/invalid/not_enclosed_map.cub | 12 +++++++++++ maps/invalid/test.cub | 12 +++++++++++ maps/simple.cub | 12 +++++++++++ test.log | 10 +++++++++ test.sh | 31 +++++++++++++++++++++++++++ 13 files changed, 174 insertions(+) create mode 100644 maps/invalid/double_floor_color.cub create mode 100644 maps/invalid/double_player.cub create mode 100644 maps/invalid/double_wall_texture.cub create mode 100644 maps/invalid/empty_line_in_map.cub create mode 100644 maps/invalid/invalid_color.cub create mode 100644 maps/invalid/missing_floor_color.cub create mode 100644 maps/invalid/missing_wall_texture.cub create mode 100644 maps/invalid/no_player.cub create mode 100644 maps/invalid/not_enclosed_map.cub create mode 100644 maps/invalid/test.cub create mode 100644 maps/simple.cub create mode 100644 test.log create mode 100755 test.sh diff --git a/maps/invalid/double_floor_color.cub b/maps/invalid/double_floor_color.cub new file mode 100644 index 0000000..352bf16 --- /dev/null +++ b/maps/invalid/double_floor_color.cub @@ -0,0 +1,13 @@ +NO ./assets/bricks2.png +WE ./assets/bricks2.png +SO ./assets/stonewall256.png +EA ./assets/bricksx64.png + +F 200,30,30 +F 30,130,130 +C 100,100,200 + +1111111 +1000001 +1N00001 +1111111 \ No newline at end of file diff --git a/maps/invalid/double_player.cub b/maps/invalid/double_player.cub new file mode 100644 index 0000000..5b6493e --- /dev/null +++ b/maps/invalid/double_player.cub @@ -0,0 +1,12 @@ +NO ./assets/bricks2.png +WE ./assets/bricks2.png +SO ./assets/stonewall256.png +EA ./assets/bricksx64.png + +F 90,30,30 +C 100,100,200 + +1111111 +100W001 +1N00001 +1111111 \ No newline at end of file diff --git a/maps/invalid/double_wall_texture.cub b/maps/invalid/double_wall_texture.cub new file mode 100644 index 0000000..842180d --- /dev/null +++ b/maps/invalid/double_wall_texture.cub @@ -0,0 +1,13 @@ +NO ./assets/tiles256.png +NO ./assets/bricks2.png +WE ./assets/bricks2.png +SO ./assets/stonewall256.png +EA ./assets/bricksx64.png + +F 90,30,30 +C 100,100,200 + +1111111 +1000001 +1N00001 +1111111 \ No newline at end of file diff --git a/maps/invalid/empty_line_in_map.cub b/maps/invalid/empty_line_in_map.cub new file mode 100644 index 0000000..5924f15 --- /dev/null +++ b/maps/invalid/empty_line_in_map.cub @@ -0,0 +1,13 @@ +NO ./assets/bricks2.png +WE ./assets/bricks2.png +SO ./assets/stonewall256.png +EA ./assets/bricksx64.png + +F 90,30,30 +C 100,100,200 + +1111111 +1000001 + +1E00001 +1111111 \ No newline at end of file diff --git a/maps/invalid/invalid_color.cub b/maps/invalid/invalid_color.cub new file mode 100644 index 0000000..c4b5226 --- /dev/null +++ b/maps/invalid/invalid_color.cub @@ -0,0 +1,12 @@ +NO ./assets/bricks2.png +WE ./assets/bricks2.png +SO ./assets/stonewall256.png +EA ./assets/bricksx64.png + +F 900,30,30 +C 100,100,200 + +1111111 +1000001 +1N00001 +1111111 \ No newline at end of file diff --git a/maps/invalid/missing_floor_color.cub b/maps/invalid/missing_floor_color.cub new file mode 100644 index 0000000..03f69cc --- /dev/null +++ b/maps/invalid/missing_floor_color.cub @@ -0,0 +1,11 @@ +NO ./assets/tiles256.png +WE ./assets/bricks2.png +SO ./assets/stonewall256.png +EA ./assets/bricksx64.png + +C 100,100,200 + +1111111 +1000001 +1N00001 +1111111 \ No newline at end of file diff --git a/maps/invalid/missing_wall_texture.cub b/maps/invalid/missing_wall_texture.cub new file mode 100644 index 0000000..0dc58cf --- /dev/null +++ b/maps/invalid/missing_wall_texture.cub @@ -0,0 +1,11 @@ +WE ./assets/bricks2.png +SO ./assets/stonewall256.png +EA ./assets/bricksx64.png + +F 90,30,30 +C 100,100,200 + +1111111 +1000001 +1N00001 +1111111 \ No newline at end of file diff --git a/maps/invalid/no_player.cub b/maps/invalid/no_player.cub new file mode 100644 index 0000000..a9b5eda --- /dev/null +++ b/maps/invalid/no_player.cub @@ -0,0 +1,12 @@ +NO ./assets/bricks2.png +WE ./assets/bricks2.png +SO ./assets/stonewall256.png +EA ./assets/bricksx64.png + +F 90,30,30 +C 100,100,200 + +1111111 +1000001 +1000001 +1111111 \ No newline at end of file diff --git a/maps/invalid/not_enclosed_map.cub b/maps/invalid/not_enclosed_map.cub new file mode 100644 index 0000000..6edf4e5 --- /dev/null +++ b/maps/invalid/not_enclosed_map.cub @@ -0,0 +1,12 @@ +NO ./assets/bricks2.png +WE ./assets/bricks2.png +SO ./assets/stonewall256.png +EA ./assets/bricksx64.png + +F 90,30,30 +C 100,100,200 + +1111111 +1000001 +0E00001 +1111111 \ No newline at end of file diff --git a/maps/invalid/test.cub b/maps/invalid/test.cub new file mode 100644 index 0000000..5b6493e --- /dev/null +++ b/maps/invalid/test.cub @@ -0,0 +1,12 @@ +NO ./assets/bricks2.png +WE ./assets/bricks2.png +SO ./assets/stonewall256.png +EA ./assets/bricksx64.png + +F 90,30,30 +C 100,100,200 + +1111111 +100W001 +1N00001 +1111111 \ No newline at end of file diff --git a/maps/simple.cub b/maps/simple.cub new file mode 100644 index 0000000..98c83aa --- /dev/null +++ b/maps/simple.cub @@ -0,0 +1,12 @@ + +WE ./assets/bricks2.png +SO ./assets/stonewall256.png +EA ./assets/bricksx64.png + +F 90,30,30 +C 100,100,200 + +1111111 +1000001 +1N00001 +1111111 \ No newline at end of file diff --git a/test.log b/test.log new file mode 100644 index 0000000..9ba3db9 --- /dev/null +++ b/test.log @@ -0,0 +1,10 @@ +KO! maps/invalid/double_floor_color.cub +OK! maps/invalid/double_player.cub +KO! maps/invalid/double_wall_texture.cub +KO! maps/invalid/empty_line_in_map.cub +OK! maps/invalid/invalid_color.cub +KO! maps/invalid/missing_floor_color.cub +KO! maps/invalid/missing_wall_texture.cub +KO! maps/invalid/no_player.cub +KO! maps/invalid/not_enclosed_map.cub +OK! maps/invalid/test.cub diff --git a/test.sh b/test.sh new file mode 100755 index 0000000..ff1232e --- /dev/null +++ b/test.sh @@ -0,0 +1,31 @@ +#!/bin/bash + +# Define the directory and log file +bu='\033[4;34m' +rb='\033[1;31m' +gb='\033[1;32m' +reset='\033[0m' +INVALID_DIR="maps/invalid" +LOG_FILE="test.log" + +# Overwrite the log file +> "$LOG_FILE" + +# Iterate through all files in the invalid directory +for file in "$INVALID_DIR"/*; do + test_name=$(basename "$file" | sed -e 's/\..*$//') + echo -e "${bu}Testing $test_name...${reset}" + # Run the file with ./cub3D and send SIGINT after 1 second + timeout 1 ./cub3D "$file" > /dev/null 2>&1 + if [ $? -eq 1 ]; then + # Print OK! [filename] if exit status is 1 + echo -e "${gb}OK!${reset} $test_name" + echo "OK! $file" >> "$LOG_FILE" + else + # Print KO! [filename] and append the file name to the log file if exit status is not 1 + echo -e "${rb}KO!${reset} $test_name" + echo "KO! $file" >> "$LOG_FILE" + fi + echo "----------------------------------------" + echo "" +done \ No newline at end of file