This repo contains two simple calculator implementations โ one in Python and one in C++ โ each with their own unit tests and GitHub Actions workflows.
.
โโโ cpp-unit-test/
โ โโโ calculator.cpp
โ โโโ calculator.h
โ โโโ test_calculator.cpp
โ โโโ catch_amalgamated.hpp / .cpp
โ โโโ main.cpp
โโโ python-unit-test/
โโโ calculator.py
โโโ test_calculator.py
โโโ main.py
cd python-unit-test
uv syncuv run main.pyUsage:
- Type an operation (
add,subtract,multiply,divide) - Enter two numbers
- Type
exitto quit
Example:
Enter operation: add
Enter first number: 5
Enter second number: 3
Result: 8.0
cd cpp-unit-test
g++ -std=c++17 main.cpp calculator.cpp -o calculator_app
./calculator_appUsage:
Same as Python โ type an operation name and numbers interactively.
Handles divide-by-zero errors gracefully.
cd python-unit-test
uv syncpytest -vOptions:
-vโ verbose (shows each test)-qโ quiet (only summary)-xโ stop after first failure
cd cpp-unit-test
curl -L -o catch_amalgamated.hpp https://github.com/catchorg/Catch2/releases/download/v3.6.0/catch_amalgamated.hpp
curl -L -o catch_amalgamated.cpp https://github.com/catchorg/Catch2/releases/download/v3.6.0/catch_amalgamated.cppg++ -std=c++17 catch_amalgamated.cpp test_calculator.cpp calculator.cpp -o tests
./tests -s -v highOptions:
-sโ showstd::coutoutput-v highโ high verbosity (shows each assertion and section)--list-reportersโ list available reporters (e.g.,console,xml)
Both projects include GitHub Actions workflows that:
- Automatically build and run tests on every push and pull request
- Use Python 3.12 and GCC 17 respectively
- Fail the workflow if any test fails
โ Summary
| Project | Run App | Run Tests | Framework |
|---|---|---|---|
| Python | python main.py |
pytest -v |
pytest |
| C++ | ./calculator_app |
./tests -s -v high |
Catch2 v3 |