template <typename ListType>
static void
-test_intrusive_list ()
+test_intrusive_list_1 ()
{
intrusive_list_test<ListType> tests;
static void
test_intrusive_list ()
{
- test_intrusive_list<item_with_base_list> ();
- test_intrusive_list<item_with_member_list> ();
+ test_intrusive_list_1<item_with_base_list> ();
+ test_intrusive_list_1<item_with_member_list> ();
test_node_is_linked ();
}
#include "common-debug.h"
#include "selftest.h"
#include <map>
+#include <functional>
namespace selftests
{
static std::map<std::string, std::unique_ptr<selftest>> tests;
-/* A selftest that calls the test function without arguments. */
-
-struct simple_selftest : public selftest
-{
- simple_selftest (self_test_function *function_)
- : function (function_)
- {}
-
- void operator() () const override
- {
- function ();
- }
-
- self_test_function *function;
-};
-
/* See selftest.h. */
void
tests[name] = std::unique_ptr<selftest> (test);
}
+/* A selftest that calls the test function without arguments. */
+
+struct lambda_selftest : public selftest
+{
+ lambda_selftest (std::function<void(void)> function_)
+ {
+ function = function_;
+ }
+
+ void operator() () const override
+ {
+ function ();
+ }
+
+ std::function<void(void)> function;
+};
+
/* See selftest.h. */
void
-register_test (const std::string &name, self_test_function *function)
+register_test (const std::string &name,
+ std::function<void(void)> function)
{
- register_test (name, new simple_selftest (function));
+ register_test (name, new lambda_selftest (function));
}
/* See selftest.h. */
/* Register a new self-test. */
extern void register_test (const std::string &name,
- self_test_function *function);
+ std::function<void(void)> function);
/* Run all the self tests. This print a message describing the number
of test and the number of failures.