Migration to lightweight_test continues

This commit is contained in:
Andrzej Krzemienski
2015-01-15 22:46:34 +01:00
parent a8a6be013f
commit 67c7e21b4b
5 changed files with 167 additions and 173 deletions

View File

@ -1,4 +1,5 @@
// Copyright (C) 2003, Fernando Luis Cacciola Carballal.
// Copyright (C) 2015 Andrzej Krzemienski.
//
// Use, modification, and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
@ -8,57 +9,59 @@
//
// You are welcome to contact the author at:
// fernando_cacciola@hotmail.com
//
#include<iostream>
#include<stdexcept>
#include<string>
#define BOOST_ENABLE_ASSERT_HANDLER
#include "boost/optional.hpp"
#include "boost/tuple/tuple.hpp"
#include "boost/optional/optional.hpp"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#include "boost/test/minimal.hpp"
#include "boost/core/lightweight_test.hpp"
#include "boost/none.hpp"
#include "boost/tuple/tuple.hpp"
#include "optional_test_common.cpp"
// Test boost::tie() interoperabiliy.
int test_main( int, char* [] )
struct counting_oracle
{
typedef X T ;
try
{
TRACE( std::endl << BOOST_CURRENT_FUNCTION );
int val;
counting_oracle() : val() { ++default_ctor_count; }
counting_oracle(int v) : val(v) { ++val_ctor_count; }
counting_oracle(const counting_oracle& rhs) : val(rhs.val) { ++copy_ctor_count; }
counting_oracle& operator=(const counting_oracle& rhs) { val = rhs.val; ++copy_assign_count; return *this; }
~counting_oracle() { ++dtor_count; }
T z(0);
T a(1);
T b(2);
static int dtor_count;
static int default_ctor_count;
static int val_ctor_count;
static int copy_ctor_count;
static int copy_assign_count;
static int equals_count;
optional<T> oa, ob ;
// T::T( T const& x ) is used
set_pending_dtor( ARG(T) ) ;
set_pending_copy( ARG(T) ) ;
boost::tie(oa,ob) = std::make_pair(a,b) ;
check_is_not_pending_dtor( ARG(T) ) ;
check_is_not_pending_copy( ARG(T) ) ;
check_initialized(oa);
check_initialized(ob);
check_value(oa,a,z);
check_value(ob,b,z);
}
catch ( ... )
{
BOOST_ERROR("Unexpected Exception caught!");
}
friend bool operator==(const counting_oracle& lhs, const counting_oracle& rhs) { ++equals_count; return lhs.val == rhs.val; }
};
return 0;
int counting_oracle::dtor_count = 0;
int counting_oracle::default_ctor_count = 0;
int counting_oracle::val_ctor_count = 0;
int counting_oracle::copy_ctor_count = 0;
int counting_oracle::copy_assign_count = 0;
int counting_oracle::equals_count = 0;
// Test boost::tie() interoperability.
int main()
{
const std::pair<counting_oracle, counting_oracle> pair(1, 2);
boost::optional<counting_oracle> o1, o2;
boost::tie(o1, o2) = pair;
BOOST_TEST(o1);
BOOST_TEST(o2);
BOOST_TEST(*o1 == counting_oracle(1));
BOOST_TEST(*o2 == counting_oracle(2));
BOOST_TEST_EQ(2, counting_oracle::copy_ctor_count);
BOOST_TEST_EQ(0, counting_oracle::copy_assign_count);
BOOST_TEST_EQ(0, counting_oracle::default_ctor_count);
return boost::report_errors();
}