Skip to content

iwatake2222/googletest_test

Repository files navigation

Sample project for GoogleTest

  • Create a simple calculator with GoogleTest
  • Continuous Integration with GitHub Actions

CI Status

Status Build Type
CMake_x64 windows-latest, ubuntu-latest, macos-latest
CMake_ARM armv7 + ubuntu18.04, aarch64 + ubuntu18.04
CodeQL ubuntu-latest

Class Diagram

For product

  • To test core logic and input/output, make Arithmetic and Prompt module, respectively
  • Calculator module contains these modules
  • However, Calculator module doesn't create these modules. Instead, use dependency injection
    • It's better to have a factory module, but in this project main function creates these modules to make it easy
  • So that, I can use mock modules when running unit test for Calculator module

For calculator unit test

Structure

  • main.cpp
  • calculator/
  • arithmetic/
  • prompt/
  • test/
    • calculator/
    • arithmetic/
    • prompt/

How to

Linux

mkdir -p build && cd build
cmake ..
make
ctest
./main
`>+ 1 2`

Visual Studio

  • Create Visual Studio project using cmake-gui
  • Build the project
  • Normal execution
    • Set main as a startup project
    • Run
    • >+ 1 2
  • Test
    • Open Test Explorer
    • Run All Tests

License

Acknowledgements

  • This project utilizes OSS (Open Source Software)