![]() |
The NEW Pong Game V13.2.1
An interesting implemnettaion of the pong game
|
Test suite for the Ball classes functionality. More...
#include "../ball_base.hpp"
#include "../classic_ball.hpp"
#include "../square_ball.hpp"
#include "../triangle_ball.hpp"
#include "../paddle.hpp"
#include "../user.hpp"
#include <cassert>
#include <iostream>
#include <SDL.h>
Functions | |
void | cleanup_sdl () |
Cleans up SDL resources. | |
int | main () |
Main test runner function. | |
bool | setup_sdl () |
Sets up the SDL environment for tests. | |
void | test_ball_boundaries () |
Tests ball collision boundaries. | |
void | test_ball_color () |
Tests color change functionality. | |
void | test_ball_initialization () |
Tests the BallBase initialization and getters. | |
void | test_ball_movement () |
Tests position and velocity setters and getters. | |
void | test_ball_rendering () |
Tests the rendering of different ball types. | |
void | test_ball_reset () |
Tests the ball reset functionality. | |
void | test_ball_sizes () |
Tests that different ball subclasses have correct sizes. | |
Variables | |
SDL_Renderer * | renderer = nullptr |
SDL_Window * | window = nullptr |
Test suite for the Ball classes functionality.
This file contains tests for verifying the proper functionality of our Ball classes hierarchy. We test the base class functionality and derived class implementations.
void cleanup_sdl | ( | ) |
Cleans up SDL resources.
Destroys the renderer and window, and quits SDL
int main | ( | ) |
Main test runner function.
Executes all Ball class tests and reports results.
bool setup_sdl | ( | ) |
Sets up the SDL environment for tests.
Initializes SDL, creates a hidden window, and sets up a renderer for testing ball rendering functionality.
void test_ball_boundaries | ( | ) |
Tests ball collision boundaries.
Ensures that the ball's collision rectangle is properly calculated.
void test_ball_color | ( | ) |
Tests color change functionality.
Verifies that ball color can be properly set and retrieved.
void test_ball_initialization | ( | ) |
Tests the BallBase initialization and getters.
Verifies that the ball is initialized at the center of the screen, with proper size and non-zero velocities.
void test_ball_movement | ( | ) |
Tests position and velocity setters and getters.
Ensures we can properly set and retrieve ball position and velocity.
void test_ball_rendering | ( | ) |
Tests the rendering of different ball types.
Verifies that each ball type can be rendered without errors. Note: This only tests that the render call doesn't crash, not the actual visual appearance.
void test_ball_reset | ( | ) |
Tests the ball reset functionality.
Checks if the ball correctly resets to center position and gets a new random direction.
void test_ball_sizes | ( | ) |
Tests that different ball subclasses have correct sizes.
Each ball type can have its own default size, this test verifies they're initialized correctly.
SDL_Renderer* renderer = nullptr |
SDL_Window* window = nullptr |