A simple and minimalistic C++ project template to kickstart your C++ development.
Includes a basic structure, style enforcement, static analysis, unit testing, and a convenient Makefile workflow.
This project follows the Google C++ Style Guide to maintain consistent and clean code.
Before using this template, install the following tools:
sudo apt-get install -y astyle
sudo apt-get install -y cppcheckSets up the initial folder structure (e.g., build directory, etc.)
make initmake buildmake runmake cleanUnit tests are written using a simple macro-based testing framework included in the template.
-
Create a new file named
Test_<YourTestName>.hpp. -
Include the base test header:
#include "TestBase.hpp"
-
Define your test suite using the
UNIT_TEST(<TestName>)macro. -
Add your test cases using the
TEST(<FunctionName>)macro.- Names must be valid function names and must be unique.
UNIT_TEST(MyMathTest)
TEST(Addition) {
assert(2 + 2 == 4);
}
TEST(Subtraction) {
assert(5 - 3 == 2);
}- Include your test file in
main.cppat the top:
#include "Test_MyMathTest.hpp"make unit-testAutomatically format all source files using AStyle:
make formatRun static analysis with Cppcheck:
make analysegit checkout -b "dev/<branch-name>"or
git branch dev/<branch-name>
git checkout dev/<branch-name>git add <file(s)>
git commit -m "<commit message>"
git pushgit pullgit checkout main
git pull
git merge -m "<merge message>" dev/<branch-name>
git push- Branches:
dev/<feature-or-topic-name> - Files: Use lowercase and underscore for filenames (e.g.,
hello_world.hpp) - Classes: PascalCase (e.g.,
HelloWorld) - Variables/Functions: camelCase (e.g.,
printMessage,messageText) - Constants: UPPER_CASE_WITH_UNDERSCORES (e.g.,
MAX_BUFFER_SIZE)