1
0
forked from boostorg/move

Use lightweight test instead of assert

This commit is contained in:
Ion Gaztañaga
2023-01-20 12:44:30 +01:00
parent 2513f1bdcd
commit 0865eb3a80

View File

@@ -13,6 +13,7 @@
#include <cassert> #include <cassert>
#include <new> #include <new>
#include <boost/move/detail/move_helpers.hpp> #include <boost/move/detail/move_helpers.hpp>
#include <boost/core/lightweight_test.hpp>
enum ConstructionType { Copied, Moved, Other }; enum ConstructionType { Copied, Moved, Other };
@@ -188,42 +189,42 @@ int main()
{ {
conversion_target x; conversion_target x;
c.push_back(x); c.push_back(x);
assert(c.construction_type() == Copied); BOOST_TEST(c.construction_type() == Copied);
c.insert(c.begin(), x); c.insert(c.begin(), x);
assert(c.construction_type() == Copied); BOOST_TEST(c.construction_type() == Copied);
} }
{ {
const conversion_target x; const conversion_target x;
c.push_back(x); c.push_back(x);
assert(c.construction_type() == Copied); BOOST_TEST(c.construction_type() == Copied);
c.insert(c.begin(), x); c.insert(c.begin(), x);
assert(c.construction_type() == Copied); BOOST_TEST(c.construction_type() == Copied);
} }
{ {
c.push_back(conversion_target()); c.push_back(conversion_target());
assert(c.construction_type() == Copied); BOOST_TEST(c.construction_type() == Copied);
c.insert(c.begin(), conversion_target()); c.insert(c.begin(), conversion_target());
assert(c.construction_type() == Copied); BOOST_TEST(c.construction_type() == Copied);
} }
{ {
conversion_source x; conversion_source x;
c.push_back(x); c.push_back(x);
assert(c.construction_type() == Copied); BOOST_TEST(c.construction_type() == Copied);
c.insert(c.begin(), x); c.insert(c.begin(), x);
assert(c.construction_type() == Copied); BOOST_TEST(c.construction_type() == Copied);
} }
{ {
const conversion_source x; const conversion_source x;
c.push_back(x); c.push_back(x);
assert(c.construction_type() == Copied); BOOST_TEST(c.construction_type() == Copied);
c.insert(c.begin(), x); c.insert(c.begin(), x);
assert(c.construction_type() == Copied); BOOST_TEST(c.construction_type() == Copied);
} }
{ {
c.push_back(conversion_source()); c.push_back(conversion_source());
assert(c.construction_type() == Copied); BOOST_TEST(c.construction_type() == Copied);
c.insert(c.begin(), conversion_source()); c.insert(c.begin(), conversion_source());
assert(c.construction_type() == Copied); BOOST_TEST(c.construction_type() == Copied);
} }
} }
@@ -232,42 +233,42 @@ int main()
{ {
conversion_target_copymovable x; conversion_target_copymovable x;
c.push_back(x); c.push_back(x);
assert(c.construction_type() == Copied); BOOST_TEST(c.construction_type() == Copied);
c.insert(c.begin(), x); c.insert(c.begin(), x);
assert(c.construction_type() == Copied); BOOST_TEST(c.construction_type() == Copied);
} }
{ {
const conversion_target_copymovable x; const conversion_target_copymovable x;
c.push_back(x); c.push_back(x);
assert(c.construction_type() == Copied); BOOST_TEST(c.construction_type() == Copied);
c.insert(c.begin(), x); c.insert(c.begin(), x);
assert(c.construction_type() == Copied); BOOST_TEST(c.construction_type() == Copied);
} }
{ {
c.push_back(conversion_target_copymovable()); c.push_back(conversion_target_copymovable());
assert(c.construction_type() == Moved); BOOST_TEST(c.construction_type() == Moved);
c.insert(c.begin(), conversion_target_copymovable()); c.insert(c.begin(), conversion_target_copymovable());
assert(c.construction_type() == Moved); BOOST_TEST(c.construction_type() == Moved);
} }
{ {
conversion_source x; conversion_source x;
c.push_back(x); c.push_back(x);
assert(c.construction_type() == Moved); BOOST_TEST(c.construction_type() == Moved);
c.insert(c.begin(), x); c.insert(c.begin(), x);
assert(c.construction_type() == Moved); BOOST_TEST(c.construction_type() == Moved);
} }
{ {
const conversion_source x; const conversion_source x;
c.push_back(x); c.push_back(x);
assert(c.construction_type() == Moved); BOOST_TEST(c.construction_type() == Moved);
c.insert(c.begin(), x); c.insert(c.begin(), x);
assert(c.construction_type() == Moved); BOOST_TEST(c.construction_type() == Moved);
} }
{ {
c.push_back(conversion_source()); c.push_back(conversion_source());
assert(c.construction_type() == Moved); BOOST_TEST(c.construction_type() == Moved);
c.insert(c.begin(), conversion_source()); c.insert(c.begin(), conversion_source());
assert(c.construction_type() == Moved); BOOST_TEST(c.construction_type() == Moved);
} }
} }
{ {
@@ -276,38 +277,38 @@ int main()
//{ //{
// conversion_target_movable x; // conversion_target_movable x;
// c.push_back(x); // c.push_back(x);
// assert(c.construction_type() == Copied); // BOOST_TEST(c.construction_type() == Copied);
//} //}
//{ //{
// const conversion_target_movable x; // const conversion_target_movable x;
// c.push_back(x); // c.push_back(x);
// assert(c.construction_type() == Copied); // BOOST_TEST(c.construction_type() == Copied);
//} //}
{ {
c.push_back(conversion_target_movable()); c.push_back(conversion_target_movable());
assert(c.construction_type() == Moved); BOOST_TEST(c.construction_type() == Moved);
c.insert(c.begin(), conversion_target_movable()); c.insert(c.begin(), conversion_target_movable());
assert(c.construction_type() == Moved); BOOST_TEST(c.construction_type() == Moved);
} }
{ {
conversion_source x; conversion_source x;
c.push_back(x); c.push_back(x);
assert(c.construction_type() == Moved); BOOST_TEST(c.construction_type() == Moved);
c.insert(c.begin(), x); c.insert(c.begin(), x);
assert(c.construction_type() == Moved); BOOST_TEST(c.construction_type() == Moved);
} }
{ {
const conversion_source x; const conversion_source x;
c.push_back(x); c.push_back(x);
assert(c.construction_type() == Moved); BOOST_TEST(c.construction_type() == Moved);
c.insert(c.begin(), x); c.insert(c.begin(), x);
assert(c.construction_type() == Moved); BOOST_TEST(c.construction_type() == Moved);
} }
{ {
c.push_back(conversion_source()); c.push_back(conversion_source());
assert(c.construction_type() == Moved); BOOST_TEST(c.construction_type() == Moved);
c.insert(c.begin(), conversion_source()); c.insert(c.begin(), conversion_source());
assert(c.construction_type() == Moved); BOOST_TEST(c.construction_type() == Moved);
} }
} }
{ {
@@ -315,43 +316,43 @@ int main()
{ {
int x = 0; int x = 0;
c.push_back(x); c.push_back(x);
assert(c.construction_type() == Copied); BOOST_TEST(c.construction_type() == Copied);
c.insert(c.begin(), c.construction_type()); c.insert(c.begin(), c.construction_type());
assert(c.construction_type() == Copied); BOOST_TEST(c.construction_type() == Copied);
} }
{ {
const int x = 0; const int x = 0;
c.push_back(x); c.push_back(x);
assert(c.construction_type() == Copied); BOOST_TEST(c.construction_type() == Copied);
c.insert(c.begin(), x); c.insert(c.begin(), x);
assert(c.construction_type() == Copied); BOOST_TEST(c.construction_type() == Copied);
} }
{ {
c.push_back(int(0)); c.push_back(int(0));
assert(c.construction_type() == Copied); BOOST_TEST(c.construction_type() == Copied);
c.insert(c.begin(), int(0)); c.insert(c.begin(), int(0));
assert(c.construction_type() == Copied); BOOST_TEST(c.construction_type() == Copied);
} }
{ {
conversion_source x; conversion_source x;
c.push_back(x); c.push_back(x);
assert(c.construction_type() == Copied); BOOST_TEST(c.construction_type() == Copied);
c.insert(c.begin(), x); c.insert(c.begin(), x);
assert(c.construction_type() == Copied); BOOST_TEST(c.construction_type() == Copied);
} }
{ {
const conversion_source x; const conversion_source x;
c.push_back(x); c.push_back(x);
assert(c.construction_type() == Copied); BOOST_TEST(c.construction_type() == Copied);
c.insert(c.begin(), x); c.insert(c.begin(), x);
assert(c.construction_type() == Copied); BOOST_TEST(c.construction_type() == Copied);
} }
{ {
c.push_back(conversion_source()); c.push_back(conversion_source());
assert(c.construction_type() == Copied); BOOST_TEST(c.construction_type() == Copied);
c.insert(c.begin(), conversion_source()); c.insert(c.begin(), conversion_source());
assert(c.construction_type() == Copied); BOOST_TEST(c.construction_type() == Copied);
} }
//c.insert(c.begin(), c.begin()); //c.insert(c.begin(), c.begin());
} }
@@ -361,43 +362,43 @@ int main()
{ {
int x = 0; int x = 0;
c.push_back(x); c.push_back(x);
assert(c.construction_type() == Copied); BOOST_TEST(c.construction_type() == Copied);
c.insert(c.begin(), c.construction_type()); c.insert(c.begin(), c.construction_type());
assert(c.construction_type() == Copied); BOOST_TEST(c.construction_type() == Copied);
} }
{ {
const int x = 0; const int x = 0;
c.push_back(x); c.push_back(x);
assert(c.construction_type() == Copied); BOOST_TEST(c.construction_type() == Copied);
c.insert(c.begin(), x); c.insert(c.begin(), x);
assert(c.construction_type() == Copied); BOOST_TEST(c.construction_type() == Copied);
} }
{ {
c.push_back(int(0)); c.push_back(int(0));
assert(c.construction_type() == Copied); BOOST_TEST(c.construction_type() == Copied);
c.insert(c.begin(), int(0)); c.insert(c.begin(), int(0));
assert(c.construction_type() == Copied); BOOST_TEST(c.construction_type() == Copied);
} }
{ {
conversion_source x; conversion_source x;
c.push_back(x); c.push_back(x);
assert(c.construction_type() == Copied); BOOST_TEST(c.construction_type() == Copied);
c.insert(c.begin(), x); c.insert(c.begin(), x);
assert(c.construction_type() == Copied); BOOST_TEST(c.construction_type() == Copied);
} }
{ {
const conversion_source x; const conversion_source x;
c.push_back(x); c.push_back(x);
assert(c.construction_type() == Copied); BOOST_TEST(c.construction_type() == Copied);
c.insert(c.begin(), x); c.insert(c.begin(), x);
assert(c.construction_type() == Copied); BOOST_TEST(c.construction_type() == Copied);
} }
{ {
c.push_back(conversion_source()); c.push_back(conversion_source());
assert(c.construction_type() == Copied); BOOST_TEST(c.construction_type() == Copied);
c.insert(c.begin(), conversion_source()); c.insert(c.begin(), conversion_source());
assert(c.construction_type() == Copied); BOOST_TEST(c.construction_type() == Copied);
} }
c.insert(c.begin(), c.begin()); c.insert(c.begin(), c.begin());
} }
@@ -410,5 +411,5 @@ int main()
c.container_.insert(c.container_.begin(), c.container_.begin()); c.container_.insert(c.container_.begin(), c.container_.begin());
} }
return 0; return boost::report_errors();
} }