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

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

#include "../letter.hpp"
#include "../user.hpp"
#include "../macros.hpp"
#include <cassert>
#include <iostream>
#include <SDL.h>
#include <SDL_ttf.h>

Functions

void cleanup_sdl_ttf ()
 Cleans up SDL and TTF resources.
 
int main ()
 Main test runner function.
 
bool setup_sdl_ttf ()
 Sets up the SDL and TTF environment for tests.
 
void test_letter_collision ()
 Tests the letter collision detection.
 
void test_letter_collision_scoring ()
 Tests the letter collision with player scoring.
 
void test_letter_initialization ()
 Tests the Letter initialization.
 
void test_letter_movement ()
 Tests the letter movement and boundary handling.
 
void test_letter_progression ()
 Tests word and letter progression.
 
void test_letter_rendering ()
 Tests the letter rendering functionality.
 

Variables

TTF_Font * font = nullptr
 
SDL_Renderer * renderer = nullptr
 
SDL_Window * window = nullptr
 

Detailed Description

Test suite for the Letter class functionality.

Authors
Vasileios Filippos Skarleas

Unit tests for verifying the proper functionality of our Letter class, including initialization, movement, collision detection, and word progression.

Function Documentation

◆ cleanup_sdl_ttf()

void cleanup_sdl_ttf ( )

Cleans up SDL and TTF resources.

Destroys the font, renderer, the SDL window, and it quits the TTF and SDL libraries

◆ main()

int main ( )

Main test runner function.

Executes all Letter class tests and reports results.

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

◆ setup_sdl_ttf()

bool setup_sdl_ttf ( )

Sets up the SDL and TTF environment for tests.

Initializes SDL and TTF, creates a hidden window, and sets up a renderer and font for testing letter functionality.

Returns
true if initialization successful, false otherwise

◆ test_letter_collision()

void test_letter_collision ( )

Tests the letter collision detection.

Ensures the collision detection correctly identifies when a ball intersects with the letter boundaries.

◆ test_letter_collision_scoring()

void test_letter_collision_scoring ( )

Tests the letter collision with player scoring.

Ensures that when a letter collides with the ball, the appropriate player gets points and the letter advances.

◆ test_letter_initialization()

void test_letter_initialization ( )

Tests the Letter initialization.

Verifies that a letter is correctly initialized with the provided position, speed, and initial word/letter selection.

◆ test_letter_movement()

void test_letter_movement ( )

Tests the letter movement and boundary handling.

Verifies that letters move correctly according to their speed and respect screen boundaries by bouncing.

◆ test_letter_progression()

void test_letter_progression ( )

Tests word and letter progression.

Checks that next_letter() and next_word() correctly advance to subsequent letters and words.

◆ test_letter_rendering()

void test_letter_rendering ( )

Tests the letter rendering functionality.

Verifies that the letter can be rendered without errors.

Variable Documentation

◆ font

TTF_Font* font = nullptr

◆ renderer

SDL_Renderer* renderer = nullptr

◆ window

SDL_Window* window = nullptr