boost-test

Can I cause a compile error on “too few initializers”?

孤街浪徒 提交于 2019-12-23 19:38:05
问题 I am using an aggregate initializer to set up a block of static data for a unit test. I would like to use the array size as the expected number of elements, but this can fail if too few initializers are provided: my_struct_type expected[14] = { { 1.234, 0, 'c' }, { 3.141, 1, 'z' }, { 2.718, 0, 'a' } }; This gives no compiler error in Visual Studio 2008. I would like to be able to use it as such: const unsigned expected_size = sizeof(expected) / sizeof(my_struct_type); BOOST_CHECK_EQUAL(points

Is there a way to run C++ Unit Tests tests in parallel?

假如想象 提交于 2019-12-23 07:08:21
问题 I'm using Boost Test for a long time now and I ends up having my tests running too slowly. As each test is highly parallel, I want them to run concurrently with all my cores. Is there a way to do that using the Boost Test Library ? I didn't found any solution. I tried to look a how to write custom test runner, but I didn't much documentation on that point :( If there is no way, does someone know a good C++ Test Framework to achieve that goal ? I was thinking that Google Test would do the job

Does the Boost testing framework support test dependencies?

不打扰是莪最后的温柔 提交于 2019-12-22 11:33:12
问题 One of my favorite unit testing frameworks is PHPUnit because it supports test dependencies (i.e. the ability to mark tests as dependent upon other tests, running the dependent tests conditionally on the success of their dependencies). I've been using the Boost testing framework more recently to test my C++ code, and while it suits most of my unit testing needs, it doesn't appear to support test dependencies. I've scoured the documentation for the Boost testing framework and have found

boost unit test - list available tests

荒凉一梦 提交于 2019-12-22 08:57:48
问题 I've written some scripts to automate the running of our unit tests, written using the boost unit testing framework. I'd like to add functionality to allow the selection and subsequent running of a subset of all tests. I know I can run a subset of tests using the run_test argument, but I can't find a way to list all tests that are in a compiled binary, i.e. all the argument values I can pass to run_test. Is there a way to extract all available tests, or will I have to write a custom test

Boost test does not init_unit_test_suite

僤鯓⒐⒋嵵緔 提交于 2019-12-22 04:07:44
问题 I run this piece of code #define BOOST_TEST_MAIN #define BOOST_TEST_DYN_LINK #include <boost/test/unit_test.hpp> #include <boost/test/unit_test_log.hpp> #include <boost/filesystem/fstream.hpp> #include <iostream> using namespace boost::unit_test; using namespace std; void TestFoo() { BOOST_CHECK(0==0); } test_suite* init_unit_test_suite( int argc, char* argv[] ) { std::cout << "Enter init_unit_test_suite" << endl; boost::unit_test::test_suite* master_test_suite = BOOST_TEST_SUITE(

getting all boost test suites / test cases

假如想象 提交于 2019-12-21 17:33:07
问题 As the title says, I want to get all test suites or test cases (name) from a test application, ether in the console or as xml output. Test framework is the boost test library. Is there an option to achieve this? I did not found anything useful in the documentation. 回答1: This can be done without much intrusion using a global fixture. Assuming you have a translation unit (cpp file) that contains main explicitly or auto generated, you can intercept test execution when a certain command line

Boost::Test — generation of Main()?

蓝咒 提交于 2019-12-21 05:15:08
问题 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

How to set which Boost unit test to run

白昼怎懂夜的黑 提交于 2019-12-12 13:17:07
问题 I am trying to use boost-test, and in particular boost unit testing. I clearly don't understand how is the main function generated and called, all the tutorial says is to define a module and write a test #define BOOST_TEST_MODULE EnfTraderTest BOOST_AUTO_TEST_CASE(CalculateExpectedPriceTest){BOOST_ERROR("Oops");} But, how do I say to my program to run this test ? I already have main function, I would like to decide to run the test or not, from my main function. 回答1: The simplest way to do

Using Boost.Build and Boost.Test - linker errors

∥☆過路亽.° 提交于 2019-12-11 10:59:21
问题 I'm stuck trying to figure out why my tests won't link. I'm using Boost.Build and Boost.Test from Boost 1.59 on Ubuntu. I built and installed the boost libraries from source. I am specifying <library>/boost//unit_test_framework as part of the unit test's usage requirements. My understanding is that this should set all of the linker requirements in order to link with Boost.Test. Unfortunately, I get a heap of linker errors for undefined references to Boost.Test components even though the link

How to tell Boost.Test to stop on first failing test case?

回眸只為那壹抹淺笑 提交于 2019-12-10 02:12:02
问题 I've got a number of Boost test cases ordered in several test suites. Some test cases have one, some more than one check. However, when executing all tests, they all get executed – no matter how many fail or pass. I know, that I can stop the execution of one test case with several checks by using BOOST_REQUIRE instead of BOOST_CHECK . But that's not want I want. How can I tell Boost to stop the whole execution after the first test case failed? I would prefer a compiled solution (e.g. realized