Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 1 | // (C) Copyright Gennadiy Rozental 2005-2008. |
| 2 | // Use, modification, and distribution are subject to the |
| 3 | // Boost Software License, Version 1.0. (See accompanying file |
| 4 | // http://www.boost.org/LICENSE_1_0.txt) |
| 5 | |
| 6 | // See http://www.boost.org/libs/test for the library home page. |
| 7 | // |
| 8 | // File : $RCSfile$ |
| 9 | // |
| 10 | // Version : $Revision: 54633 $ |
| 11 | // |
| 12 | // Description : Facilities to perform interaction-based testing |
| 13 | // *************************************************************************** |
| 14 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 15 | #ifndef NDNBOOST_TEST_INTERACTION_BASED_IPP_112105GER |
| 16 | #define NDNBOOST_TEST_INTERACTION_BASED_IPP_112105GER |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 17 | |
| 18 | // Boost.Test |
| 19 | #include <ndnboost/test/detail/config.hpp> |
| 20 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 21 | #if NDNBOOST_TEST_SUPPORT_INTERACTION_TESTING |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 22 | |
| 23 | // Boost.Test |
| 24 | #include <ndnboost/test/detail/config.hpp> |
| 25 | #include <ndnboost/test/utils/callback.hpp> |
| 26 | #include <ndnboost/test/interaction_based.hpp> |
| 27 | #include <ndnboost/test/mock_object.hpp> |
| 28 | #include <ndnboost/test/framework.hpp> // for setup_error |
| 29 | |
| 30 | #include <ndnboost/test/detail/suppress_warnings.hpp> |
| 31 | |
| 32 | // STL |
| 33 | #include <stdexcept> |
| 34 | #include <string> |
| 35 | |
| 36 | //____________________________________________________________________________// |
| 37 | |
| 38 | namespace ndnboost { |
| 39 | |
| 40 | namespace itest { // interaction-based testing |
| 41 | |
| 42 | // ************************************************************************** // |
| 43 | // ************** manager ************** // |
| 44 | // ************************************************************************** // |
| 45 | |
| 46 | manager::manager() |
| 47 | { |
| 48 | instance_ptr( true, this ); |
| 49 | } |
| 50 | |
| 51 | //____________________________________________________________________________// |
| 52 | |
| 53 | manager::~manager() |
| 54 | { |
| 55 | instance_ptr( true ); |
| 56 | } |
| 57 | |
| 58 | //____________________________________________________________________________// |
| 59 | |
| 60 | manager* |
| 61 | manager::instance_ptr( bool reset, manager* new_ptr ) |
| 62 | { |
| 63 | static manager dummy( 0 ); |
| 64 | |
| 65 | static manager* ptr = &dummy; |
| 66 | |
| 67 | if( reset ) { |
| 68 | if( new_ptr ) { |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 69 | NDNBOOST_TEST_SETUP_ASSERT( ptr == &dummy, NDNBOOST_TEST_L( "Can't run two interation based test the same time" ) ); |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 70 | |
| 71 | ptr = new_ptr; |
| 72 | } |
| 73 | else |
| 74 | ptr = &dummy; |
| 75 | } |
| 76 | |
| 77 | return ptr; |
| 78 | } |
| 79 | |
| 80 | } // namespace itest |
| 81 | |
| 82 | } // namespace ndnboost |
| 83 | |
| 84 | //____________________________________________________________________________// |
| 85 | |
| 86 | #include <ndnboost/test/detail/enable_warnings.hpp> |
| 87 | |
| 88 | #endif // not ancient compiler |
| 89 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 90 | #endif // NDNBOOST_TEST_INTERACTION_BASED_IPP_112105GER |