Skip to content

Commit

Permalink
Add DocTestRegister.cpp as a library file (should register all files …
Browse files Browse the repository at this point in the history
…that contain testst)

Call it from doctest_main.cpp
  • Loading branch information
Pascal Thomet committed Jun 5, 2016
1 parent 33df417 commit 5f42f75
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 8 deletions.
2 changes: 1 addition & 1 deletion MyLibrary/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
set(sources lib1.cpp lib2.cpp)
set(sources lib1.cpp lib2.cpp DocTestRegister.cpp)
add_library(MyLibrary STATIC ${sources})
set_property(TARGET MyLibrary PROPERTY CXX_STANDARD 11)
target_include_directories(MyLibrary PUBLIC ${CMAKE_SOURCE_DIR}/doctest/doctest )
Expand Down
11 changes: 11 additions & 0 deletions MyLibrary/DocTestRegister.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

int DocTestRegister_lib1();
int DocTestRegister_lib2();

int DocTestRegister()
{
int sum;
sum += DocTestRegister_lib1();
sum += DocTestRegister_lib2();
return sum;
}
2 changes: 1 addition & 1 deletion MyLibrary/lib1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#define DEBUG // Quick hack against DOCTEST_BREAK_INTO_DEBUGGER not being defined
#include "doctest.h"

int DocTestRegister1() {
int DocTestRegister_lib1() {
return 1;
}

Expand Down
2 changes: 1 addition & 1 deletion MyLibrary/lib2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include "doctest.h"


int DocTestRegister2() {
int DocTestRegister_lib2() {
return 1;
}

Expand Down
7 changes: 2 additions & 5 deletions doctest_main/doctest_main.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
#define DOCTEST_CONFIG_IMPLEMENT
#include "doctest.h"


int DocTestRegister1();
int DocTestRegister2();
int DocTestRegister();

int main(int argc, char** argv) {
doctest::Context context(argc, argv);
Expand All @@ -12,7 +10,6 @@ int main(int argc, char** argv) {
if(context.shouldExit())
return res;

DocTestRegister1();
DocTestRegister2();
DocTestRegister();
return res;
}

0 comments on commit 5f42f75

Please sign in to comment.