Questions tagged [catch-unit-test]

Catch is a unit testing framework for C++

Catch2 is a unit testing framework for C++11 and later. 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.

93 questions
1
vote
0 answers

How to perform Unit Testing on complicated functions

I have a class XYZ which has some function whivh I need to test using Catch Unit-testing. I am in a state of confusion what can be the possibility to test the function. Can anyone help on this? Test code is below: UaStatus…
user4477835
1
vote
0 answers

C/C++ Project inluding folders containing separate build shells not able to include files from each other

I have a complex C++ Project folder which contains two folders. a C++ src folder with multiple sub-folders and CmakeList.txt file. The src folder contains main.cpp file. a C++ build standard external folder ExtLib containing multipe subfolders and…
user4477835
1
vote
0 answers

catch.hpp error messages with visual studio

Using visual studio 2015 to compile a test code using catch.hpp unit test. I need to write code to interface with serial port and will need to interface with Widnows API and need to include windows.h But compiler generates complains with error…
1
vote
1 answer

Catch not catching exception

I'm using Catch to write unit tests and came across a problem where my test fails because an exception is thrown, even though I use REQUIRE_THROWS_AS. This is my test: SECTION("Get column index for inexistent name") { …
ruipacheco
  • 15,025
  • 19
  • 82
  • 138
1
vote
1 answer

How to bypass assert in unit test in Debug mode?

In a test case I would like to test a function which in debug mode generates an assertion for invalid input. This unfortunately stops Catch test runner. Is there any way to bypass this assertion so that the test runner keeps going ? Here is my test…
tommyk
  • 3,187
  • 7
  • 39
  • 61
1
vote
0 answers

Catch compiles fine with MinGW32, but I get Segmentation Fault

I decided to try writing tests with Catch. I am using MinGW32 in Windows. I used the example file define here (which I reproduce below for convenience): #define CATCH_CONFIG_MAIN // This tells Catch to provide a main() - only do this in one cpp…
vaulttech
  • 493
  • 1
  • 5
  • 15
1
vote
2 answers

Good way to call overloaded const vs non-const method in C++ TDD?

All wrote some fancy container with iterators. So I have iterator begin() { } iterator end() { } const_iterator begin() const { } const_iterator end() const { } In test I instantiate container, fill it and testing it. What is an accepted/good…
Severin Pappadeux
  • 18,636
  • 3
  • 38
  • 64
1
vote
1 answer

Can I use Catch with boost/program_options.hpp?

I have a program that uses boost/program_options.hpp to process command line arguments. I want to add unit-tests to this program, and the Catch framework is very attractive. However, it seems to mess with the command line arguments to my…
a06e
  • 18,594
  • 33
  • 93
  • 169
1
vote
3 answers

Catch unit test library linking error

I am trying to use CATCH unit test suite linked below. https://github.com/philsquared/Catch However, I cannot succeed to make it right. The main.cpp and test.cpp are as follows. //main.cpp #define CATCH_CONFIG_MAIN #include…
Sungmin
  • 2,499
  • 3
  • 26
  • 32
1
vote
1 answer

How to retrieve or print "Catch" info logging buffers?

Using the Catch single-include unit-tester, I have (passing) tests like this TEST_CASE ("sizes", "[metadata]" ) { INFO ( "The number is " << 42 ); REQUIRE (sizeof(some_struct) == 16); } The documentation (linked above) states that the INFO…
Reb.Cabin
  • 5,426
  • 3
  • 35
  • 64
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
1 answer

Class definition marked as not covered

I set up Codecov for a personal (open source) project in Qt. The project is still mostly a stub (barely a couple of classes, and I tried to achieve 100% coverage as of now. However, looking at the headers of these two classes in the Codecov report,…
phagio
  • 196
  • 1
  • 14
0
votes
1 answer

Determine name of current SECTION

We are using Catch as testing framework and are quite satisfied with its usability. I'm planning to implement a series of simple unit tests for a new chart widget. The chart widget can be only tested properly by simple image comparisons. For this I…
Aleph0
  • 5,816
  • 4
  • 29
  • 80
0
votes
1 answer

CMake header only dependency

I am having some trouble running a simple test with catch2 using CMake. Since catch is header only I got the impression that it is easily dropped into any project so i thought I'd just include it like a normal header file. Project structure: …
Tagor
  • 937
  • 10
  • 30
0
votes
3 answers

Acessing data on `inst/extdata` from Rcpp Catch tests

I am trying to access a data file on a inst/extdata file from a Rcpp Catch2 test. The file tree looks like this: ├── inst │   └── extdata │   └── data-sample ├── R │   ├── catch-routine-registration.R │   └── RcppExports.R ├── src    ├──…
Yuri-M-Dias
  • 610
  • 1
  • 11
  • 25