From b5f369493854dbd1336c60f82cd584bd4f9a2241 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Sat, 14 Jul 2001 18:41:47 +0000 Subject: [PATCH] mixin_test.cpp: - Test copying of mixins [SVN r10615] --- test/mixin_test.cpp | 39 +++++++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/test/mixin_test.cpp b/test/mixin_test.cpp index 4e559e3..a17981b 100644 --- a/test/mixin_test.cpp +++ b/test/mixin_test.cpp @@ -19,22 +19,37 @@ #include #include -using namespace std; -using namespace boost; - struct id_mixin -{ +{ + id_mixin(const id_mixin& rhs) : id(rhs.id) {} + id_mixin& operator=(const id_mixin& rhs){id = rhs.id; return *this;} + id_mixin(){ id = 0;} int id; }; -int -test_main(int, char*[]) -{ - function::mixin::type f; - f = plus(); - f.id = 7; - f.clear(); - BOOST_TEST(f.id == 7); +typedef boost::function::mixin::type func; +int test_main(int, char*[]) +{ + func f; + f = std::plus(); + BOOST_TEST(f.id == 0); + + f.clear(); + f.id = 7; + BOOST_TEST(f.id == 7); + + func g(f); + BOOST_TEST(g.id == 7); + + f.id = 21; + BOOST_TEST(f.id == 21); + + boost::swap(f,g); + BOOST_TEST(f.id == 7); + BOOST_TEST(g.id == 21); + + g = f; + BOOST_TEST(g.id == 7); return 0; }