Simple command-line calculator for basic arithmetic operations.
Install g++, make, gtest, lcov, lcov-cobertura (until lcov is natively supported):
sudo apt-get update
sudo apt-get install g++ cmake make lcov libgtest-dev
pip install lcov_cobertura
Build Google Test
cd /usr/src/gtest
sudo cmake CMakeLists.txt
sudo make
sudo find . -type f -name "*.a" -exec cp {} /usr/lib \;
Compile the calculator:
cmake .
make
Run the calculator:
./calculator # get usage
./calculator --add 5 3 # Replace `--add 5 3` with your operation and operands
Compile the tests with coverage:
cmake .
make
Run tests and generate coverage report:
./test_calculator
lcov --capture --directory . --output-file coverage.info
lcov --remove coverage.info '/usr/*' '*/test_*' --output-file coverage_filtered.info
lcov --list coverage_filtered.info
See build_and_test_with_coverage.sh
for a complete script to build and run the tests with coverage