boost-test

Boost::Test — generation of Main()?

我是研究僧i 提交于 2019-12-03 17:03:57
I'm a bit confused on setting up the boost test library. Here is my code: #include "stdafx.h" #define BOOST_TEST_DYN_LINK #define BOOST_TEST_MODULE pevUnitTest #include <boost/test/unit_test.hpp> BOOST_AUTO_TEST_CASE( TesterTest ) { BOOST_CHECK(true); } My compiler generates the wonderfully useful error message: 1>MSVCRTD.lib(wcrtexe.obj) : error LNK2019: unresolved external symbol _wmain referenced in function ___tmainCRTStartup 1>C:\Users\Billy\Documents\Visual Studio 10\Projects\pevFind\Debug\pevUnitTest.exe : fatal error LNK1120: 1 unresolved externals It seems that the Boost::Test library

Visual Studio and Boost::Test

℡╲_俬逩灬. 提交于 2019-12-03 16:58:32
问题 I'm getting started with Boost::Test driven development (in C++), and I'm retrofitting one of my older projects with Unit Tests. My question is -- where do I add the unit test code? The syntax for the tests themselves seems really simple according to Boost::Test's documentation, but I'm confused as to how I tell the compiler to generate the executable with my unit tests. Ideally, I'd use a precompiled header and the header-only version of the boost::test library. Do I just create a new

Testing for assert in the Boost Test framework

痴心易碎 提交于 2019-12-03 11:04:35
问题 I use the Boost Test framework to unit test my C++ code and wondered if it is possible to test if a function will assert? Yes, sounds a bit strange but bear with me! Many of my functions check the input parameters upon entry, asserting if they are invalid, and it would be useful to test for this. For example: void MyFunction(int param) { assert(param > 0); // param cannot be less than 1 ... } I would like to be able to do something like this: BOOST_CHECK_ASSERT(MyFunction(0), true); BOOST

How can I use Boost.Test in a CMake based project?

落花浮王杯 提交于 2019-12-03 08:56:28
问题 My project uses CMake as its build system, and I want it to execute my Boost.Test test cases. How can I achieve that? In Boost.Build, I could do it as follows: import testing ; use-project /my_lib : ../src ; unit-test my_test : my_test.cpp /my_lib boost_unit_test_framework ; lib boost_unit_test_framework ; 回答1: CMake itself is just a build system; CTest is a just test runner that is integrated with CMake. Neither is a unit test framework; that job can be done by Boost.Test or googletest. To

Visual Studio and Boost::Test

三世轮回 提交于 2019-12-03 06:01:59
I'm getting started with Boost::Test driven development (in C++), and I'm retrofitting one of my older projects with Unit Tests. My question is -- where do I add the unit test code? The syntax for the tests themselves seems really simple according to Boost::Test's documentation, but I'm confused as to how I tell the compiler to generate the executable with my unit tests. Ideally, I'd use a precompiled header and the header-only version of the boost::test library. Do I just create a new project for tests and add all my existing source files to it? Billy3 They way I've added Boost unit tests to

Boost test linking

不羁的心 提交于 2019-11-30 10:48:42
问题 I want to use Boost test in my project. I use cmake in my project so I wrote a simple CMakeList.txt for wrapping it: find_package (Boost COMPONENTS unit_test_framework REQUIRED) file(GLOB_RECURSE UnitTests_sources tests/*.cpp) add_executable(UnitTests ${UnitTests_sources} ) enable_testing() ADD_TEST (UnitTests UnitTests) So, cmake works fine here. The trouble becomes during compiling: Linking CXX executable ../../bin/UnitTests /usr/lib/gcc/x86_64-unknown-linux-gnu/4.6.1/../../../../lib/crt1.o

boost test - 'undefined reference' errors

女生的网名这么多〃 提交于 2019-11-30 10:03:31
I have two simple files: runner.cpp: #define BOOST_TEST_DYN_LINK #define BOOST_TEST_MODULE Main #include <boost/test/unit_test.hpp> and test1.cpp: #define BOOST_TEST_DYN_LINK #ifdef STAND_ALONE # define BOOST_TEST_MODULE Main #endif #include <boost/test/unit_test.hpp> BOOST_AUTO_TEST_SUITE( Foo) BOOST_AUTO_TEST_CASE( TestSomething ) { BOOST_CHECK( true ); } BOOST_AUTO_TEST_SUITE_END() To compile, I'm using: $ g++ -I/e/code/boost_1_52_0 -o runner -lboost_unit_test_framework runner.cpp test1.cpp I get the following error: C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\ccU0cDSz.o:runner.cpp:(.text+0x8c):

BOOST_CHECK_EQUAL with pair<int, int> and custom operator <<

喜欢而已 提交于 2019-11-30 09:38:37
When attempting to do a BOOST_CHECK_EQUAL(pair, pair), gcc doesnt find the stream operator for pair, inspite of declaring it. The funny thing is that std::out finds the operator. ostream& operator<<(ostream& s, const pair<int,int>& p) { s << '<' << p.first << ',' << p.second << '>'; return s; } BOOST_AUTO_TEST_CASE(works) { pair<int,int> expected(5, 5); pair<int,int> actual (5, 5); std::cout << expected << std::endl; std::cout << actual << std::endl; BOOST_CHECK(actual == expected); } BOOST_AUTO_TEST_CASE(no_work) { pair<int,int> expected(5, 5); pair<int,int> actual (5, 5); BOOST_CHECK_EQUAL

Using Jenkins with boost.test unit tests

你。 提交于 2019-11-29 23:08:14
I have done a bit of Googling in this area and have found many discussions about getting Jenkins to understand boost.test's XML output format, but no canonical reference. Some people say we simply need to use XLST to convert the XML format, others suggest the XML needs some hacking before that ( Anyone have an XSL to convert Boost.Test XML logs to a presentable format? ). Some suggest the xUnit plugin can natively understand boost.test XML format, others state it can't Because my search results span 5 years, I'm conscious that things could have changed. So I'm seeking an up to date answer

boost test - 'undefined reference' errors

南笙酒味 提交于 2019-11-29 14:53:38
问题 I have two simple files: runner.cpp: #define BOOST_TEST_DYN_LINK #define BOOST_TEST_MODULE Main #include <boost/test/unit_test.hpp> and test1.cpp: #define BOOST_TEST_DYN_LINK #ifdef STAND_ALONE # define BOOST_TEST_MODULE Main #endif #include <boost/test/unit_test.hpp> BOOST_AUTO_TEST_SUITE( Foo) BOOST_AUTO_TEST_CASE( TestSomething ) { BOOST_CHECK( true ); } BOOST_AUTO_TEST_SUITE_END() To compile, I'm using: $ g++ -I/e/code/boost_1_52_0 -o runner -lboost_unit_test_framework runner.cpp test1