Testing and Debugging
The GLEED2D project provides testing and debugging features that facilitate the development process. This section outlines the available tools and methods.
Unit Testing
- GLEED2D uses Google Test for unit testing.
- Unit tests are located in the
test
directory. - They aim to verify the correctness of individual functions and classes.
- To run the unit tests, use the following command:
make test
- The
make test
command builds the unit tests and executes them. The output will indicate the test results, including any failures.
Debugging
- GLEED2D relies on GDB for debugging.
- You can use the GDB debugger to step through the code, inspect variables, and set breakpoints.
- Use the following commands to run the GDB debugger on the GLEED2D executable:
make gdb
gdb gleed2d
- Once in the GDB debugger, you can use commands like
run
,next
,step
,print
, andbreak
to examine and control the program execution.
Debugging Visuals
- For visual debugging, GLEED2D leverages GLEW and GLFW.
- You can use these libraries to render debug information directly within the application’s graphical output.
- GLEED2D offers several debug rendering options, including:
- Bounding Box Visualization: Enables visualization of the bounding boxes for game objects, helping identify potential collision issues.
- Grid Rendering: Allows for rendering of the grid used for object placement, simplifying visual understanding of the level structure.
- Collision Debugging: Displays debug information related to collisions, assisting in resolving collision detection issues.
Using the Debugger
- Setting Breakpoints: Breakpoints can be set at specific lines of code using the
break
command in GDB. This allows you to pause execution and inspect the state of the program at a particular point.
Example:
(gdb) break main.cpp:20
- Stepping Through Code: You can use the
next
andstep
commands to navigate through the code execution line by line.
Example:
(gdb) next
(gdb) step
- Inspecting Variables: Use the
print
command to inspect the values of variables during execution.
Example:
(gdb) print myVariable
- Using Debug Rendering: The debug rendering options can be toggled within the GLEED2D editor.
Logging
- GLEED2D employs a logging system to provide insights into the application’s behavior.
- Log messages are written to a log file, offering valuable information during debugging.
Example:
#include <logger.hpp>
int main() {
Logger::Log("Info", "Application Started");
// ...
}
Documentation
- Detailed explanations of the GLEED2D codebase are available within the source files as comments.
- Refer to the
gleed2d.h
andgleed2d.cpp
files for comprehensive explanations of key components. - You can also refer to the GLEED2D GitHub repository for additional information and resources.