All Questions
15 questions
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 ...
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 ...
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 ...
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);...
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:
#...
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, ...
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 ...
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 ...
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 ...
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 ...
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,...
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} $<...
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 ...
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 ...
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 ...