A simple command-line calculator that adds two numbers together.
SumCLI is a lightweight C-based command-line tool that performs addition of two numbers. It accepts two numeric arguments and returns their sum with two decimal places precision.
- ✅ Add two numbers (integers or decimals)
- ✅ Input validation and error handling
- ✅ Help documentation
- ✅ Automated testing with TUI Test framework
- ✅ CI/CD pipeline with compliance checks
- C compiler (GCC or Clang)
- CMake (for building)
- Node.js and npm (for running tests)
-
Clone the repository:
git clone https://github.com/Interes-Group/cli_testing_poc cd cli_testing_poc -
Create build directory and compile:
mkdir build cd build cmake .. make
It can be compiled with only gcc compiler
gcc -std=c17 -o sumcli -Wall -Wextra main.c - The executable
sumcliwill be created in the build directory.
sumcli <first_number> <second_number># Add two integers
./sumcli 5 3
# Output: The sum is 8.00
# Add decimal numbers
./sumcli 2.5 1.7
# Output: The sum is 4.20
# Add negative numbers
./sumcli -10 15
# Output: The sum is 5.00./sumcli
# Shows usage information and help textThe application provides clear error messages for common issues:
- Too few arguments: Displays error message and help when less than 2 numbers are provided
- Too many arguments: Displays error message and help when more than 2 numbers are provided
- Invalid input: Uses
atof()which handles invalid numeric input gracefully
This project uses the Microsoft TUI Test framework for automated testing.
cd test
npm install
npm testThe test suite includes:
- Snapshot testing for output verification
- Various input scenarios validation
- Error condition testing
Tests are configured in test/tui-test.config.js and test cases are defined in test/sumcli.test.js.
poc_for_testing_cli_app/
├── main.c # Main source code
├── CMakeLists.txt # Build configuration
├── test/ # Test directory
│ ├── sumcli.test.js # Test cases
│ ├── tui-test.config.js # Test configuration
├── .github/workflows/ # CI/CD configuration
└── README.md # This file
- Fork the repository
- Create a feature branch
- Make your changes
- Run tests to ensure they pass
- Submit a pull request
The project includes GitHub Actions workflow for:
- Automated compliance checks
- Build verification
- Test execution
See LICENSE.txt for license information.
- C99 compatible compiler
- Standard C library
- CMake 3.0 or higher (for building)
- Node.js 16+ (for testing)