Skip to content

Jacobbishopxy/catch2-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cache2 Template

Installation

  • MacOS: brew install catch2

  • Ubuntu: sudo apt install catch2

Usage

  1. build:

    cd build
    cmake ..
    make
  2. test one executable:

    tests/test
  3. test specific test case:

    tests/test "factorial test #2"

    or test specific tag:

    tests/test --list-tags
    tests/test \[one]

CMake

  • ./src/CMakeLists.txt includes files as lib:

    add_library(fct factorial.cpp)  # lib name: fct
    add_library(bnm binomial.cpp)   # lib name: bnm
  • ./tests/CMakeLists.txt adds executable and links libs (works for multiple executables with their libraries):

    add_executable(
      test # name of the executable
      test_factorial.cpp
      test_binomial.cpp
    )
    
    target_link_libraries(
      test # linking libraries from `src/CMakeLists.txt`
      fct
      bnm
      Catch2::Catch2WithMain
    )
  • ./CMakeLists.txt main file:

    cmake_minimum_required(VERSION 3.10)
    
    project(Catch2Template LANGUAGES CXX VERSION 0.0.1)
    
    find_package(Catch2 REQUIRED)
    
    include_directories(include)
    
    add_subdirectory(src)
    add_subdirectory(tests)

References

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published