The NEW Pong Game V13.2.1
An interesting implemnettaion of the pong game
Loading...
Searching...
No Matches
paddle_test.cpp File Reference

Test suite for the Paddle class functionality. More...

#include "../paddle.hpp"
#include "../macros.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_paddle_boundaries ()
 Tests the paddle's movement and boundary constraints.
 
void test_paddle_height_adjustment ()
 Tests paddle height adjustment.
 
void test_paddle_initialization ()
 Tests the paddle initialization and constructor.
 
void test_paddle_inverse_power ()
 Tests the inverse power functionality.
 
void test_paddle_position ()
 Tests paddle position setters and getters.
 
void test_paddle_rectangle ()
 Tests the paddle rectangle boundary calculation.
 
void test_paddle_rendering ()
 Tests the paddle rendering functionality.
 

Variables

SDL_Renderer * renderer = nullptr
 
SDL_Window * window = nullptr
 

Detailed Description

Test suite for the Paddle class functionality.

Authors
Vasileios Filippos Skarleas

This file contains unit tests for verifying the proper functionality of our Paddle class, including initialization, movement, rendering, and boundary checks.

Function Documentation

◆ cleanup_sdl()

void cleanup_sdl ( )

Cleans up SDL resources.

Destroys the renderer and window, and quits SDL

◆ main()

int main ( )

Main test runner function.

Executes all Paddle class tests and reports results.

Returns
0 on successful test completion, non-zero on failure

◆ setup_sdl()

bool setup_sdl ( )

Sets up the SDL environment for tests.

Initializes SDL, creates a hidden window, and sets up a renderer for testing paddle rendering functionality.

Returns
true if initialization successful, false otherwise

◆ test_paddle_boundaries()

void test_paddle_boundaries ( )

Tests the paddle's movement and boundary constraints.

Verifies that the paddle movement respects screen boundaries and doesn't allow the paddle to move outside the playable area.

◆ test_paddle_height_adjustment()

void test_paddle_height_adjustment ( )

Tests paddle height adjustment.

Verifies that we can properly change the paddle height (important for power-ups that affect paddle size).

◆ test_paddle_initialization()

void test_paddle_initialization ( )

Tests the paddle initialization and constructor.

Verifies that paddles are initialized with correct position, dimensions, and side placement.

◆ test_paddle_inverse_power()

void test_paddle_inverse_power ( )

Tests the inverse power functionality.

Verifies that the inverse power effect properly reverses the paddle's control direction.

◆ test_paddle_position()

void test_paddle_position ( )

Tests paddle position setters and getters.

Ensures we can properly set and retrieve paddle position.

◆ test_paddle_rectangle()

void test_paddle_rectangle ( )

Tests the paddle rectangle boundary calculation.

Ensures that the collision rectangle is properly calculated for collision detection.

◆ test_paddle_rendering()

void test_paddle_rendering ( )

Tests the paddle rendering functionality.

Verifies that the paddle can be rendered without errors.

Variable Documentation

◆ renderer

SDL_Renderer* renderer = nullptr

◆ window

SDL_Window* window = nullptr