boost-test

Boost test case and suite fixtures in manually defined suite tree

时光总嘲笑我的痴心妄想 提交于 2019-12-08 01:38:26
问题 Using Boost 1.46.1 on Windows x86, Android TI 2.2 I have defined my own test suite tree, since I need the user to choose order of the tests. although I'm aware the tests should be independent, this is a requirement. The test suite tree was redefined using my own implementation of test_suite* init_unit_test_suite(int, char**) . For automated test cases and automated test suites, there are Boost macros: BOOST_FIXTURE_TEST_CASE and BOOST_FIXTURE_TEST_SUITE( suite_name, F ) . These macros

Best practice using boost test and tests that should not compile

百般思念 提交于 2019-12-08 00:04:04
问题 I'm looking for a reasonable approach to test C++ template based software, where I want to check template arguments. If the argument do not fit certain criteria, I want the compiler to issue an error. So far so good... Now I want to test that invalid template parameters are indeed revoked by the compiler. I could setup a single test scenario and fiddle something within the build system (cmake) that tries to compile the scenario, but this sounds very painful. I think I'm not the first who

What is the better way to generate test report in a file using BOOST.Test?

风流意气都作罢 提交于 2019-12-07 15:44:46
问题 I know by default report is directed to standard-error, and so one has to redirect it to a file. My question is shall we do this inside a global fixture? Which isn't seem to be working for me some how. This is what i tried - struct MyConfig { MyConfig() : testReport("fileName.log") { if(!testReport.fail()) original = std::cerr.rdbuf(testReport.rdbuf()); } ~MyConfig() { cerr.rdbuf(original); testReport.close(); } ofstream testReport; streambuf* original; }; BOOST_GLOBAL_FIXTURE(MyConfig);

Testing a DLL with Boost::Test?

China☆狼群 提交于 2019-12-07 06:59:18
问题 I am developing a DLL in C++ and want to perform unit testing of that DLL using the Boost Test Libraries. I read the Boost test manual thoroughly but since I am new, I have the following question: Should I add test classes in the same VC project in which I am developing my DLL?. Ideally I want to do this but I am confused that a DLL has no main() and, on the other hand, the Boost test needs its own main() to execute. So where does the Boost test output go in this scenario? (In fact, I

Boost test case and suite fixtures in manually defined suite tree

*爱你&永不变心* 提交于 2019-12-06 13:46:23
Using Boost 1.46.1 on Windows x86, Android TI 2.2 I have defined my own test suite tree, since I need the user to choose order of the tests. although I'm aware the tests should be independent, this is a requirement. The test suite tree was redefined using my own implementation of test_suite* init_unit_test_suite(int, char**) . For automated test cases and automated test suites, there are Boost macros: BOOST_FIXTURE_TEST_CASE and BOOST_FIXTURE_TEST_SUITE( suite_name, F ) . These macros register the function to the framework::master_test_suite() , which is undesired behavior in this case. Global

Does the Boost testing framework support test dependencies?

廉价感情. 提交于 2019-12-06 05:26:26
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 various hints that Boost supports this feature, but I've yet to find a documentation page or any concrete

Problem with BOOST_CHECK_CLOSE_FRACTION

天涯浪子 提交于 2019-12-06 03:46:29
问题 I'm using the Boost::Test library, and I am trying to check if an actual percent value is close to the expected value: BOOST_CHECK_CLOSE_FRACTION( items[i].ExpectedPercent, items[i].ActualCount / totalCount, 0.05); For some reason this check fails even when the values are close enough: difference between items[i].ExpectedPercent{0.40000000000000002} and items[i].ActualCount / totalReturned{0.42999999999999999} exceeds 0.050000000000000003 Is this a problem with Boost or a problem with how I

Running Boost unit tests on different processes

独自空忆成欢 提交于 2019-12-06 03:46:21
问题 I want to do unit testing in a SystemC program. The idea is to have multiple test suites with several tests in each suite. Each one of the tests would require resetting the SystemC framework (e.g., by calling sc_simcontext::reset() ), but that is actually not possible due to some bug that is apparently not going to be fixed anytime soon. Therefore, I decided to come up with a workaround. I found out that if I run each test on a different process everything works fine. The following code

What is the better way to generate test report in a file using BOOST.Test?

守給你的承諾、 提交于 2019-12-06 02:51:01
I know by default report is directed to standard-error, and so one has to redirect it to a file. My question is shall we do this inside a global fixture? Which isn't seem to be working for me some how. This is what i tried - struct MyConfig { MyConfig() : testReport("fileName.log") { if(!testReport.fail()) original = std::cerr.rdbuf(testReport.rdbuf()); } ~MyConfig() { cerr.rdbuf(original); testReport.close(); } ofstream testReport; streambuf* original; }; BOOST_GLOBAL_FIXTURE(MyConfig); After running the test, report outputs on console only, though a 0kb file is created with the given name.

Boost's data-driven tests' join operator `+` corrupts first column

泄露秘密 提交于 2019-12-06 01:54:27
问题 Consider the following code: BOOST_DATA_TEST_CASE( sampleTest, (data::make(1) ^ data::make(2)) + (data::make(3) ^ data::make(4)), var1, var2) { std::cout << var1 << "," << var2 << std::endl; } The output I expect is: 1,2 3,4 However, var1 appears to be corrupt: $> ./MyTests --run_test=Tests/sampleTest Running 2 test cases... 202875304,2 202875304,4 *** No errors detected $> ./MyTests --run_test=Tests/sampleTest Running 2 test cases... 83976616,2 83976616,4 *** No errors detected Am I doing