Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions cfg/boost.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,12 @@
<define name="BOOST_MATH_INT_TABLE_TYPE" value=""/>
<define name="BOOST_MATH_INT_VALUE_SUFFIX" value=""/>
<!-- Tell cppcheck to interpret BOOST_AUTO_TEST_CASE as a function definition -->
<define name="BOOST_AUTO_TEST_CASE(test_name)" value="void BOOST_AUTO_TEST_CASE_run ## test_name ()"/>
<define name="BOOST_AUTO_TEST_CASE(test_name, ...)" value="void BOOST_AUTO_TEST_CASE_run ## test_name ()"/>
<define name="BOOST_AUTO_TEST_CASE_TEMPLATE(test_name, type_name, TL)" value="template&lt;typename type_name&gt;void test_name()"/>
<define name="BOOST_FIXTURE_TEST_CASE(name, fixture)" value="struct name : fixture { void test_method(); }; void name::test_method()" />
<define name="BOOST_FIXTURE_TEST_CASE(name, fixture, ...)" value="struct name : fixture { void test_method(); }; void name::test_method()" />
<define name="BOOST_FIXTURE_TEST_CASE_TEMPLATE(test_name, type_name, TL, F)" value="template&lt;typename type_name&gt; struct test_name : public F { void test_method(); }; template&lt;typename type_name&gt; void test_name&lt;type_name&gt;::test_method()" />
<define name="BOOST_DATA_TEST_CASE(test_name)" value="void BOOST_DATA_TEST_CASE_run ## test_name ()"/>
<define name="BOOST_DATA_TEST_CASE_F(test_name)" value="void BOOST_DATA_TEST_CASE_F_run ## test_name ()"/>
<define name="BOOST_DATA_TEST_CASE(test_name, ...)" value="void BOOST_DATA_TEST_CASE_run ## test_name ()"/>
<define name="BOOST_DATA_TEST_CASE_F(test_name, ...)" value="void BOOST_DATA_TEST_CASE_F_run ## test_name ()"/>
<define name="BOOST_PYTHON_MODULE(str)" value="void BOOST_PYTHON_MODULE_definition(str)"/>
<define name="BOOST_SCOPED_ENUM_DECLARE_BEGIN(x)" value=""/>
<define name="BOOST_SCOPED_ENUM_DECLARE_END(x)" value=""/>
Expand Down
45 changes: 45 additions & 0 deletions test/cfg/boost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
#include <boost/thread/mutex.hpp> // IWYU pragma: keep
#include <boost/thread/lock_guard.hpp>
#include <boost/test/unit_test.hpp> // IWYU pragma: keep
#include <boost/test/data/test_case.hpp>
#include <boost/test/data/monomorphic.hpp>
#include <boost/core/scoped_enum.hpp>
#include <boost/foreach.hpp>

Expand Down Expand Up @@ -199,3 +201,46 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(my_tuple_test, T, test_types_w_tuples)
}

BOOST_AUTO_TEST_SUITE_END()

// https://www.boost.org/doc/libs/latest/libs/test/doc/html/boost_test/tests_organization/test_cases/test_case_generation/datasets.html
namespace bdata = boost::unit_test::data;

// Dataset generating a Fibonacci sequence
struct fibonacci_dataset {
// the type of the samples is deduced
// cppcheck-suppress unusedStructMember // FP #14795, used in template is_dataset
static const int arity = 1;

struct iterator {
int operator*() const { return b; }
void operator++() {
a = a + b;
std::swap(a, b);
}
private:
int a = 1;
int b = 1; // b is the output
};

// size is infinite
bdata::size_t size() const { return bdata::BOOST_TEST_DS_INFINITE_SIZE; }

// iterator
static iterator begin() { return iterator(); }
};

namespace boost { namespace unit_test { namespace data { namespace monomorphic {
// registering fibonacci_dataset as a proper dataset
template <>
struct is_dataset<fibonacci_dataset> : boost::mpl::true_ {};
}}}}

// Creating a test-driven dataset, the zip is for checking
BOOST_DATA_TEST_CASE(
test1,
fibonacci_dataset() ^ bdata::make( { 1, 2, 3, 5, 8, 13, 21, 35, 56 } ),
fib_sample, exp)
{
// cppcheck-suppress valueFlowBailoutIncompleteVar // TODO: fib_sample declared in test case
BOOST_TEST(fib_sample == exp);
}
Loading