Skip to content

Latest commit

ย 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿงฎ Calculator Projects โ€” Python & C++

This repo contains two simple calculator implementations โ€” one in Python and one in C++ โ€” each with their own unit tests and GitHub Actions workflows.


๐Ÿ“ Project Structure

.
โ”œโ”€โ”€ 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

๐Ÿš€ Run the Main Programs

๐Ÿ Python

cd python-unit-test
uv sync
uv run main.py

Usage:

  • Type an operation (add, subtract, multiply, divide)
  • Enter two numbers
  • Type exit to quit

Example:

Enter operation: add
Enter first number: 5
Enter second number: 3
Result: 8.0

๐Ÿงฑ C++

cd cpp-unit-test
g++ -std=c++17 main.cpp calculator.cpp -o calculator_app
./calculator_app

Usage:
Same as Python โ€” type an operation name and numbers interactively.
Handles divide-by-zero errors gracefully.


๐Ÿงช Run Unit Tests

Python Tests

cd python-unit-test
uv sync
pytest -v

Options:

  • -v โ†’ verbose (shows each test)
  • -q โ†’ quiet (only summary)
  • -x โ†’ stop after first failure

C++ Tests

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.cpp
g++ -std=c++17 catch_amalgamated.cpp test_calculator.cpp calculator.cpp -o tests
./tests -s -v high

Options:

  • -s โ†’ show std::cout output
  • -v high โ†’ high verbosity (shows each assertion and section)
  • --list-reporters โ†’ list available reporters (e.g., console, xml)

โš™๏ธ CI Automation

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

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages