| 
									
										
										
										
											2003-12-03 13:34:11 +00:00
										 |  |  | //  boost::compressed_pair test program   
 | 
					
						
							| 
									
										
										
										
											2000-07-30 10:33:53 +00:00
										 |  |  |      | 
					
						
							| 
									
										
										
										
											2003-12-03 13:34:11 +00:00
										 |  |  | //  (C) Copyright John Maddock 2000. 
 | 
					
						
							|  |  |  | //  Use, modification and distribution are subject to the Boost Software License,
 | 
					
						
							|  |  |  | //  Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
 | 
					
						
							|  |  |  | //  http://www.boost.org/LICENSE_1_0.txt).
 | 
					
						
							| 
									
										
										
										
											2000-07-26 17:29:19 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2000-08-02 10:58:59 +00:00
										 |  |  | // standalone test program for <boost/compressed_pair.hpp>
 | 
					
						
							| 
									
										
										
										
											2000-10-03 11:47:24 +00:00
										 |  |  | // Revised 03 Oct 2000: 
 | 
					
						
							|  |  |  | //    Enabled tests for VC6.
 | 
					
						
							| 
									
										
										
										
											2000-08-02 10:58:59 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2000-07-26 17:29:19 +00:00
										 |  |  | #include <iostream>
 | 
					
						
							|  |  |  | #include <typeinfo>
 | 
					
						
							|  |  |  | #include <cassert>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <boost/compressed_pair.hpp>
 | 
					
						
							| 
									
										
										
										
											2017-12-23 12:58:39 -05:00
										 |  |  | #include <boost/core/lightweight_test.hpp>
 | 
					
						
							| 
									
										
										
										
											2000-07-26 17:29:19 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | using namespace boost; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-03-29 11:21:53 +00:00
										 |  |  | struct empty_UDT | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |    ~empty_UDT(){}; | 
					
						
							|  |  |  |    empty_UDT& operator=(const empty_UDT&){ return *this; } | 
					
						
							|  |  |  |    bool operator==(const empty_UDT&)const | 
					
						
							|  |  |  |    { return true; } | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | struct empty_POD_UDT | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |    empty_POD_UDT& operator=(const empty_POD_UDT&){ return *this; } | 
					
						
							|  |  |  |    bool operator==(const empty_POD_UDT&)const | 
					
						
							|  |  |  |    { return true; } | 
					
						
							|  |  |  | }; | 
					
						
							| 
									
										
										
										
											2000-07-26 17:29:19 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2000-10-07 10:53:47 +00:00
										 |  |  | struct non_empty1 | 
					
						
							|  |  |  | {  | 
					
						
							|  |  |  |    int i; | 
					
						
							|  |  |  |    non_empty1() : i(1){} | 
					
						
							|  |  |  |    non_empty1(int v) : i(v){} | 
					
						
							|  |  |  |    friend bool operator==(const non_empty1& a, const non_empty1& b) | 
					
						
							|  |  |  |    { return a.i == b.i; } | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | struct non_empty2 | 
					
						
							|  |  |  | {  | 
					
						
							|  |  |  |    int i; | 
					
						
							|  |  |  |    non_empty2() : i(3){} | 
					
						
							|  |  |  |    non_empty2(int v) : i(v){} | 
					
						
							|  |  |  |    friend bool operator==(const non_empty2& a, const non_empty2& b) | 
					
						
							|  |  |  |    { return a.i == b.i; } | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-05-01 11:17:02 +00:00
										 |  |  | #ifdef __GNUC__
 | 
					
						
							|  |  |  | using std::swap; | 
					
						
							| 
									
										
										
										
											2000-07-26 17:29:19 +00:00
										 |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-05-01 11:17:02 +00:00
										 |  |  | template <class T1, class T2> | 
					
						
							|  |  |  | struct compressed_pair_tester | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |    // define the types we need:
 | 
					
						
							|  |  |  |    typedef T1                                                 first_type; | 
					
						
							|  |  |  |    typedef T2                                                 second_type; | 
					
						
							|  |  |  |    typedef typename call_traits<first_type>::param_type       first_param_type; | 
					
						
							|  |  |  |    typedef typename call_traits<second_type>::param_type      second_param_type; | 
					
						
							|  |  |  |    // define our test proc:
 | 
					
						
							|  |  |  |    static void test(first_param_type p1, second_param_type p2, first_param_type p3, second_param_type p4); | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | template <class T1, class T2> | 
					
						
							|  |  |  | void compressed_pair_tester<T1, T2>::test(first_param_type p1, second_param_type p2, first_param_type p3, second_param_type p4) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2001-05-08 11:17:05 +00:00
										 |  |  | #ifndef __GNUC__
 | 
					
						
							|  |  |  |    // gcc 2.90 can't cope with function scope using
 | 
					
						
							|  |  |  |    // declarations, and generates an internal compiler error...
 | 
					
						
							| 
									
										
										
										
											2001-05-01 11:17:02 +00:00
										 |  |  |    using std::swap; | 
					
						
							| 
									
										
										
										
											2001-05-08 11:17:05 +00:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2001-05-01 11:17:02 +00:00
										 |  |  |    // default construct:
 | 
					
						
							|  |  |  |    boost::compressed_pair<T1,T2> cp1; | 
					
						
							|  |  |  |    // first param construct:
 | 
					
						
							|  |  |  |    boost::compressed_pair<T1,T2> cp2(p1); | 
					
						
							|  |  |  |    cp2.second() = p2; | 
					
						
							| 
									
										
										
										
											2017-12-23 12:58:39 -05:00
										 |  |  |    BOOST_TEST(cp2.first() == p1); | 
					
						
							|  |  |  |    BOOST_TEST(cp2.second() == p2); | 
					
						
							| 
									
										
										
										
											2001-05-01 11:17:02 +00:00
										 |  |  |    // second param construct:
 | 
					
						
							|  |  |  |    boost::compressed_pair<T1,T2> cp3(p2); | 
					
						
							|  |  |  |    cp3.first() = p1; | 
					
						
							| 
									
										
										
										
											2017-12-23 12:58:39 -05:00
										 |  |  |    BOOST_TEST(cp3.second() == p2); | 
					
						
							|  |  |  |    BOOST_TEST(cp3.first() == p1); | 
					
						
							| 
									
										
										
										
											2001-05-01 11:17:02 +00:00
										 |  |  |    // both param construct:
 | 
					
						
							|  |  |  |    boost::compressed_pair<T1,T2> cp4(p1, p2); | 
					
						
							| 
									
										
										
										
											2017-12-23 12:58:39 -05:00
										 |  |  |    BOOST_TEST(cp4.first() == p1); | 
					
						
							|  |  |  |    BOOST_TEST(cp4.second() == p2); | 
					
						
							| 
									
										
										
										
											2001-05-01 11:17:02 +00:00
										 |  |  |    boost::compressed_pair<T1,T2> cp5(p3, p4); | 
					
						
							| 
									
										
										
										
											2017-12-23 12:58:39 -05:00
										 |  |  |    BOOST_TEST(cp5.first() == p3); | 
					
						
							|  |  |  |    BOOST_TEST(cp5.second() == p4); | 
					
						
							| 
									
										
										
										
											2001-05-01 11:17:02 +00:00
										 |  |  |    // check const members:
 | 
					
						
							|  |  |  |    const boost::compressed_pair<T1,T2>& cpr1 = cp4; | 
					
						
							| 
									
										
										
										
											2017-12-23 12:58:39 -05:00
										 |  |  |    BOOST_TEST(cpr1.first() == p1); | 
					
						
							|  |  |  |    BOOST_TEST(cpr1.second() == p2); | 
					
						
							| 
									
										
										
										
											2001-05-01 11:17:02 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |    // copy construct:
 | 
					
						
							|  |  |  |    boost::compressed_pair<T1,T2> cp6(cp4); | 
					
						
							| 
									
										
										
										
											2017-12-23 12:58:39 -05:00
										 |  |  |    BOOST_TEST(cp6.first() == p1); | 
					
						
							|  |  |  |    BOOST_TEST(cp6.second() == p2); | 
					
						
							| 
									
										
										
										
											2001-05-01 11:17:02 +00:00
										 |  |  |    // assignment:
 | 
					
						
							|  |  |  |    cp1 = cp4; | 
					
						
							| 
									
										
										
										
											2017-12-23 12:58:39 -05:00
										 |  |  |    BOOST_TEST(cp1.first() == p1); | 
					
						
							|  |  |  |    BOOST_TEST(cp1.second() == p2); | 
					
						
							| 
									
										
										
										
											2001-05-01 11:17:02 +00:00
										 |  |  |    cp1 = cp5; | 
					
						
							| 
									
										
										
										
											2017-12-23 12:58:39 -05:00
										 |  |  |    BOOST_TEST(cp1.first() == p3); | 
					
						
							|  |  |  |    BOOST_TEST(cp1.second() == p4); | 
					
						
							| 
									
										
										
										
											2001-05-01 11:17:02 +00:00
										 |  |  |    // swap:
 | 
					
						
							|  |  |  |    cp4.swap(cp5); | 
					
						
							| 
									
										
										
										
											2017-12-23 12:58:39 -05:00
										 |  |  |    BOOST_TEST(cp4.first() == p3); | 
					
						
							|  |  |  |    BOOST_TEST(cp4.second() == p4); | 
					
						
							|  |  |  |    BOOST_TEST(cp5.first() == p1); | 
					
						
							|  |  |  |    BOOST_TEST(cp5.second() == p2); | 
					
						
							| 
									
										
										
										
											2001-05-01 11:17:02 +00:00
										 |  |  |    swap(cp4,cp5); | 
					
						
							| 
									
										
										
										
											2017-12-23 12:58:39 -05:00
										 |  |  |    BOOST_TEST(cp4.first() == p1); | 
					
						
							|  |  |  |    BOOST_TEST(cp4.second() == p2); | 
					
						
							|  |  |  |    BOOST_TEST(cp5.first() == p3); | 
					
						
							|  |  |  |    BOOST_TEST(cp5.second() == p4); | 
					
						
							| 
									
										
										
										
											2000-07-26 17:29:19 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | //
 | 
					
						
							| 
									
										
										
										
											2001-05-01 11:17:02 +00:00
										 |  |  | // tests for case where one or both 
 | 
					
						
							|  |  |  | // parameters are reference types:
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | template <class T1, class T2> | 
					
						
							|  |  |  | struct compressed_pair_reference_tester | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |    // define the types we need:
 | 
					
						
							|  |  |  |    typedef T1                                                 first_type; | 
					
						
							|  |  |  |    typedef T2                                                 second_type; | 
					
						
							|  |  |  |    typedef typename call_traits<first_type>::param_type       first_param_type; | 
					
						
							|  |  |  |    typedef typename call_traits<second_type>::param_type      second_param_type; | 
					
						
							|  |  |  |    // define our test proc:
 | 
					
						
							|  |  |  |    static void test(first_param_type p1, second_param_type p2, first_param_type p3, second_param_type p4); | 
					
						
							|  |  |  | }; | 
					
						
							| 
									
										
										
										
											2000-07-26 17:29:19 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-05-01 11:17:02 +00:00
										 |  |  | template <class T1, class T2> | 
					
						
							|  |  |  | void compressed_pair_reference_tester<T1, T2>::test(first_param_type p1, second_param_type p2, first_param_type p3, second_param_type p4) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2001-05-08 11:17:05 +00:00
										 |  |  | #ifndef __GNUC__
 | 
					
						
							|  |  |  |    // gcc 2.90 can't cope with function scope using
 | 
					
						
							|  |  |  |    // declarations, and generates an internal compiler error...
 | 
					
						
							| 
									
										
										
										
											2001-05-01 11:17:02 +00:00
										 |  |  |    using std::swap; | 
					
						
							| 
									
										
										
										
											2001-05-08 11:17:05 +00:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2001-05-01 11:17:02 +00:00
										 |  |  |    // both param construct:
 | 
					
						
							|  |  |  |    boost::compressed_pair<T1,T2> cp4(p1, p2); | 
					
						
							| 
									
										
										
										
											2017-12-23 12:58:39 -05:00
										 |  |  |    BOOST_TEST(cp4.first() == p1); | 
					
						
							|  |  |  |    BOOST_TEST(cp4.second() == p2); | 
					
						
							| 
									
										
										
										
											2001-05-01 11:17:02 +00:00
										 |  |  |    boost::compressed_pair<T1,T2> cp5(p3, p4); | 
					
						
							| 
									
										
										
										
											2017-12-23 12:58:39 -05:00
										 |  |  |    BOOST_TEST(cp5.first() == p3); | 
					
						
							|  |  |  |    BOOST_TEST(cp5.second() == p4); | 
					
						
							| 
									
										
										
										
											2001-05-01 11:17:02 +00:00
										 |  |  |    // check const members:
 | 
					
						
							|  |  |  |    const boost::compressed_pair<T1,T2>& cpr1 = cp4; | 
					
						
							| 
									
										
										
										
											2017-12-23 12:58:39 -05:00
										 |  |  |    BOOST_TEST(cpr1.first() == p1); | 
					
						
							|  |  |  |    BOOST_TEST(cpr1.second() == p2); | 
					
						
							| 
									
										
										
										
											2001-05-01 11:17:02 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |    // copy construct:
 | 
					
						
							|  |  |  |    boost::compressed_pair<T1,T2> cp6(cp4); | 
					
						
							| 
									
										
										
										
											2017-12-23 12:58:39 -05:00
										 |  |  |    BOOST_TEST(cp6.first() == p1); | 
					
						
							|  |  |  |    BOOST_TEST(cp6.second() == p2); | 
					
						
							| 
									
										
										
										
											2001-05-01 11:17:02 +00:00
										 |  |  |    // assignment:
 | 
					
						
							| 
									
										
										
										
											2001-05-02 10:59:32 +00:00
										 |  |  |    // VC6 bug:
 | 
					
						
							|  |  |  |    // When second() is an empty class, VC6 performs the
 | 
					
						
							|  |  |  |    // assignment by doing a memcpy - even though the empty
 | 
					
						
							|  |  |  |    // class is really a zero sized base class, the result
 | 
					
						
							|  |  |  |    // is that the memory of first() gets trampled over.
 | 
					
						
							|  |  |  |    // Similar arguments apply to the case that first() is 
 | 
					
						
							|  |  |  |    // an empty base class.
 | 
					
						
							|  |  |  |    // Strangely the problem is dependent upon the compiler
 | 
					
						
							|  |  |  |    // settings - some generate the problem others do not.
 | 
					
						
							|  |  |  |    cp4.first() = p3; | 
					
						
							|  |  |  |    cp4.second() = p4; | 
					
						
							| 
									
										
										
										
											2017-12-23 12:58:39 -05:00
										 |  |  |    BOOST_TEST(cp4.first() == p3); | 
					
						
							|  |  |  |    BOOST_TEST(cp4.second() == p4); | 
					
						
							| 
									
										
										
										
											2001-05-01 11:17:02 +00:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2000-07-26 17:29:19 +00:00
										 |  |  | //
 | 
					
						
							| 
									
										
										
										
											2001-05-01 11:17:02 +00:00
										 |  |  | // supplimentary tests for case where first arg only is a reference type:
 | 
					
						
							| 
									
										
										
										
											2000-07-26 17:29:19 +00:00
										 |  |  | //
 | 
					
						
							| 
									
										
										
										
											2001-05-01 11:17:02 +00:00
										 |  |  | template <class T1, class T2> | 
					
						
							|  |  |  | struct compressed_pair_reference1_tester | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |    // define the types we need:
 | 
					
						
							|  |  |  |    typedef T1                                                 first_type; | 
					
						
							|  |  |  |    typedef T2                                                 second_type; | 
					
						
							|  |  |  |    typedef typename call_traits<first_type>::param_type       first_param_type; | 
					
						
							|  |  |  |    typedef typename call_traits<second_type>::param_type      second_param_type; | 
					
						
							|  |  |  |    // define our test proc:
 | 
					
						
							|  |  |  |    static void test(first_param_type p1, second_param_type p2, first_param_type p3, second_param_type p4); | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | template <class T1, class T2> | 
					
						
							| 
									
										
										
										
											2001-09-24 23:21:16 +00:00
										 |  |  | void compressed_pair_reference1_tester<T1, T2>::test(first_param_type p1, second_param_type p2, first_param_type, second_param_type) | 
					
						
							| 
									
										
										
										
											2001-05-01 11:17:02 +00:00
										 |  |  | { | 
					
						
							|  |  |  | #ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
 | 
					
						
							|  |  |  |    // first param construct:
 | 
					
						
							|  |  |  |    boost::compressed_pair<T1,T2> cp2(p1); | 
					
						
							|  |  |  |    cp2.second() = p2; | 
					
						
							| 
									
										
										
										
											2017-12-23 12:58:39 -05:00
										 |  |  |    BOOST_TEST(cp2.first() == p1); | 
					
						
							|  |  |  |    BOOST_TEST(cp2.second() == p2); | 
					
						
							| 
									
										
										
										
											2000-07-26 17:29:19 +00:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2001-05-01 11:17:02 +00:00
										 |  |  | } | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | // supplimentary tests for case where second arg only is a reference type:
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | template <class T1, class T2> | 
					
						
							|  |  |  | struct compressed_pair_reference2_tester | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |    // define the types we need:
 | 
					
						
							|  |  |  |    typedef T1                                                 first_type; | 
					
						
							|  |  |  |    typedef T2                                                 second_type; | 
					
						
							|  |  |  |    typedef typename call_traits<first_type>::param_type       first_param_type; | 
					
						
							|  |  |  |    typedef typename call_traits<second_type>::param_type      second_param_type; | 
					
						
							|  |  |  |    // define our test proc:
 | 
					
						
							|  |  |  |    static void test(first_param_type p1, second_param_type p2, first_param_type p3, second_param_type p4); | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | template <class T1, class T2> | 
					
						
							| 
									
										
										
										
											2001-09-24 23:21:16 +00:00
										 |  |  | void compressed_pair_reference2_tester<T1, T2>::test(first_param_type p1, second_param_type p2, first_param_type, second_param_type) | 
					
						
							| 
									
										
										
										
											2001-05-01 11:17:02 +00:00
										 |  |  | { | 
					
						
							|  |  |  | #ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
 | 
					
						
							|  |  |  |    // second param construct:
 | 
					
						
							|  |  |  |    boost::compressed_pair<T1,T2> cp3(p2); | 
					
						
							|  |  |  |    cp3.first() = p1; | 
					
						
							| 
									
										
										
										
											2017-12-23 12:58:39 -05:00
										 |  |  |    BOOST_TEST(cp3.second() == p2); | 
					
						
							|  |  |  |    BOOST_TEST(cp3.first() == p1); | 
					
						
							| 
									
										
										
										
											2000-11-04 11:16:12 +00:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2001-05-01 11:17:02 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | // tests for where one or the other parameter is an array:
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | template <class T1, class T2> | 
					
						
							|  |  |  | struct compressed_pair_array1_tester | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |    // define the types we need:
 | 
					
						
							|  |  |  |    typedef T1                                                 first_type; | 
					
						
							|  |  |  |    typedef T2                                                 second_type; | 
					
						
							|  |  |  |    typedef typename call_traits<first_type>::param_type       first_param_type; | 
					
						
							|  |  |  |    typedef typename call_traits<second_type>::param_type      second_param_type; | 
					
						
							|  |  |  |    // define our test proc:
 | 
					
						
							|  |  |  |    static void test(first_param_type p1, second_param_type p2, first_param_type p3, second_param_type p4); | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | template <class T1, class T2> | 
					
						
							| 
									
										
										
										
											2001-09-24 23:21:16 +00:00
										 |  |  | void compressed_pair_array1_tester<T1, T2>::test(first_param_type p1, second_param_type p2, first_param_type, second_param_type) | 
					
						
							| 
									
										
										
										
											2001-05-01 11:17:02 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2001-05-08 11:17:05 +00:00
										 |  |  |   // default construct:
 | 
					
						
							| 
									
										
										
										
											2001-05-01 11:17:02 +00:00
										 |  |  |    boost::compressed_pair<T1,T2> cp1; | 
					
						
							|  |  |  |    // second param construct:
 | 
					
						
							|  |  |  |    boost::compressed_pair<T1,T2> cp3(p2); | 
					
						
							|  |  |  |    cp3.first()[0] = p1[0]; | 
					
						
							| 
									
										
										
										
											2017-12-23 12:58:39 -05:00
										 |  |  |    BOOST_TEST(cp3.second() == p2); | 
					
						
							|  |  |  |    BOOST_TEST(cp3.first()[0] == p1[0]); | 
					
						
							| 
									
										
										
										
											2001-05-01 11:17:02 +00:00
										 |  |  |    // check const members:
 | 
					
						
							|  |  |  |    const boost::compressed_pair<T1,T2>& cpr1 = cp3; | 
					
						
							| 
									
										
										
										
											2017-12-23 12:58:39 -05:00
										 |  |  |    BOOST_TEST(cpr1.first()[0] == p1[0]); | 
					
						
							|  |  |  |    BOOST_TEST(cpr1.second() == p2); | 
					
						
							| 
									
										
										
										
											2001-05-01 11:17:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-23 12:58:39 -05:00
										 |  |  |    BOOST_TEST(sizeof(T1) == sizeof(cp1.first())); | 
					
						
							| 
									
										
										
										
											2001-05-01 11:17:02 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | template <class T1, class T2> | 
					
						
							|  |  |  | struct compressed_pair_array2_tester | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |    // define the types we need:
 | 
					
						
							|  |  |  |    typedef T1                                                 first_type; | 
					
						
							|  |  |  |    typedef T2                                                 second_type; | 
					
						
							|  |  |  |    typedef typename call_traits<first_type>::param_type       first_param_type; | 
					
						
							|  |  |  |    typedef typename call_traits<second_type>::param_type      second_param_type; | 
					
						
							|  |  |  |    // define our test proc:
 | 
					
						
							|  |  |  |    static void test(first_param_type p1, second_param_type p2, first_param_type p3, second_param_type p4); | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | template <class T1, class T2> | 
					
						
							| 
									
										
										
										
											2001-09-24 23:21:16 +00:00
										 |  |  | void compressed_pair_array2_tester<T1, T2>::test(first_param_type p1, second_param_type p2, first_param_type, second_param_type) | 
					
						
							| 
									
										
										
										
											2001-05-01 11:17:02 +00:00
										 |  |  | { | 
					
						
							|  |  |  |    // default construct:
 | 
					
						
							|  |  |  |    boost::compressed_pair<T1,T2> cp1; | 
					
						
							|  |  |  |    // first param construct:
 | 
					
						
							|  |  |  |    boost::compressed_pair<T1,T2> cp2(p1); | 
					
						
							|  |  |  |    cp2.second()[0] = p2[0]; | 
					
						
							| 
									
										
										
										
											2017-12-23 12:58:39 -05:00
										 |  |  |    BOOST_TEST(cp2.first() == p1); | 
					
						
							|  |  |  |    BOOST_TEST(cp2.second()[0] == p2[0]); | 
					
						
							| 
									
										
										
										
											2001-05-01 11:17:02 +00:00
										 |  |  |    // check const members:
 | 
					
						
							|  |  |  |    const boost::compressed_pair<T1,T2>& cpr1 = cp2; | 
					
						
							| 
									
										
										
										
											2017-12-23 12:58:39 -05:00
										 |  |  |    BOOST_TEST(cpr1.first() == p1); | 
					
						
							|  |  |  |    BOOST_TEST(cpr1.second()[0] == p2[0]); | 
					
						
							| 
									
										
										
										
											2001-05-01 11:17:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-23 12:58:39 -05:00
										 |  |  |    BOOST_TEST(sizeof(T2) == sizeof(cp1.second())); | 
					
						
							| 
									
										
										
										
											2001-05-01 11:17:02 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | template <class T1, class T2> | 
					
						
							|  |  |  | struct compressed_pair_array_tester | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |    // define the types we need:
 | 
					
						
							|  |  |  |    typedef T1                                                 first_type; | 
					
						
							|  |  |  |    typedef T2                                                 second_type; | 
					
						
							|  |  |  |    typedef typename call_traits<first_type>::param_type       first_param_type; | 
					
						
							|  |  |  |    typedef typename call_traits<second_type>::param_type      second_param_type; | 
					
						
							|  |  |  |    // define our test proc:
 | 
					
						
							|  |  |  |    static void test(first_param_type p1, second_param_type p2, first_param_type p3, second_param_type p4); | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | template <class T1, class T2> | 
					
						
							| 
									
										
										
										
											2001-09-24 23:21:16 +00:00
										 |  |  | void compressed_pair_array_tester<T1, T2>::test(first_param_type p1, second_param_type p2, first_param_type, second_param_type) | 
					
						
							| 
									
										
										
										
											2001-05-01 11:17:02 +00:00
										 |  |  | { | 
					
						
							|  |  |  |    // default construct:
 | 
					
						
							|  |  |  |    boost::compressed_pair<T1,T2> cp1; | 
					
						
							|  |  |  |    cp1.first()[0] = p1[0]; | 
					
						
							|  |  |  |    cp1.second()[0] = p2[0]; | 
					
						
							| 
									
										
										
										
											2017-12-23 12:58:39 -05:00
										 |  |  |    BOOST_TEST(cp1.first()[0] == p1[0]); | 
					
						
							|  |  |  |    BOOST_TEST(cp1.second()[0] == p2[0]); | 
					
						
							| 
									
										
										
										
											2001-05-01 11:17:02 +00:00
										 |  |  |    // check const members:
 | 
					
						
							|  |  |  |    const boost::compressed_pair<T1,T2>& cpr1 = cp1; | 
					
						
							| 
									
										
										
										
											2017-12-23 12:58:39 -05:00
										 |  |  |    BOOST_TEST(cpr1.first()[0] == p1[0]); | 
					
						
							|  |  |  |    BOOST_TEST(cpr1.second()[0] == p2[0]); | 
					
						
							| 
									
										
										
										
											2001-05-01 11:17:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-23 12:58:39 -05:00
										 |  |  |    BOOST_TEST(sizeof(T1) == sizeof(cp1.first())); | 
					
						
							|  |  |  |    BOOST_TEST(sizeof(T2) == sizeof(cp1.second())); | 
					
						
							| 
									
										
										
										
											2001-05-01 11:17:02 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-23 12:58:39 -05:00
										 |  |  | int main() | 
					
						
							| 
									
										
										
										
											2001-05-01 11:17:02 +00:00
										 |  |  | { | 
					
						
							|  |  |  |    // declare some variables to pass to the tester:
 | 
					
						
							|  |  |  |    non_empty1 ne1(2); | 
					
						
							|  |  |  |    non_empty1 ne2(3); | 
					
						
							|  |  |  |    non_empty2 ne3(4); | 
					
						
							|  |  |  |    non_empty2 ne4(5); | 
					
						
							|  |  |  |    empty_POD_UDT  e1; | 
					
						
							|  |  |  |    empty_UDT      e2; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |    // T1 != T2, both non-empty
 | 
					
						
							|  |  |  |    compressed_pair_tester<non_empty1,non_empty2>::test(ne1, ne3, ne2, ne4); | 
					
						
							|  |  |  |    // T1 != T2, T2 empty
 | 
					
						
							|  |  |  |    compressed_pair_tester<non_empty1,empty_POD_UDT>::test(ne1, e1, ne2, e1); | 
					
						
							|  |  |  |    // T1 != T2, T1 empty
 | 
					
						
							|  |  |  |    compressed_pair_tester<empty_POD_UDT,non_empty2>::test(e1, ne3, e1, ne4); | 
					
						
							|  |  |  |    // T1 != T2, both empty
 | 
					
						
							|  |  |  |    compressed_pair_tester<empty_POD_UDT,empty_UDT>::test(e1, e2, e1, e2); | 
					
						
							|  |  |  |    // T1 == T2, both non-empty
 | 
					
						
							|  |  |  |    compressed_pair_tester<non_empty1,non_empty1>::test(ne1, ne1, ne2, ne2); | 
					
						
							|  |  |  |    // T1 == T2, both empty
 | 
					
						
							|  |  |  |    compressed_pair_tester<empty_UDT,empty_UDT>::test(e2, e2, e2, e2); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |    // test references:
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |    // T1 != T2, both non-empty
 | 
					
						
							|  |  |  |    compressed_pair_reference_tester<non_empty1&,non_empty2>::test(ne1, ne3, ne2, ne4); | 
					
						
							|  |  |  |    compressed_pair_reference_tester<non_empty1,non_empty2&>::test(ne1, ne3, ne2, ne4); | 
					
						
							|  |  |  |    compressed_pair_reference1_tester<non_empty1&,non_empty2>::test(ne1, ne3, ne2, ne4); | 
					
						
							|  |  |  |    compressed_pair_reference2_tester<non_empty1,non_empty2&>::test(ne1, ne3, ne2, ne4); | 
					
						
							|  |  |  |    // T1 != T2, T2 empty
 | 
					
						
							|  |  |  |    compressed_pair_reference_tester<non_empty1&,empty_POD_UDT>::test(ne1, e1, ne2, e1); | 
					
						
							|  |  |  |    compressed_pair_reference1_tester<non_empty1&,empty_POD_UDT>::test(ne1, e1, ne2, e1); | 
					
						
							|  |  |  |    // T1 != T2, T1 empty
 | 
					
						
							|  |  |  |    compressed_pair_reference_tester<empty_POD_UDT,non_empty2&>::test(e1, ne3, e1, ne4); | 
					
						
							|  |  |  |    compressed_pair_reference2_tester<empty_POD_UDT,non_empty2&>::test(e1, ne3, e1, ne4); | 
					
						
							|  |  |  |    // T1 == T2, both non-empty
 | 
					
						
							|  |  |  |    compressed_pair_reference_tester<non_empty1&,non_empty1&>::test(ne1, ne1, ne2, ne2); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |    // tests arrays:
 | 
					
						
							|  |  |  |    non_empty1 nea1[2]; | 
					
						
							|  |  |  |    non_empty1 nea2[2]; | 
					
						
							|  |  |  |    non_empty2 nea3[2]; | 
					
						
							|  |  |  |    non_empty2 nea4[2]; | 
					
						
							|  |  |  |    nea1[0] = non_empty1(5); | 
					
						
							|  |  |  |    nea2[0] = non_empty1(6); | 
					
						
							|  |  |  |    nea3[0] = non_empty2(7); | 
					
						
							|  |  |  |    nea4[0] = non_empty2(8); | 
					
						
							|  |  |  |     | 
					
						
							|  |  |  |    // T1 != T2, both non-empty
 | 
					
						
							|  |  |  |    compressed_pair_array1_tester<non_empty1[2],non_empty2>::test(nea1, ne3, nea2, ne4); | 
					
						
							|  |  |  |    compressed_pair_array2_tester<non_empty1,non_empty2[2]>::test(ne1, nea3, ne2, nea4); | 
					
						
							|  |  |  |    compressed_pair_array_tester<non_empty1[2],non_empty2[2]>::test(nea1, nea3, nea2, nea4); | 
					
						
							|  |  |  |    // T1 != T2, T2 empty
 | 
					
						
							|  |  |  |    compressed_pair_array1_tester<non_empty1[2],empty_POD_UDT>::test(nea1, e1, nea2, e1); | 
					
						
							|  |  |  |    // T1 != T2, T1 empty
 | 
					
						
							|  |  |  |    compressed_pair_array2_tester<empty_POD_UDT,non_empty2[2]>::test(e1, nea3, e1, nea4); | 
					
						
							|  |  |  |    // T1 == T2, both non-empty
 | 
					
						
							|  |  |  |    compressed_pair_array_tester<non_empty1[2],non_empty1[2]>::test(nea1, nea1, nea2, nea2); | 
					
						
							| 
									
										
										
										
											2017-12-23 12:58:39 -05:00
										 |  |  |    return boost::report_errors(); | 
					
						
							| 
									
										
										
										
											2001-05-01 11:17:02 +00:00
										 |  |  | } |