Skip to content
Snippets Groups Projects
Commit 461e92ab authored by Wuttke, Joachim's avatar Wuttke, Joachim
Browse files

move template files out of UnitTests.cmake

parent 48f8930b
Branches
Tags
No related merge requests found
#ifdef _MSC_VER
#define _VARIADIC_MAX 10
#endif
#include "gtest/gtest.h"
#include "FitParameterTest.h"
#include "FitParameterLinkedTest.h"
#include "MinimizerOptionsTest.h"
#include "FitObjectTest.h"
struct ErrorStreamRedirect {
ErrorStreamRedirect( std::streambuf * new_buffer )
: old( std::cerr.rdbuf( new_buffer ) )
{ }
~ErrorStreamRedirect( ) {
std::cerr.rdbuf( old );
}
private:
std::streambuf * old;
};
int main(int argc, char** argv)
{
::testing::InitGoogleTest(&argc, argv);
// redirect std::cerr stream
std::stringstream oss;
ErrorStreamRedirect redirecter( oss.rdbuf() );
(void)redirecter;
// run all google tests
return RUN_ALL_TESTS();
}
......@@ -23,45 +23,14 @@ function(UNIT_TESTS TEST_NAME SUBDIR LINK_LIB)
list(SORT INCLUDE_FILES)
# Compose main program (C++ snippets plus #include's of test code from SUBDIR)
set(TMP "/* Generated by CMake. Do not edit. */
#ifdef _MSC_VER
#define _VARIADIC_MAX 10
#endif
#include <gtest/gtest.h>
")
file(READ "${CMAKE_MODULE_PATH}/unitTests.cpp.header" TMP)
foreach(FILE ${INCLUDE_FILES})
set(TMP "${TMP}#include \"${FILE}\"\n")
endforeach()
set(TMP "${TMP}
struct ErrorStreamRedirect {
ErrorStreamRedirect( std::streambuf * new_buffer )
: old( std::cerr.rdbuf( new_buffer ) )
{ }
~ErrorStreamRedirect( ) {
std::cerr.rdbuf( old )\;
}
private:
std::streambuf * old\;
}\;
int main(int argc, char** argv)
{
std::cout << \"UnitTest::main ...\\n\"\;
::testing::InitGoogleTest(&argc, argv)\;
// redirect std::cerr stream
std::stringstream oss\;
ErrorStreamRedirect redirecter( oss.rdbuf() )\;
(void)redirecter\;
// run all google tests
return RUN_ALL_TESTS()\;
}
")
file(READ "${CMAKE_MODULE_PATH}/unitTests.cpp.footer" TMPTMP)
set(TMP "${TMP}\n${TMPTMP}")
set(TEST_SRC "_${TEST_NAME}.cpp")
file(WRITE ${TEST_SRC} ${TMP})
file(WRITE ${TEST_SRC} "${TMP}")
set(EXE ${TEST_NAME})
add_executable(${EXE} ${TEST_SRC})
......
#ifdef _MSC_VER
#define _VARIADIC_MAX 10
#endif
#include "gtest/gtest.h"
#include "1/_IncludableTests.h" // generated by CMake
struct ErrorStreamRedirect {
ErrorStreamRedirect( std::streambuf * new_buffer )
: old( std::cerr.rdbuf( new_buffer ) )
......
/* Generated by CMake module UnitTests.cmake. Do not edit. */
#ifdef _MSC_VER
#define _VARIADIC_MAX 10
#endif
#include <gtest/gtest.h>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment