Skip to main content

All Questions

Tagged with
Filter by
Sorted by
Tagged with
0 votes
0 answers
89 views

Using doctest with c++, where can I place initialization code?

I'm using doctest with DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN defined so that doctest provides its own main function when I run tests. It's been working great this way but now I need to run some setup ...
Tom 's user avatar
  • 175
0 votes
0 answers
171 views

Unable to open source file "doctest/doctest.h" and "cxxopts.hpp"

I created a repository from the template provided on https://github.com/TheLartians/ModernCppStarter I clone the repo and opened it using CLION and visual studio code. I expected that both the ...
HipocratesTheDoc's user avatar
3 votes
1 answer
553 views

Dedicated main() for doctest.h but with tests also written in production code in C++

I'm under the impression this functionality exists on doctest but I wasn't able to implement it, and I'm not even sure anymore if this is possible. I already have read a lot of references, but failed ...
Vinícius Ferrão's user avatar
1 vote
1 answer
800 views

Unable to compile doctest's `CHECK_THROWS_AS` with Visual Studio 2019

Consider the following code using doctest.h C++ unit test library: #define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include "doctest.h" TEST_CASE("") { CHECK_THROWS_AS(throw 0, int);...
yeputons's user avatar
  • 9,228
0 votes
1 answer
2k views

Linker error when using cmake and doctest.h (it's working without cmake)

I have 3 files in my directory "project": doctest.h - the testing library, doctest_main.cpp - a file needed for the library, and tests.cpp - the file with tests. project/doctest_main.cpp: #...
rvedtsaneon's user avatar
0 votes
1 answer
860 views

Code::Blocks 20.03 + MinGW bug? "Entry point could not be located in the dynamic link library", but target is an exe console app

I am creating a suite of small unit test projects using Code::Blocks IDE bundled with MINGW and doctest as the unit test framework. Under Code::Blocks v17.12, everything builds and runs as expected, ...
lapem's user avatar
  • 1
0 votes
1 answer
39 views

function not taken into account (w. makefile)

==> I tried to resume a long long code, so all the other functions than the concerned ones are already tested and are working! All the #include are okay too an Ant is : #ifndef ANT_HPP #define ...
piau's user avatar
  • 3
0 votes
0 answers
454 views

Printing the output straight from makefile to a .txt file

I have a test.cpp file that test my class, then I have a Makefile that I use to run my program AND run my tests (after running the tests, the result should be written into a .txt file as well as into ...
Aldomond's user avatar
  • 171
0 votes
1 answer
401 views

My tests never stop when using CMake and C++. How to test a program without starting its main function?

I recently started C++ with a little project of PuyoPuyo game (a kind of tetris) within the terminal. I'm using ncurses to play with the terminal and I have a loop that turns indefinitely when I ...
Th0rgal's user avatar
  • 905
2 votes
1 answer
1k views

How to unit-test for assert() failing?

I want to unit-test some code which uses assert() occasionally. Specifically, I want to make sure that certain commands do indeed trigger an assert. But - I don't actually want the program to be ...
einpoklum's user avatar
  • 130k
1 vote
1 answer
916 views

How do I write a doctest test case with a value template?

In doctest, the C++ testing framework, we can write: TEST_SUITE("foo") { TEST_CASE_TEMPLATE("bar", T, t1, t2, t3) { /* code using template parameter T */ } } and this works - if t1,...
einpoklum's user avatar
  • 130k
8 votes
2 answers
3k views

CMake: prevent building test executable target in subdirectory library project

I have written a small library that uses doctest. In CMakeLists.txt I have: ... add_library(my_lib STATIC ${SRCS} $<TARGET_OBJECTS:common_files>) add_executable(tests ${SRCS} $<...
PaulR's user avatar
  • 726
0 votes
1 answer
1k views

Both DocTest and Catch 2 not running unit test

I'm starting a new win32 C++ project using Visual Studio 2019 (v. 16.0.4) and Resharper (v. 2019.1.1) and can't get either the Catch2 or Doctest unit testing framework to run a test. I prefer Doctest ...
pro3carp3's user avatar
  • 803
7 votes
2 answers
4k views

Where to put implementation when using Doctest alongside code

I'm using doctest for the tests in my C++ project. I would like to put the test code alongside my implementations, as the library says is possible, but I can't seem to figure out what to do with the ...
Omegastick's user avatar
  • 1,902
12 votes
6 answers
2k views

C++ equivalent to Python's doctests?

I think the concept of Python's doctests is brilliant, and as a C++ programmer at a real-time shop, I'm quite jealous. We basically have no unit test capability, which is a severe hindrance. I've ...
user59513's user avatar
  • 131