@@ -23,11 +23,11 @@ struct PYSTRINGTest
2323 PYSTRINGTestFunc function;
2424};
2525
26- typedef std::vector<PYSTRINGTest* > UnitTests;
26+ typedef std::vector<PYSTRINGTest> UnitTests;
2727
2828UnitTests& GetUnitTests ();
2929
30- struct AddTest { AddTest(PYSTRINGTest* test); };
30+ struct AddTest { AddTest(PYSTRINGTest&& test); };
3131
3232// / PYSTRING_CHECK_* macros checks if the conditions is met, and if not,
3333// / prints an error message indicating the module and line where the
@@ -102,22 +102,22 @@ struct AddTest { AddTest(PYSTRINGTest* test); };
102102
103103#define PYSTRING_ADD_TEST (group, name ) \
104104 static void pystringtest_##group##_##name(); \
105- AddTest pystringaddtest_##group##_##name(new PYSTRINGTest(#group, #name, pystringtest_##group##_##name)); \
105+ AddTest pystringaddtest_##group##_##name(PYSTRINGTest(#group, #name, pystringtest_##group##_##name)); \
106106 static void pystringtest_##group##_##name()
107107
108108#define PYSTRING_TEST_SETUP () \
109109 int unit_test_failures = 0
110110
111111#define PYSTRING_TEST_APP (app ) \
112- std::vector<PYSTRINGTest* >& GetUnitTests () { \
113- static std::vector<PYSTRINGTest* > pystring_unit_tests; \
112+ std::vector<PYSTRINGTest>& GetUnitTests () { \
113+ static std::vector<PYSTRINGTest> pystring_unit_tests; \
114114 return pystring_unit_tests; } \
115- AddTest::AddTest (PYSTRINGTest* test){GetUnitTests ().push_back (test);}; \
115+ AddTest::AddTest (PYSTRINGTest&& test){GetUnitTests ().emplace_back (test);}; \
116116 PYSTRING_TEST_SETUP (); \
117117 int main (int , char **) { std::cerr << " \n " << #app <<" \n\n " ; \
118118 for (size_t i = 0 ; i < GetUnitTests ().size (); ++i) { \
119- int _tmp = unit_test_failures; GetUnitTests ()[i]-> function (); \
120- std::cerr << " Test [" << GetUnitTests ()[i]-> group << " ] [" << GetUnitTests ()[i]-> name << " ] - " ; \
119+ int _tmp = unit_test_failures; GetUnitTests ()[i]. function (); \
120+ std::cerr << " Test [" << GetUnitTests ()[i]. group << " ] [" << GetUnitTests ()[i]. name << " ] - " ; \
121121 std::cerr << (_tmp == unit_test_failures ? " PASSED" : " FAILED" ) << " \n " ; } \
122122 std::cerr << " \n " << unit_test_failures << " tests failed\n\n " ; \
123123 return unit_test_failures; }
0 commit comments