Questions tagged [catch2]

Catch is a unit testing framework for C++

Catch2 offers a BDD syntax, fixtures, Matchers and dynamic data-generation, and a simplified syntax using overloaded assertions. Catch2 is designed for simplicity – it is released as a single include file and allows the use of natural C++ expressions inside assertions.

Catch2 is hosted on GitHub, available at catch-lib.net, and is openly discussed in a Google group.

153 questions
0
votes
1 answer

How do I iterate over all permutations of compile-time parameters in Catch2?

I have a function that I want to test for each possible input with Catch2. This function has multiple compile-time constants as its parameter. For simplicity, let's say I have two enums enum class A { a, b}; enum class B { a, b}; and the…
Stefan Groth
  • 154
  • 7
0
votes
0 answers

unable to catch2 hello test on mac running Apple LLVM version 10.0.1

Im only trying my tutorial to try catch2 unit testing lib. Im using mac with 10.14. I dont have full XCode, only cmd tools and macports runs perfect in my setup (no brew). Im using the amalgamated single header and source file as suggested. Yet, a…
thevikas
  • 1,618
  • 1
  • 14
  • 31
0
votes
0 answers

How to run/execute a unit testing framework like "catch2" in Unix Bash?

I am trying to learn testing with makefiles . I searched online for a framework. Many people talked about "catch2" so I downloaded it. I read the tutorial in git and I've searched about it in many other webpages. I wrote this : mytests (without any…
tonythestark
  • 519
  • 4
  • 15
0
votes
1 answer

CMake Error: The source directory "/" does not appear to contain CMakeLists.txt while building docker image

I'm currently trying to install a Catch2 on a Docker Image, for a project that I need to install. This is the Dockerfile that I currently have, FROM ubuntu:20.04 ENV TZ=some/loc RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ >…
Karthik Prakash
  • 153
  • 4
  • 11
0
votes
1 answer

Catch2: Overloaded stream operator not recognized by INFO after moving class into namespace

in my code I overloaded the stream operator for a class ByteArray (which is simply a vector of bytes). // myfile.hpp using ByteArray_t = std::vector; std::ostream &operator<<(std::ostream &os, const ByteArray_t &array); ... //…
Oliver
  • 1
0
votes
1 answer

Shared library problems between C++11 and C++14

I have had to switch from C++11 to C++14 in my project to use the Catch testing framework, written for C++14 (it doesn't compile with anything less). Everything compiles fine. However, while running the program, the following function causes a…
0
votes
1 answer

How to use TEMPLATE_TEST_CASE with pairs of types?

I am trying to use catch2 TEMPLATE_TEST_CASE for pairs of types, i.e. instead of templating a single type for each test, I need to use a correlated pair of types. I thought I could use std::variant to store these pairs, but compilation fails with:…
Armut
  • 969
  • 8
  • 22
0
votes
1 answer

Why is "==" not acceptable here?

I'm writing a unit test and comparing two objects to ensure they're the same but am getting the error no operator "==" matches these operands -- operand types are: Item == Item This is my code with the line in question commented: SCENARIO("A…
askman
  • 447
  • 4
  • 14
0
votes
2 answers

Cannot compile file using catch2 CATCH_CONFIG_MAIN

I've started out learning how to use Catch2 for testing my C++ code and am trying to set up a simple test. My folder structure consists of three files all in the same folder: catch.cpp //this is the catch_amalgamated.cpp file from GitHub catch.hpp…
askman
  • 447
  • 4
  • 14
0
votes
0 answers

Catching errors when Calling a lambda function within another lambda function

I'm able to invoke a lambda function from another lambda function using aws-sdk invoke() function. I wrote both lambda functions. The lambda function I invoke, returns context.fail() in case of any error occurrence. I invoke the lambda function like…
amir
  • 13
  • 2
0
votes
0 answers

CMake find_package for non-standard locations

I am trying to make a self contained library whose dependencies are self contained.All installs are installed to /libs//build. To find dependencies in cmake build system I use find_package. Because all installs are in a custom location I…
user10443822
0
votes
1 answer

catch2 throws and error when adding a struct

This is the root of my project. I think I am missing a basic concept because the error occur when I wrap the the find() function in a struct. CMakeLists.txt bst.cpp bst.hpp bst-test.cpp …
Ramses Aldama
  • 327
  • 1
  • 3
  • 11
0
votes
2 answers

testthat (& Catch) complains in R CMD check that xml2 library is missing

I am using testthat to test my R package (https://github.com/beerda/hexmatrix). Recently, I started C++ testing: I have executed testthat::use_catch(), which should setup the package for unit testing with C++ Catch, and then I wrote some tests. The…
beerda
  • 88
  • 5
0
votes
1 answer

Controlling output of Boost.Test source location format

Catch2 and Boost.Test provide similar features for writing unit tests. For a certain project I have to use Boost.Test instead of Catch2. The problem I have is that both use different format outputs. For example, Catch2 will say that the was a fail…
alfC
  • 14,261
  • 4
  • 67
  • 118
0
votes
1 answer

ctest reports success for test with exit status 1

I have a project with unit tests and when I run ctest (cmake version 3.18.2 on macos), success is reported for all tests. However, if I run one of the tests by itself, it has exit status 1. As far as I know, this shouldn't happen, so what is causing…
Jasper Braun
  • 109
  • 8