Include bind in ndnboost.
diff --git a/ndnboost/test/debug.hpp b/ndnboost/test/debug.hpp
new file mode 100644
index 0000000..30d5d30
--- /dev/null
+++ b/ndnboost/test/debug.hpp
@@ -0,0 +1,101 @@
+// (C) Copyright Gennadiy Rozental 2006-2008.
+// Distributed under 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)
+
+// See http://www.boost.org/libs/test for the library home page.
+//
+// File : $RCSfile$
+//
+// Version : $Revision: 49312 $
+//
+// Description : defines portable debug interfaces
+// ***************************************************************************
+
+#ifndef BOOST_TEST_DEBUG_API_HPP_112006GER
+#define BOOST_TEST_DEBUG_API_HPP_112006GER
+
+// Boost.Test
+#include <ndnboost/test/detail/config.hpp>
+#include <ndnboost/test/utils/callback.hpp>
+#include <ndnboost/test/utils/basic_cstring/basic_cstring.hpp>
+
+// STL
+#include <string>
+
+#include <ndnboost/test/detail/suppress_warnings.hpp>
+
+//____________________________________________________________________________//
+
+namespace ndnboost {
+
+namespace debug {
+
+// ************************************************************************** //
+// ************** check if program is running under debugger ************** //
+// ************************************************************************** //
+
+bool BOOST_TEST_DECL under_debugger();
+
+// ************************************************************************** //
+// ************** cause program to break execution ************** //
+// ************** in debugger at call point ************** //
+// ************************************************************************** //
+
+void BOOST_TEST_DECL debugger_break();
+
+// ************************************************************************** //
+// ************** gui debugger setup ************** //
+// ************************************************************************** //
+
+struct dbg_startup_info {
+ long pid;
+ bool break_or_continue;
+ unit_test::const_string binary_path;
+ unit_test::const_string display;
+ unit_test::const_string init_done_lock;
+};
+
+typedef unit_test::callback1<dbg_startup_info const&> dbg_starter;
+
+// ************************************************************************** //
+// ************** debugger setup ************** //
+// ************************************************************************** //
+
+#if BOOST_WORKAROUND( BOOST_MSVC, <1300)
+
+std::string BOOST_TEST_DECL set_debugger( unit_test::const_string dbg_id );
+
+#else
+
+std::string BOOST_TEST_DECL set_debugger( unit_test::const_string dbg_id, dbg_starter s = dbg_starter() );
+
+#endif
+
+
+// ************************************************************************** //
+// ************** attach debugger to the current process ************** //
+// ************************************************************************** //
+
+bool BOOST_TEST_DECL attach_debugger( bool break_or_continue = true );
+
+// ************************************************************************** //
+// ************** switch on/off detect memory leaks feature ************** //
+// ************************************************************************** //
+
+void BOOST_TEST_DECL detect_memory_leaks( bool on_off );
+
+// ************************************************************************** //
+// ************** cause program to break execution in ************** //
+// ************** debugger at specific allocation point ************** //
+// ************************************************************************** //
+
+void BOOST_TEST_DECL break_memory_alloc( long mem_alloc_order_num );
+
+} // namespace debug
+
+} // namespace ndnboost
+
+#include <ndnboost/test/detail/enable_warnings.hpp>
+
+#endif
diff --git a/ndnboost/test/debug_config.hpp b/ndnboost/test/debug_config.hpp
new file mode 100644
index 0000000..54c21e9
--- /dev/null
+++ b/ndnboost/test/debug_config.hpp
@@ -0,0 +1,24 @@
+// (C) Copyright Gennadiy Rozental 2006-2008.
+// Distributed under 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)
+
+// See http://www.boost.org/libs/test for the library home page.
+//
+// File : $RCSfile$
+//
+// Version : $Revision: 49312 $
+//
+// Description : user's config for Boost.Test debugging support
+// ***************************************************************************
+
+#ifndef BOOST_TEST_DEBUG_CONFIG_HPP_112006GER
+#define BOOST_TEST_DEBUG_CONFIG_HPP_112006GER
+
+// ';' separated list of supported debuggers
+// #define BOOST_TEST_DBG_LIST gdb;dbx
+
+// maximum size of /proc/pid/stat file
+// #define BOOST_TEST_STAT_LINE_MAX
+
+#endif
diff --git a/ndnboost/test/detail/config.hpp b/ndnboost/test/detail/config.hpp
new file mode 100644
index 0000000..1b6ae68
--- /dev/null
+++ b/ndnboost/test/detail/config.hpp
@@ -0,0 +1,104 @@
+// (C) Copyright Gennadiy Rozental 2001-2008.
+// Distributed under 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)
+
+// See http://www.boost.org/libs/test for the library home page.
+//
+// File : $RCSfile$
+//
+// Version : $Revision: 63441 $
+//
+// Description : as a central place for global configuration switches
+// ***************************************************************************
+
+#ifndef BOOST_TEST_CONFIG_HPP_071894GER
+#define BOOST_TEST_CONFIG_HPP_071894GER
+
+// Boost
+#include <ndnboost/config.hpp> // compilers workarounds
+#include <ndnboost/detail/workaround.hpp>
+
+//____________________________________________________________________________//
+
+#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x570)) || \
+ BOOST_WORKAROUND(__IBMCPP__, BOOST_TESTED_AT(600)) || \
+ (defined __sgi && BOOST_WORKAROUND(_COMPILER_VERSION, BOOST_TESTED_AT(730)))
+# define BOOST_TEST_SHIFTED_LINE
+#endif
+
+//____________________________________________________________________________//
+
+#if defined(BOOST_MSVC) || (defined(__BORLANDC__) && !defined(BOOST_DISABLE_WIN32))
+# define BOOST_TEST_CALL_DECL __cdecl
+#else
+# define BOOST_TEST_CALL_DECL /**/
+#endif
+
+//____________________________________________________________________________//
+
+#if !defined(BOOST_NO_STD_LOCALE) && \
+ !BOOST_WORKAROUND(BOOST_MSVC, < 1310) && \
+ !defined(__MWERKS__)
+# define BOOST_TEST_USE_STD_LOCALE 1
+#endif
+
+//____________________________________________________________________________//
+
+#if BOOST_WORKAROUND(__BORLANDC__, <= 0x570) || \
+ BOOST_WORKAROUND( __COMO__, <= 0x433 ) || \
+ BOOST_WORKAROUND( __INTEL_COMPILER, <= 800 ) || \
+ defined(__sgi) && _COMPILER_VERSION <= 730 || \
+ BOOST_WORKAROUND(__IBMCPP__, BOOST_TESTED_AT(600)) || \
+ defined(__DECCXX) || \
+ defined(__DMC__)
+# define BOOST_TEST_NO_PROTECTED_USING
+#endif
+
+//____________________________________________________________________________//
+
+#if defined(__GNUC__) || BOOST_WORKAROUND(BOOST_MSVC, == 1400)
+#define BOOST_TEST_PROTECTED_VIRTUAL virtual
+#else
+#define BOOST_TEST_PROTECTED_VIRTUAL
+#endif
+
+//____________________________________________________________________________//
+
+#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) && \
+ !BOOST_WORKAROUND(BOOST_MSVC, <1310) && \
+ !BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x530))
+# define BOOST_TEST_SUPPORT_INTERACTION_TESTING 1
+#endif
+
+//____________________________________________________________________________//
+
+#if defined(BOOST_ALL_DYN_LINK) && !defined(BOOST_TEST_DYN_LINK)
+# define BOOST_TEST_DYN_LINK
+#endif
+
+#if defined(BOOST_TEST_INCLUDED)
+# undef BOOST_TEST_DYN_LINK
+#endif
+
+#if defined(BOOST_TEST_DYN_LINK)
+# define BOOST_TEST_ALTERNATIVE_INIT_API
+
+# ifdef BOOST_TEST_SOURCE
+# define BOOST_TEST_DECL BOOST_SYMBOL_EXPORT
+# else
+# define BOOST_TEST_DECL BOOST_SYMBOL_IMPORT
+# endif // BOOST_TEST_SOURCE
+#else
+# define BOOST_TEST_DECL
+#endif
+
+#if !defined(BOOST_TEST_MAIN) && defined(BOOST_AUTO_TEST_MAIN)
+#define BOOST_TEST_MAIN BOOST_AUTO_TEST_MAIN
+#endif
+
+#if !defined(BOOST_TEST_MAIN) && defined(BOOST_TEST_MODULE)
+#define BOOST_TEST_MAIN BOOST_TEST_MODULE
+#endif
+
+#endif // BOOST_TEST_CONFIG_HPP_071894GER
diff --git a/ndnboost/test/detail/enable_warnings.hpp b/ndnboost/test/detail/enable_warnings.hpp
new file mode 100644
index 0000000..2d67fb0
--- /dev/null
+++ b/ndnboost/test/detail/enable_warnings.hpp
@@ -0,0 +1,30 @@
+// (C) Copyright Gennadiy Rozental 2004-2008.
+// Distributed under 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)
+
+// See http://www.boost.org/libs/test for the library home page.
+//
+// File : $RCSfile$
+//
+// Version : $Revision: 54633 $
+//
+// Description : enable previosly suppressed warnings
+// ***************************************************************************
+
+#ifdef BOOST_MSVC
+# pragma warning(default: 4511) // copy constructor can't not be generated
+# pragma warning(default: 4512) // assignment operator can't not be generated
+# pragma warning(default: 4100) // unreferenced formal parameter
+# pragma warning(default: 4996) // <symbol> was declared deprecated
+# pragma warning(default: 4355) // 'this' : used in base member initializer list
+# pragma warning(default: 4706) // assignment within conditional expression
+# pragma warning(default: 4251) // class 'A<T>' needs to have dll-interface to be used by clients of class 'B'
+# pragma warning(default: 4127) // conditional expression is constant
+# pragma warning(default: 4290) // C++ exception specification ignored except to ...
+# pragma warning(default: 4180) // qualifier applied to function type has no meaning; ignored
+# pragma warning(default: 4275) // non dll-interface class ... used as base for dll-interface class ...
+# pragma warning(default: 4267) // 'var' : conversion from 'size_t' to 'type', possible loss of data
+# pragma warning(default: 4511) // 'class' : copy constructor could not be generated
+# pragma warning(pop)
+#endif
diff --git a/ndnboost/test/detail/fwd_decl.hpp b/ndnboost/test/detail/fwd_decl.hpp
new file mode 100644
index 0000000..b8d2a87
--- /dev/null
+++ b/ndnboost/test/detail/fwd_decl.hpp
@@ -0,0 +1,48 @@
+// (C) Copyright Gennadiy Rozental 2005-2008.
+// Distributed under 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)
+
+// See http://www.boost.org/libs/test for the library home page.
+//
+// File : $RCSfile$
+//
+// Version : $Revision: 49312 $
+//
+// Description : contains forward eclarations for Boost.Test data types
+// ***************************************************************************
+
+#ifndef BOOST_TEST_FWD_DECL_HPP_011605GER
+#define BOOST_TEST_FWD_DECL_HPP_011605GER
+
+namespace ndnboost {
+
+class execution_monitor;
+class execution_exception;
+
+namespace unit_test {
+
+class test_unit;
+class test_case;
+class test_suite;
+class master_test_suite_t;
+
+class test_tree_visitor;
+class test_observer;
+
+// singletons
+class unit_test_monitor_t;
+class unit_test_log_t;
+
+class unit_test_log_formatter;
+struct log_entry_data;
+struct log_checkpoint_data;
+
+class lazy_ostream;
+
+} // namespace unit_test
+
+} // namespace ndnboost
+
+#endif // BOOST_TEST_FWD_DECL_HPP_011605GER
+
diff --git a/ndnboost/test/detail/global_typedef.hpp b/ndnboost/test/detail/global_typedef.hpp
new file mode 100644
index 0000000..e87327a
--- /dev/null
+++ b/ndnboost/test/detail/global_typedef.hpp
@@ -0,0 +1,88 @@
+// (C) Copyright Gennadiy Rozental 2001-2008.
+// Distributed under 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)
+
+// See http://www.boost.org/libs/test for the library home page.
+//
+// File : $RCSfile$
+//
+// Version : $Revision: 54633 $
+//
+// Description : some trivial global typedefs
+// ***************************************************************************
+
+#ifndef BOOST_TEST_GLOBAL_TYPEDEF_HPP_021005GER
+#define BOOST_TEST_GLOBAL_TYPEDEF_HPP_021005GER
+
+#include <ndnboost/test/utils/basic_cstring/basic_cstring.hpp>
+#define BOOST_TEST_L( s ) ndnboost::unit_test::const_string( s, sizeof( s ) - 1 )
+#define BOOST_TEST_STRINGIZE( s ) BOOST_TEST_L( BOOST_STRINGIZE( s ) )
+#define BOOST_TEST_EMPTY_STRING BOOST_TEST_L( "" )
+
+#include <ndnboost/test/detail/suppress_warnings.hpp>
+
+//____________________________________________________________________________//
+
+namespace ndnboost {
+
+namespace unit_test {
+
+typedef unsigned long counter_t;
+
+//____________________________________________________________________________//
+
+enum report_level { INV_REPORT_LEVEL, CONFIRMATION_REPORT, SHORT_REPORT, DETAILED_REPORT, NO_REPORT };
+
+//____________________________________________________________________________//
+
+enum output_format { INV_OF, CLF /* compiler log format */, XML /* XML */ };
+
+//____________________________________________________________________________//
+
+enum test_unit_type { tut_case = 0x01, tut_suite = 0x10, tut_any = 0x11 };
+
+//____________________________________________________________________________//
+
+typedef unsigned long test_unit_id;
+
+const test_unit_id INV_TEST_UNIT_ID = 0xFFFFFFFF;
+const test_unit_id MAX_TEST_CASE_ID = 0xFFFFFFFE;
+const test_unit_id MIN_TEST_CASE_ID = 0x00010000;
+const test_unit_id MAX_TEST_SUITE_ID = 0x0000FF00;
+const test_unit_id MIN_TEST_SUITE_ID = 0x00000001;
+
+//____________________________________________________________________________//
+
+namespace ut_detail {
+
+inline test_unit_type
+test_id_2_unit_type( test_unit_id id )
+{
+ return (id & 0xFFFF0000) != 0 ? tut_case : tut_suite;
+}
+
+//____________________________________________________________________________//
+
+// helper templates to prevent ODR violations
+template<class T>
+struct static_constant {
+ static T value;
+};
+
+template<class T>
+T static_constant<T>::value;
+
+//____________________________________________________________________________//
+
+} // namespace ut_detail
+
+} // namespace unit_test
+
+} // namespace ndnboost
+
+//____________________________________________________________________________//
+
+#include <ndnboost/test/detail/enable_warnings.hpp>
+
+#endif // BOOST_TEST_GLOBAL_TYPEDEF_HPP_021005GER
diff --git a/ndnboost/test/detail/log_level.hpp b/ndnboost/test/detail/log_level.hpp
new file mode 100644
index 0000000..14e69f4
--- /dev/null
+++ b/ndnboost/test/detail/log_level.hpp
@@ -0,0 +1,43 @@
+// (C) Copyright Gennadiy Rozental 2005-2008.
+// Distributed under 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)
+
+// See http://www.boost.org/libs/test for the library home page.
+//
+// File : $RCSfile$
+//
+// Version : $Revision: 49312 $
+//
+// Description : shared definition for unit test log levels
+// ***************************************************************************
+
+#ifndef BOOST_TEST_LOG_LEVEL_HPP_011605GER
+#define BOOST_TEST_LOG_LEVEL_HPP_011605GER
+
+namespace ndnboost {
+namespace unit_test {
+
+// ************************************************************************** //
+// ************** log levels ************** //
+// ************************************************************************** //
+
+// each log level includes all subsequent higher loging levels
+enum log_level {
+ invalid_log_level = -1,
+ log_successful_tests = 0,
+ log_test_units = 1,
+ log_messages = 2,
+ log_warnings = 3,
+ log_all_errors = 4, // reported by unit test macros
+ log_cpp_exception_errors = 5, // uncaught C++ exceptions
+ log_system_errors = 6, // including timeouts, signals, traps
+ log_fatal_errors = 7, // including unit test macros or
+ // fatal system errors
+ log_nothing = 8
+};
+
+} // namespace unit_test
+} // namespace ndnboost
+
+#endif // BOOST_TEST_LOG_LEVEL_HPP_011605GER
diff --git a/ndnboost/test/detail/suppress_warnings.hpp b/ndnboost/test/detail/suppress_warnings.hpp
new file mode 100644
index 0000000..2471226
--- /dev/null
+++ b/ndnboost/test/detail/suppress_warnings.hpp
@@ -0,0 +1,31 @@
+// (C) Copyright Gennadiy Rozental 2004-2008.
+// Distributed under 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)
+
+// See http://www.boost.org/libs/test for the library home page.
+//
+// File : $RCSfile$
+//
+// Version : $Revision: 54633 $
+//
+// Description : suppress some warnings
+// ***************************************************************************
+
+#ifdef BOOST_MSVC
+# pragma warning(push)
+# pragma warning(disable: 4511) // copy constructor can't not be generated
+# pragma warning(disable: 4512) // assignment operator can't not be generated
+# pragma warning(disable: 4100) // unreferenced formal parameter
+# pragma warning(disable: 4996) // <symbol> was declared deprecated
+# pragma warning(disable: 4355) // 'this' : used in base member initializer list
+# pragma warning(disable: 4706) // assignment within conditional expression
+# pragma warning(disable: 4251) // class 'A<T>' needs to have dll-interface to be used by clients of class 'B'
+# pragma warning(disable: 4127) // conditional expression is constant
+# pragma warning(disable: 4290) // C++ exception specification ignored except to ...
+# pragma warning(disable: 4180) // qualifier applied to function type has no meaning; ignored
+# pragma warning(disable: 4275) // non dll-interface class ... used as base for dll-interface class ...
+# pragma warning(disable: 4267) // 'var' : conversion from 'size_t' to 'type', possible loss of data
+# pragma warning(disable: 4511) // 'class' : copy constructor could not be generated
+#endif
+
diff --git a/ndnboost/test/detail/unit_test_parameters.hpp b/ndnboost/test/detail/unit_test_parameters.hpp
new file mode 100644
index 0000000..364692b
--- /dev/null
+++ b/ndnboost/test/detail/unit_test_parameters.hpp
@@ -0,0 +1,69 @@
+// (C) Copyright Gennadiy Rozental 2001-2008.
+// Distributed under 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)
+
+// See http://www.boost.org/libs/test for the library home page.
+//
+// File : $RCSfile$
+//
+// Version : $Revision: 57992 $
+//
+// Description : storage for unit test framework parameters information
+// ***************************************************************************
+
+#ifndef BOOST_TEST_UNIT_TEST_PARAMETERS_HPP_071894GER
+#define BOOST_TEST_UNIT_TEST_PARAMETERS_HPP_071894GER
+
+#include <ndnboost/test/detail/global_typedef.hpp>
+#include <ndnboost/test/detail/log_level.hpp>
+
+#include <ndnboost/test/detail/suppress_warnings.hpp>
+
+// STL
+#include <iosfwd>
+
+//____________________________________________________________________________//
+
+namespace ndnboost {
+
+namespace unit_test {
+
+// ************************************************************************** //
+// ************** runtime_config ************** //
+// ************************************************************************** //
+
+namespace runtime_config {
+
+BOOST_TEST_DECL void init( int& argc, char** argv );
+
+BOOST_TEST_DECL unit_test::log_level log_level();
+BOOST_TEST_DECL bool no_result_code();
+BOOST_TEST_DECL unit_test::report_level report_level();
+BOOST_TEST_DECL const_string test_to_run();
+BOOST_TEST_DECL const_string break_exec_path();
+BOOST_TEST_DECL bool save_pattern();
+BOOST_TEST_DECL bool show_build_info();
+BOOST_TEST_DECL bool show_progress();
+BOOST_TEST_DECL bool catch_sys_errors();
+BOOST_TEST_DECL bool auto_start_dbg();
+BOOST_TEST_DECL bool use_alt_stack();
+BOOST_TEST_DECL bool detect_fp_exceptions();
+BOOST_TEST_DECL output_format report_format();
+BOOST_TEST_DECL output_format log_format();
+BOOST_TEST_DECL std::ostream* report_sink();
+BOOST_TEST_DECL std::ostream* log_sink();
+BOOST_TEST_DECL long detect_memory_leaks();
+BOOST_TEST_DECL int random_seed();
+
+} // namespace runtime_config
+
+} // namespace unit_test
+
+} // namespace ndnboost
+
+//____________________________________________________________________________//
+
+#include <ndnboost/test/detail/enable_warnings.hpp>
+
+#endif // BOOST_TEST_UNIT_TEST_PARAMETERS_HPP_071894GER
diff --git a/ndnboost/test/detail/workaround.hpp b/ndnboost/test/detail/workaround.hpp
new file mode 100644
index 0000000..654972b
--- /dev/null
+++ b/ndnboost/test/detail/workaround.hpp
@@ -0,0 +1,65 @@
+// (C) Copyright Gennadiy Rozental 2005-2008.
+// Distributed under 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)
+
+// See http://www.boost.org/libs/test for the library home page.
+//
+// File : $RCSfile$
+//
+// Version : $Revision: 54633 $
+//
+// Description : contains mics. workarounds
+// ***************************************************************************
+
+#ifndef BOOST_TEST_WORKAROUND_HPP_021005GER
+#define BOOST_TEST_WORKAROUND_HPP_021005GER
+
+// Boost
+#include <ndnboost/config.hpp> // compilers workarounds and std::ptrdiff_t
+
+// STL
+#include <iterator> // for std::distance
+
+#include <ndnboost/test/detail/suppress_warnings.hpp>
+
+//____________________________________________________________________________//
+
+namespace ndnboost {
+
+namespace unit_test {
+
+namespace ut_detail {
+
+#ifdef BOOST_NO_STD_DISTANCE
+template <class T>
+std::ptrdiff_t distance( T const& x_, T const& y_ )
+{
+ std::ptrdiff_t res = 0;
+
+ std::distance( x_, y_, res );
+
+ return res;
+}
+
+//____________________________________________________________________________//
+
+#else
+using std::distance;
+#endif
+
+template <class T> inline void ignore_unused_variable_warning(const T&) {}
+
+} // namespace ut_detail
+
+} // namespace unit_test
+
+namespace unit_test_framework = unit_test;
+
+} // namespace ndnboost
+
+//____________________________________________________________________________//
+
+#include <ndnboost/test/detail/enable_warnings.hpp>
+
+#endif // BOOST_TEST_WORKAROUND_HPP_021005GER
diff --git a/ndnboost/test/execution_monitor.hpp b/ndnboost/test/execution_monitor.hpp
new file mode 100644
index 0000000..8475686
--- /dev/null
+++ b/ndnboost/test/execution_monitor.hpp
@@ -0,0 +1,263 @@
+// (C) Copyright Gennadiy Rozental 2001-2008.
+// (C) Copyright Beman Dawes 2001.
+// Distributed under 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)
+
+// See http://www.boost.org/libs/test for the library home page.
+//
+// File : $RCSfile$
+//
+// Version : $Revision: 57992 $
+//
+// Description : defines abstract monitor interfaces and implements execution exception
+// The original Boost Test Library included an implementation detail function
+// named catch_exceptions() which caught otherwise uncaught C++ exceptions.
+// It was derived from an existing test framework by Beman Dawes. The
+// intent was to expand later to catch other detectable but platform dependent
+// error events like Unix signals or Windows structured C exceptions.
+//
+// Requests from early adopters of the Boost Test Library included
+// configurable levels of error message detail, elimination of templates,
+// separation of error reporting, and making the catch_exceptions() facilities
+// available as a public interface. Support for unit testing also stretched
+// the function based design. Implementation within the header became less
+// attractive due to the need to include many huge system dependent headers,
+// although still preferable in certain cases.
+//
+// All those issues have been addressed by introducing the class-based
+// design presented here.
+// ***************************************************************************
+
+#ifndef BOOST_TEST_EXECUTION_MONITOR_HPP_071894GER
+#define BOOST_TEST_EXECUTION_MONITOR_HPP_071894GER
+
+// Boost.Test
+#include <ndnboost/test/detail/global_typedef.hpp>
+#include <ndnboost/test/detail/fwd_decl.hpp>
+#include <ndnboost/test/utils/callback.hpp>
+#include <ndnboost/test/utils/class_properties.hpp>
+
+// Boost
+#include <ndnboost/scoped_ptr.hpp>
+#include <ndnboost/scoped_array.hpp>
+#include <ndnboost/type.hpp>
+#include <ndnboost/cstdlib.hpp>
+
+#include <ndnboost/test/detail/suppress_warnings.hpp>
+
+//____________________________________________________________________________//
+
+namespace ndnboost {
+
+namespace detail {
+
+// ************************************************************************** //
+// ************** detail::translate_exception_base ************** //
+// ************************************************************************** //
+
+class BOOST_TEST_DECL translate_exception_base {
+public:
+ // Constructor
+ explicit translate_exception_base( ndnboost::scoped_ptr<translate_exception_base>& next )
+ {
+ next.swap( m_next );
+ }
+
+ // Destructor
+ virtual ~translate_exception_base() {}
+
+ virtual int operator()( unit_test::callback0<int> const& F ) = 0;
+
+protected:
+ // Data members
+ ndnboost::scoped_ptr<translate_exception_base> m_next;
+};
+
+} // namespace detail
+
+// ************************************************************************** //
+// ************** execution_exception ************** //
+// ************************************************************************** //
+
+// design rationale: fear of being out (or nearly out) of memory.
+
+class BOOST_TEST_DECL execution_exception {
+ typedef ndnboost::unit_test::const_string const_string;
+public:
+ enum error_code {
+ // These values are sometimes used as program return codes.
+ // The particular values have been chosen to avoid conflicts with
+ // commonly used program return codes: values < 100 are often user
+ // assigned, values > 255 are sometimes used to report system errors.
+ // Gaps in values allow for orderly expansion.
+
+ no_error = 0, // for completeness only; never returned
+ user_error = 200, // user reported non-fatal error
+ cpp_exception_error = 205, // see note (1) below
+ system_error = 210, // see note (2) below
+ timeout_error = 215, // only detectable on certain platforms
+ user_fatal_error = 220, // user reported fatal error
+ system_fatal_error = 225 // see note (2) below
+
+ // Note 1: Only uncaught C++ exceptions are treated as errors.
+ // If the application catches a C++ exception, it will never reach
+ // the execution_monitor.
+
+ // Note 2: These errors include Unix signals and Windows structured
+ // exceptions. They are often initiated by hardware traps.
+ //
+ // The implementation decides what is a fatal_system_exception and what is
+ // just a system_exception. Fatal errors are so likely to have corrupted
+ // machine state (like a stack overflow or addressing exception) that it
+ // is unreasonable to continue execution.
+ };
+
+ struct BOOST_TEST_DECL location {
+ explicit location( char const* file_name = 0, size_t line_num = 0, char const* func = 0 );
+
+ const_string m_file_name;
+ size_t m_line_num;
+ const_string m_function;
+ };
+
+ // Constructor
+ execution_exception( error_code ec_, const_string what_msg_, location const& location_ ); // max length 256 inc '\0'
+
+ // Access methods
+ error_code code() const { return m_error_code; }
+ const_string what() const { return m_what; }
+ location const& where() const { return m_location; }
+
+private:
+ // Data members
+ error_code m_error_code;
+ const_string m_what;
+ location m_location;
+}; // execution_exception
+
+// ************************************************************************** //
+// ************** execution_monitor ************** //
+// ************************************************************************** //
+
+class BOOST_TEST_DECL execution_monitor {
+public:
+ // Constructor
+ execution_monitor()
+ : p_catch_system_errors( true )
+ , p_auto_start_dbg( false )
+ , p_timeout( 0 )
+ , p_use_alt_stack( true )
+ , p_detect_fp_exceptions( false )
+ {}
+
+ // Public properties
+
+ // The p_catch_system_errors parameter specifies whether the monitor should
+ // try to catch system errors/exceptions that would cause program to crash
+ // in regular case
+ unit_test::readwrite_property<bool> p_catch_system_errors;
+ // The p_auto_start_dbg parameter specifies whether the monitor should
+ // try to attach debugger in case of caught system error
+ unit_test::readwrite_property<bool> p_auto_start_dbg;
+ // The p_timeout parameter specifies the seconds that elapse before
+ // a timer_error occurs. May be ignored on some platforms.
+ unit_test::readwrite_property<int> p_timeout;
+ // The p_use_alt_stack parameter specifies whether the monitor should
+ // use alternative stack for the signal catching
+ unit_test::readwrite_property<bool> p_use_alt_stack;
+ // The p_detect_fp_exceptions parameter specifies whether the monitor should
+ // try to detect hardware floating point exceptions
+ unit_test::readwrite_property<bool> p_detect_fp_exceptions;
+
+ int execute( unit_test::callback0<int> const& F );
+ // Returns: Value returned by function call F().
+ //
+ // Effects: Calls executes supplied function F inside a try/catch block which also may
+ // include other unspecified platform dependent error detection code.
+ //
+ // Throws: execution_exception on an uncaught C++ exception,
+ // a hardware or software signal, trap, or other exception.
+ //
+ // Note: execute() doesn't consider it an error for F to return a non-zero value.
+
+ // register custom (user supplied) exception translator
+ template<typename Exception, typename ExceptionTranslator>
+ void register_exception_translator( ExceptionTranslator const& tr, ndnboost::type<Exception>* = 0 );
+
+private:
+ // implementation helpers
+ int catch_signals( unit_test::callback0<int> const& F );
+
+ // Data members
+ ndnboost::scoped_ptr<detail::translate_exception_base> m_custom_translators;
+ ndnboost::scoped_array<char> m_alt_stack;
+}; // execution_monitor
+
+namespace detail {
+
+// ************************************************************************** //
+// ************** detail::translate_exception ************** //
+// ************************************************************************** //
+
+template<typename Exception, typename ExceptionTranslator>
+class translate_exception : public translate_exception_base
+{
+ typedef ndnboost::scoped_ptr<translate_exception_base> base_ptr;
+public:
+ explicit translate_exception( ExceptionTranslator const& tr, base_ptr& next )
+ : translate_exception_base( next ), m_translator( tr ) {}
+
+ int operator()( unit_test::callback0<int> const& F )
+ {
+ try {
+ return m_next ? (*m_next)( F ) : F();
+ } catch( Exception const& e ) {
+ m_translator( e );
+ return ndnboost::exit_exception_failure;
+ }
+ }
+
+private:
+ // Data members
+ ExceptionTranslator m_translator;
+};
+
+} // namespace detail
+
+template<typename Exception, typename ExceptionTranslator>
+void
+execution_monitor::register_exception_translator( ExceptionTranslator const& tr, ndnboost::type<Exception>* )
+{
+ m_custom_translators.reset(
+ new detail::translate_exception<Exception,ExceptionTranslator>( tr,m_custom_translators ) );
+}
+
+// ************************************************************************** //
+// ************** execution_aborted ************** //
+// ************************************************************************** //
+
+struct execution_aborted {};
+
+// ************************************************************************** //
+// ************** system_error ************** //
+// ************************************************************************** //
+
+class system_error {
+public:
+ // Constructor
+ explicit system_error( char const* exp );
+
+ unit_test::readonly_property<long> p_errno;
+ unit_test::readonly_property<char const*> p_failed_exp;
+};
+
+#define BOOST_TEST_SYS_ASSERT( exp ) if( (exp) ) ; else throw ::ndnboost::system_error( BOOST_STRINGIZE( exp ) )
+
+} // namespace ndnboost
+
+//____________________________________________________________________________//
+
+#include <ndnboost/test/detail/enable_warnings.hpp>
+
+#endif
diff --git a/ndnboost/test/floating_point_comparison.hpp b/ndnboost/test/floating_point_comparison.hpp
new file mode 100644
index 0000000..211f29b
--- /dev/null
+++ b/ndnboost/test/floating_point_comparison.hpp
@@ -0,0 +1,286 @@
+// (C) Copyright Gennadiy Rozental 2001-2008.
+// Distributed under 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)
+
+// See http://www.boost.org/libs/test for the library home page.
+//
+// File : $RCSfile$
+//
+// Version : $Revision: 57992 $
+//
+// Description : defines algoirthms for comparing 2 floating point values
+// ***************************************************************************
+
+#ifndef BOOST_TEST_FLOATING_POINT_COMPARISON_HPP_071894GER
+#define BOOST_TEST_FLOATING_POINT_COMPARISON_HPP_071894GER
+
+// Boost.Test
+#include <ndnboost/test/detail/global_typedef.hpp>
+#include <ndnboost/test/utils/class_properties.hpp>
+#include <ndnboost/test/predicate_result.hpp>
+
+// Boost
+#include <ndnboost/limits.hpp> // for std::numeric_limits
+#include <ndnboost/numeric/conversion/conversion_traits.hpp> // for numeric::conversion_traits
+#include <ndnboost/static_assert.hpp>
+
+#include <ndnboost/test/detail/suppress_warnings.hpp>
+
+//____________________________________________________________________________//
+
+namespace ndnboost {
+
+namespace test_tools {
+
+using unit_test::readonly_property;
+
+// ************************************************************************** //
+// ************** floating_point_comparison_type ************** //
+// ************************************************************************** //
+
+enum floating_point_comparison_type {
+ FPC_STRONG, // "Very close" - equation 1' in docs, the default
+ FPC_WEAK // "Close enough" - equation 2' in docs.
+
+};
+
+// ************************************************************************** //
+// ************** details ************** //
+// ************************************************************************** //
+
+namespace tt_detail {
+
+// FPT is Floating-Point Type: float, double, long double or User-Defined.
+template<typename FPT>
+inline FPT
+fpt_abs( FPT fpv )
+{
+ return fpv < static_cast<FPT>(0) ? -fpv : fpv;
+}
+
+//____________________________________________________________________________//
+
+template<typename FPT>
+struct fpt_limits {
+ static FPT min_value()
+ {
+ return std::numeric_limits<FPT>::is_specialized
+ ? (std::numeric_limits<FPT>::min)()
+ : 0;
+ }
+ static FPT max_value()
+ {
+ return std::numeric_limits<FPT>::is_specialized
+ ? (std::numeric_limits<FPT>::max)()
+ : static_cast<FPT>(1000000); // for the our purpuses it doesn't really matter what value is returned here
+ }
+};
+
+//____________________________________________________________________________//
+
+// both f1 and f2 are unsigned here
+template<typename FPT>
+inline FPT
+safe_fpt_division( FPT f1, FPT f2 )
+{
+ // Avoid overflow.
+ if( (f2 < static_cast<FPT>(1)) && (f1 > f2*fpt_limits<FPT>::max_value()) )
+ return fpt_limits<FPT>::max_value();
+
+ // Avoid underflow.
+ if( (f1 == static_cast<FPT>(0)) ||
+ ((f2 > static_cast<FPT>(1)) && (f1 < f2*fpt_limits<FPT>::min_value())) )
+ return static_cast<FPT>(0);
+
+ return f1/f2;
+}
+
+//____________________________________________________________________________//
+
+} // namespace tt_detail
+
+// ************************************************************************** //
+// ************** tolerance presentation types ************** //
+// ************************************************************************** //
+
+template<typename FPT>
+struct percent_tolerance_t {
+ explicit percent_tolerance_t( FPT v ) : m_value( v ) {}
+
+ FPT m_value;
+};
+
+//____________________________________________________________________________//
+
+template<typename Out,typename FPT>
+Out& operator<<( Out& out, percent_tolerance_t<FPT> t )
+{
+ return out << t.m_value;
+}
+
+//____________________________________________________________________________//
+
+template<typename FPT>
+inline percent_tolerance_t<FPT>
+percent_tolerance( FPT v )
+{
+ return percent_tolerance_t<FPT>( v );
+}
+
+//____________________________________________________________________________//
+
+template<typename FPT>
+struct fraction_tolerance_t {
+ explicit fraction_tolerance_t( FPT v ) : m_value( v ) {}
+
+ FPT m_value;
+};
+
+//____________________________________________________________________________//
+
+template<typename Out,typename FPT>
+Out& operator<<( Out& out, fraction_tolerance_t<FPT> t )
+{
+ return out << t.m_value;
+}
+
+//____________________________________________________________________________//
+
+template<typename FPT>
+inline fraction_tolerance_t<FPT>
+fraction_tolerance( FPT v )
+{
+ return fraction_tolerance_t<FPT>( v );
+}
+
+//____________________________________________________________________________//
+
+// ************************************************************************** //
+// ************** close_at_tolerance ************** //
+// ************************************************************************** //
+
+template<typename FPT>
+class close_at_tolerance {
+public:
+ // Public typedefs
+ typedef bool result_type;
+
+ // Constructor
+ template<typename ToleranceBaseType>
+ explicit close_at_tolerance( percent_tolerance_t<ToleranceBaseType> tolerance,
+ floating_point_comparison_type fpc_type = FPC_STRONG )
+ : p_fraction_tolerance( tt_detail::fpt_abs( static_cast<FPT>(0.01)*tolerance.m_value ) )
+ , p_strong_or_weak( fpc_type == FPC_STRONG )
+ , m_report_modifier( 100. )
+ {}
+ template<typename ToleranceBaseType>
+ explicit close_at_tolerance( fraction_tolerance_t<ToleranceBaseType> tolerance,
+ floating_point_comparison_type fpc_type = FPC_STRONG )
+ : p_fraction_tolerance( tt_detail::fpt_abs( tolerance.m_value ) )
+ , p_strong_or_weak( fpc_type == FPC_STRONG )
+ , m_report_modifier( 1. )
+ {}
+
+ predicate_result operator()( FPT left, FPT right ) const
+ {
+ FPT diff = tt_detail::fpt_abs( left - right );
+ FPT d1 = tt_detail::safe_fpt_division( diff, tt_detail::fpt_abs( right ) );
+ FPT d2 = tt_detail::safe_fpt_division( diff, tt_detail::fpt_abs( left ) );
+
+ predicate_result res( p_strong_or_weak
+ ? (d1 <= p_fraction_tolerance.get() && d2 <= p_fraction_tolerance.get())
+ : (d1 <= p_fraction_tolerance.get() || d2 <= p_fraction_tolerance.get()) );
+
+ if( !res )
+ res.message() << (( d1 <= p_fraction_tolerance.get() ? d2 : d1 ) * m_report_modifier);
+
+ return res;
+ }
+
+ // Public properties
+ readonly_property<FPT> p_fraction_tolerance;
+ readonly_property<bool> p_strong_or_weak;
+private:
+ // Data members
+ FPT m_report_modifier;
+};
+
+//____________________________________________________________________________//
+
+// ************************************************************************** //
+// ************** check_is_close ************** //
+// ************************************************************************** //
+
+struct BOOST_TEST_DECL check_is_close_t {
+ // Public typedefs
+ typedef bool result_type;
+
+ template<typename FPT1, typename FPT2, typename ToleranceBaseType>
+ predicate_result
+ operator()( FPT1 left, FPT2 right, percent_tolerance_t<ToleranceBaseType> tolerance,
+ floating_point_comparison_type fpc_type = FPC_STRONG ) const
+ {
+ // deduce "better" type from types of arguments being compared
+ // if one type is floating and the second integral we use floating type and
+ // value of integral type is promoted to the floating. The same for float and double
+ // But we don't want to compare two values of integral types using this tool.
+ typedef typename numeric::conversion_traits<FPT1,FPT2>::supertype FPT;
+ BOOST_STATIC_ASSERT( !is_integral<FPT>::value );
+
+ close_at_tolerance<FPT> pred( tolerance, fpc_type );
+
+ return pred( left, right );
+ }
+ template<typename FPT1, typename FPT2, typename ToleranceBaseType>
+ predicate_result
+ operator()( FPT1 left, FPT2 right, fraction_tolerance_t<ToleranceBaseType> tolerance,
+ floating_point_comparison_type fpc_type = FPC_STRONG ) const
+ {
+ // same as in a comment above
+ typedef typename numeric::conversion_traits<FPT1,FPT2>::supertype FPT;
+ BOOST_STATIC_ASSERT( !is_integral<FPT>::value );
+
+ close_at_tolerance<FPT> pred( tolerance, fpc_type );
+
+ return pred( left, right );
+ }
+};
+
+namespace {
+check_is_close_t const& check_is_close = unit_test::ut_detail::static_constant<check_is_close_t>::value;
+}
+
+//____________________________________________________________________________//
+
+// ************************************************************************** //
+// ************** check_is_small ************** //
+// ************************************************************************** //
+
+struct BOOST_TEST_DECL check_is_small_t {
+ // Public typedefs
+ typedef bool result_type;
+
+ template<typename FPT>
+ bool
+ operator()( FPT fpv, FPT tolerance ) const
+ {
+ return tt_detail::fpt_abs( fpv ) < tt_detail::fpt_abs( tolerance );
+ }
+};
+
+namespace {
+check_is_small_t const& check_is_small = unit_test::ut_detail::static_constant<check_is_small_t>::value;
+}
+
+//____________________________________________________________________________//
+
+} // namespace test_tools
+
+} // namespace ndnboost
+
+//____________________________________________________________________________//
+
+#include <ndnboost/test/detail/enable_warnings.hpp>
+
+#endif // BOOST_FLOATING_POINT_COMAPARISON_HPP_071894GER
diff --git a/ndnboost/test/framework.hpp b/ndnboost/test/framework.hpp
new file mode 100644
index 0000000..43d249d
--- /dev/null
+++ b/ndnboost/test/framework.hpp
@@ -0,0 +1,112 @@
+// (C) Copyright Gennadiy Rozental 2005-2008.
+// Distributed under 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)
+
+// See http://www.boost.org/libs/test for the library home page.
+//
+// File : $RCSfile$
+//
+// Version : $Revision: 54633 $
+//
+// Description : defines framework interface
+// ***************************************************************************
+
+#ifndef BOOST_TEST_FRAMEWORK_HPP_020805GER
+#define BOOST_TEST_FRAMEWORK_HPP_020805GER
+
+// Boost.Test
+#include <ndnboost/test/detail/global_typedef.hpp>
+#include <ndnboost/test/detail/fwd_decl.hpp>
+#include <ndnboost/test/utils/trivial_singleton.hpp>
+
+#include <ndnboost/test/detail/suppress_warnings.hpp>
+
+// STL
+#include <stdexcept>
+
+//____________________________________________________________________________//
+
+namespace ndnboost {
+
+namespace unit_test {
+
+// ************************************************************************** //
+// ************** init_unit_test_func ************** //
+// ************************************************************************** //
+
+#ifdef BOOST_TEST_ALTERNATIVE_INIT_API
+typedef bool (*init_unit_test_func)();
+#else
+typedef test_suite* (*init_unit_test_func)( int, char* [] );
+#endif
+
+// ************************************************************************** //
+// ************** framework ************** //
+// ************************************************************************** //
+
+namespace framework {
+
+// initialization
+BOOST_TEST_DECL void init( init_unit_test_func init_func, int argc, char* argv[] );
+BOOST_TEST_DECL bool is_initialized();
+
+// mutation access methods
+BOOST_TEST_DECL void register_test_unit( test_case* tc );
+BOOST_TEST_DECL void register_test_unit( test_suite* ts );
+BOOST_TEST_DECL void deregister_test_unit( test_unit* tu );
+BOOST_TEST_DECL void clear();
+
+BOOST_TEST_DECL void register_observer( test_observer& );
+BOOST_TEST_DECL void deregister_observer( test_observer& );
+BOOST_TEST_DECL void reset_observers();
+
+BOOST_TEST_DECL master_test_suite_t& master_test_suite();
+
+// constant access methods
+BOOST_TEST_DECL test_case const& current_test_case();
+
+BOOST_TEST_DECL test_unit& get( test_unit_id, test_unit_type );
+template<typename UnitType>
+UnitType& get( test_unit_id id )
+{
+ return static_cast<UnitType&>( get( id, static_cast<test_unit_type>(UnitType::type) ) );
+}
+
+// test initiation
+BOOST_TEST_DECL void run( test_unit_id = INV_TEST_UNIT_ID, bool continue_test = true );
+BOOST_TEST_DECL void run( test_unit const*, bool continue_test = true );
+
+// public test events dispatchers
+BOOST_TEST_DECL void assertion_result( bool passed );
+BOOST_TEST_DECL void exception_caught( execution_exception const& );
+BOOST_TEST_DECL void test_unit_aborted( test_unit const& );
+
+// ************************************************************************** //
+// ************** framework errors ************** //
+// ************************************************************************** //
+
+struct internal_error : std::runtime_error {
+ internal_error( const_string m ) : std::runtime_error( std::string( m.begin(), m.size() ) ) {}
+};
+
+struct setup_error : std::runtime_error {
+ setup_error( const_string m ) : std::runtime_error( std::string( m.begin(), m.size() ) ) {}
+};
+
+#define BOOST_TEST_SETUP_ASSERT( cond, msg ) if( cond ) {} else throw unit_test::framework::setup_error( msg )
+
+struct nothing_to_test {}; // not really an error
+
+} // namespace framework
+
+} // unit_test
+
+} // namespace ndnboost
+
+//____________________________________________________________________________//
+
+#include <ndnboost/test/detail/enable_warnings.hpp>
+
+#endif // BOOST_TEST_FRAMEWORK_HPP_020805GER
+
diff --git a/ndnboost/test/impl/compiler_log_formatter.ipp b/ndnboost/test/impl/compiler_log_formatter.ipp
new file mode 100644
index 0000000..e153920
--- /dev/null
+++ b/ndnboost/test/impl/compiler_log_formatter.ipp
@@ -0,0 +1,222 @@
+// (C) Copyright Gennadiy Rozental 2005-2008.
+// Distributed under 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)
+
+// See http://www.boost.org/libs/test for the library home page.
+//
+// File : $RCSfile$
+//
+// Version : $Revision: 57992 $
+//
+// Description : implements compiler like Log formatter
+// ***************************************************************************
+
+#ifndef BOOST_TEST_COMPILER_LOG_FORMATTER_IPP_020105GER
+#define BOOST_TEST_COMPILER_LOG_FORMATTER_IPP_020105GER
+
+// Boost.Test
+#include <ndnboost/test/output/compiler_log_formatter.hpp>
+#include <ndnboost/test/unit_test_suite_impl.hpp>
+#include <ndnboost/test/framework.hpp>
+#include <ndnboost/test/utils/basic_cstring/io.hpp>
+#include <ndnboost/test/utils/lazy_ostream.hpp>
+
+// Boost
+#include <ndnboost/version.hpp>
+
+// STL
+#include <iostream>
+
+#include <ndnboost/test/detail/suppress_warnings.hpp>
+
+//____________________________________________________________________________//
+
+namespace ndnboost {
+
+namespace unit_test {
+
+namespace output {
+
+// ************************************************************************** //
+// ************** compiler_log_formatter ************** //
+// ************************************************************************** //
+
+namespace {
+
+const_string
+test_phase_identifier()
+{
+ return framework::is_initialized()
+ ? const_string( framework::current_test_case().p_name.get() )
+ : BOOST_TEST_L( "Test setup" );
+}
+
+} // local namespace
+
+//____________________________________________________________________________//
+
+void
+compiler_log_formatter::log_start( std::ostream& output, counter_t test_cases_amount )
+{
+ if( test_cases_amount > 0 )
+ output << "Running " << test_cases_amount << " test "
+ << (test_cases_amount > 1 ? "cases" : "case") << "...\n";
+}
+
+//____________________________________________________________________________//
+
+void
+compiler_log_formatter::log_finish( std::ostream& ostr )
+{
+ ostr.flush();
+}
+
+//____________________________________________________________________________//
+
+void
+compiler_log_formatter::log_build_info( std::ostream& output )
+{
+ output << "Platform: " << BOOST_PLATFORM << '\n'
+ << "Compiler: " << BOOST_COMPILER << '\n'
+ << "STL : " << BOOST_STDLIB << '\n'
+ << "Boost : " << BOOST_VERSION/100000 << "."
+ << BOOST_VERSION/100 % 1000 << "."
+ << BOOST_VERSION % 100 << std::endl;
+}
+
+//____________________________________________________________________________//
+
+void
+compiler_log_formatter::test_unit_start( std::ostream& output, test_unit const& tu )
+{
+ output << "Entering test " << tu.p_type_name << " \"" << tu.p_name << "\"" << std::endl;
+}
+
+//____________________________________________________________________________//
+
+void
+compiler_log_formatter::test_unit_finish( std::ostream& output, test_unit const& tu, unsigned long elapsed )
+{
+ output << "Leaving test " << tu.p_type_name << " \"" << tu.p_name << "\"";
+
+ if( elapsed > 0 ) {
+ output << "; testing time: ";
+ if( elapsed % 1000 == 0 )
+ output << elapsed/1000 << "ms";
+ else
+ output << elapsed << "mks";
+ }
+
+ output << std::endl;
+}
+
+//____________________________________________________________________________//
+
+void
+compiler_log_formatter::test_unit_skipped( std::ostream& output, test_unit const& tu )
+{
+ output << "Test " << tu.p_type_name << " \"" << tu.p_name << "\"" << "is skipped" << std::endl;
+}
+
+//____________________________________________________________________________//
+
+void
+compiler_log_formatter::log_exception( std::ostream& output, log_checkpoint_data const& checkpoint_data, execution_exception const& ex )
+{
+ execution_exception::location const& loc = ex.where();
+ print_prefix( output, loc.m_file_name, loc.m_line_num );
+
+ output << "fatal error in \"" << (loc.m_function.is_empty() ? test_phase_identifier() : loc.m_function ) << "\": ";
+
+ output << ex.what();
+
+ if( !checkpoint_data.m_file_name.is_empty() ) {
+ output << '\n';
+ print_prefix( output, checkpoint_data.m_file_name, checkpoint_data.m_line_num );
+ output << "last checkpoint";
+ if( !checkpoint_data.m_message.empty() )
+ output << ": " << checkpoint_data.m_message;
+ }
+
+ output << std::endl;
+}
+
+//____________________________________________________________________________//
+
+void
+compiler_log_formatter::log_entry_start( std::ostream& output, log_entry_data const& entry_data, log_entry_types let )
+{
+ switch( let ) {
+ case BOOST_UTL_ET_INFO:
+ print_prefix( output, entry_data.m_file_name, entry_data.m_line_num );
+ output << "info: ";
+ break;
+ case BOOST_UTL_ET_MESSAGE:
+ break;
+ case BOOST_UTL_ET_WARNING:
+ print_prefix( output, entry_data.m_file_name, entry_data.m_line_num );
+ output << "warning in \"" << test_phase_identifier() << "\": ";
+ break;
+ case BOOST_UTL_ET_ERROR:
+ print_prefix( output, entry_data.m_file_name, entry_data.m_line_num );
+ output << "error in \"" << test_phase_identifier() << "\": ";
+ break;
+ case BOOST_UTL_ET_FATAL_ERROR:
+ print_prefix( output, entry_data.m_file_name, entry_data.m_line_num );
+ output << "fatal error in \"" << test_phase_identifier() << "\": ";
+ break;
+ }
+}
+
+//____________________________________________________________________________//
+
+void
+compiler_log_formatter::log_entry_value( std::ostream& output, const_string value )
+{
+ output << value;
+}
+
+//____________________________________________________________________________//
+
+void
+compiler_log_formatter::log_entry_value( std::ostream& output, lazy_ostream const& value )
+{
+ output << value;
+}
+
+//____________________________________________________________________________//
+
+void
+compiler_log_formatter::log_entry_finish( std::ostream& output )
+{
+ output << std::endl;
+}
+
+//____________________________________________________________________________//
+
+void
+compiler_log_formatter::print_prefix( std::ostream& output, const_string file, std::size_t line )
+{
+#ifdef __APPLE_CC__
+ // Xcode-compatible logging format, idea by Richard Dingwall at
+ // <http://richarddingwall.name/2008/06/01/using-the-boost-unit-test-framework-with-xcode-3/>.
+ output << file << ':' << line << ": ";
+#else
+ output << file << '(' << line << "): ";
+#endif
+}
+
+//____________________________________________________________________________//
+
+} // namespace output
+
+} // namespace unit_test
+
+} // namespace ndnboost
+
+//____________________________________________________________________________//
+
+#include <ndnboost/test/detail/enable_warnings.hpp>
+
+#endif // BOOST_TEST_COMPILER_LOG_FORMATTER_IPP_020105GER
diff --git a/ndnboost/test/impl/cpp_main.ipp b/ndnboost/test/impl/cpp_main.ipp
new file mode 100644
index 0000000..3bacee1
--- /dev/null
+++ b/ndnboost/test/impl/cpp_main.ipp
@@ -0,0 +1,139 @@
+// (C) Copyright Gennadiy Rozental 2001-2008.
+// (C) Copyright Beman Dawes 1995-2001.
+// Distributed under 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)
+
+// See http://www.boost.org/libs/test for the library home page.
+//
+// File : $RCSfile$
+//
+// Version : $Revision: 49312 $
+//
+// Description : main function implementation for Program Executon Monitor
+// ***************************************************************************
+
+#ifndef BOOST_TEST_CPP_MAIN_IPP_012205GER
+#define BOOST_TEST_CPP_MAIN_IPP_012205GER
+
+// Boost.Test
+#include <ndnboost/test/execution_monitor.hpp>
+#include <ndnboost/test/detail/config.hpp>
+#include <ndnboost/test/utils/basic_cstring/io.hpp>
+
+// Boost
+#include <ndnboost/cstdlib.hpp> // for exit codes
+#include <ndnboost/config.hpp> // for workarounds
+
+// STL
+#include <iostream>
+#include <cstdlib> // std::getenv
+#include <cstring> // std::strerror
+
+#include <ndnboost/test/detail/suppress_warnings.hpp>
+
+//____________________________________________________________________________//
+
+#ifdef BOOST_NO_STDC_NAMESPACE
+namespace std { using ::getenv; using ::strerror; }
+#endif
+
+namespace {
+
+struct cpp_main_caller {
+ cpp_main_caller( int (*cpp_main_func)( int argc, char* argv[] ), int argc, char** argv )
+ : m_cpp_main_func( cpp_main_func )
+ , m_argc( argc )
+ , m_argv( argv ) {}
+
+ int operator()() { return (*m_cpp_main_func)( m_argc, m_argv ); }
+
+private:
+ // Data members
+ int (*m_cpp_main_func)( int argc, char* argv[] );
+ int m_argc;
+ char** m_argv;
+};
+
+} // local namespace
+
+// ************************************************************************** //
+// ************** prg_exec_monitor_main ************** //
+// ************************************************************************** //
+
+namespace ndnboost {
+
+int BOOST_TEST_DECL
+prg_exec_monitor_main( int (*cpp_main)( int argc, char* argv[] ), int argc, char* argv[] )
+{
+ int result = 0;
+
+ try {
+ ndnboost::unit_test::const_string p( std::getenv( "BOOST_TEST_CATCH_SYSTEM_ERRORS" ) );
+ ::ndnboost::execution_monitor ex_mon;
+
+ ex_mon.p_catch_system_errors.value = p != "no";
+
+ result = ex_mon.execute(
+ ::ndnboost::unit_test::callback0<int>( cpp_main_caller( cpp_main, argc, argv ) ) );
+
+ if( result == 0 )
+ result = ::ndnboost::exit_success;
+ else if( result != ::ndnboost::exit_success ) {
+ std::cout << "\n**** error return code: " << result << std::endl;
+ result = ::ndnboost::exit_failure;
+ }
+ }
+ catch( ::ndnboost::execution_exception const& exex ) {
+ std::cout << "\n**** exception(" << exex.code() << "): " << exex.what() << std::endl;
+ result = ::ndnboost::exit_exception_failure;
+ }
+ catch( ::ndnboost::system_error const& ex ) {
+ std::cout << "\n**** failed to initialize execution monitor."
+ << "\n**** expression at fault: " << ex.p_failed_exp
+ << "\n**** error(" << ex.p_errno << "): " << std::strerror( ex.p_errno ) << std::endl;
+ result = ::ndnboost::exit_exception_failure;
+ }
+
+ if( result != ::ndnboost::exit_success ) {
+ std::cerr << "******** errors detected; see standard output for details ********" << std::endl;
+ }
+ else {
+ // Some prefer a confirming message when all is well, while others don't
+ // like the clutter. Use an environment variable to avoid command
+ // line argument modifications; for use in production programs
+ // that's a no-no in some organizations.
+ ::ndnboost::unit_test::const_string p( std::getenv( "BOOST_PRG_MON_CONFIRM" ) );
+ if( p != "no" ) {
+ std::cerr << std::flush << "no errors detected" << std::endl;
+ }
+ }
+
+ return result;
+}
+
+} // namespace ndnboost
+
+#if !defined(BOOST_TEST_DYN_LINK) && !defined(BOOST_TEST_NO_MAIN)
+
+// ************************************************************************** //
+// ************** main function for tests using lib ************** //
+// ************************************************************************** //
+
+int cpp_main( int argc, char* argv[] ); // prototype for user's cpp_main()
+
+int BOOST_TEST_CALL_DECL
+main( int argc, char* argv[] )
+{
+ return ::ndnboost::prg_exec_monitor_main( &cpp_main, argc, argv );
+}
+
+//____________________________________________________________________________//
+
+#endif // !BOOST_TEST_DYN_LINK && !BOOST_TEST_NO_MAIN
+
+//____________________________________________________________________________//
+
+#include <ndnboost/test/detail/enable_warnings.hpp>
+
+#endif // BOOST_TEST_CPP_MAIN_IPP_012205GER
diff --git a/ndnboost/test/impl/debug.ipp b/ndnboost/test/impl/debug.ipp
new file mode 100644
index 0000000..bf23f2e
--- /dev/null
+++ b/ndnboost/test/impl/debug.ipp
@@ -0,0 +1,970 @@
+// (C) Copyright Gennadiy Rozental 2006-2008.
+// Use, modification, and distribution are subject to the
+// Boost Software License, Version 1.0. (See accompanying file
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// See http://www.boost.org/libs/test for the library home page.
+//
+// File : $RCSfile$
+//
+// Version : $Revision: 57992 $
+//
+// Description : debug interfaces implementation
+// ***************************************************************************
+
+#ifndef BOOST_TEST_DEBUG_API_IPP_112006GER
+#define BOOST_TEST_DEBUG_API_IPP_112006GER
+
+// Boost.Test
+#include <ndnboost/test/detail/config.hpp>
+#include <ndnboost/test/detail/workaround.hpp>
+#include <ndnboost/test/detail/global_typedef.hpp>
+
+#include <ndnboost/test/debug.hpp>
+#include <ndnboost/test/debug_config.hpp>
+
+// Implementation on Windows
+#if defined(_WIN32) && !defined(UNDER_CE) && !defined(BOOST_DISABLE_WIN32) // ******* WIN32
+
+# define BOOST_WIN32_BASED_DEBUG
+
+// SYSTEM API
+# include <windows.h>
+# include <winreg.h>
+# include <cstdio>
+# include <cstring>
+
+# if !defined(NDEBUG) && defined(_MSC_VER)
+# define BOOST_MS_CRT_BASED_DEBUG
+# include <crtdbg.h>
+# endif
+
+
+# if BOOST_WORKAROUND( BOOST_MSVC, <1300)
+# define snprintf _snprintf
+# endif
+
+# ifdef BOOST_NO_STDC_NAMESPACE
+namespace std { using ::memset; using ::sprintf; }
+# endif
+
+#elif defined(unix) || defined(__unix) // ********************* UNIX
+
+# define BOOST_UNIX_BASED_DEBUG
+
+// Boost.Test
+#include <ndnboost/test/utils/class_properties.hpp>
+#include <ndnboost/test/utils/algorithm.hpp>
+
+// STL
+#include <cstring> // std::memcpy
+#include <map>
+#include <cstdio>
+#include <stdarg.h> // !! ?? cstdarg
+
+// SYSTEM API
+# include <unistd.h>
+# include <signal.h>
+# include <fcntl.h>
+
+# include <sys/types.h>
+# include <sys/stat.h>
+# include <sys/wait.h>
+# include <sys/time.h>
+# include <stdio.h>
+# include <stdlib.h>
+
+# if defined(sun) || defined(__sun)
+
+# define BOOST_SUN_BASED_DEBUG
+
+# ifndef BOOST_TEST_DBG_LIST
+# define BOOST_TEST_DBG_LIST dbx;gdb
+# endif
+
+# define BOOST_TEST_CNL_DBG dbx
+# define BOOST_TEST_GUI_DBG dbx-ddd
+
+# include <procfs.h>
+
+# elif defined(linux) || defined(__linux)
+
+# define BOOST_LINUX_BASED_DEBUG
+
+# include <sys/ptrace.h>
+
+# ifndef BOOST_TEST_STAT_LINE_MAX
+# define BOOST_TEST_STAT_LINE_MAX 500
+# endif
+
+# ifndef BOOST_TEST_DBG_LIST
+# define BOOST_TEST_DBG_LIST gdb
+# endif
+
+# define BOOST_TEST_CNL_DBG gdb
+# define BOOST_TEST_GUI_DBG gdb-xterm
+
+# endif
+
+#endif
+
+#include <ndnboost/test/detail/suppress_warnings.hpp>
+
+//____________________________________________________________________________//
+
+namespace ndnboost {
+
+namespace debug {
+
+using unit_test::const_string;
+
+// ************************************************************************** //
+// ************** debug::info_t ************** //
+// ************************************************************************** //
+
+namespace {
+
+#if defined(BOOST_WIN32_BASED_DEBUG) // *********************** WIN32
+
+template<typename T>
+inline void
+dyn_symbol( T& res, char const* module_name, char const* symbol_name )
+{
+ HMODULE m = ::GetModuleHandleA( module_name );
+
+ if( !m )
+ m = ::LoadLibraryA( module_name );
+
+ res = reinterpret_cast<T>( ::GetProcAddress( m, symbol_name ) );
+}
+
+//____________________________________________________________________________//
+
+static struct info_t {
+ typedef BOOL (WINAPI* IsDebuggerPresentT)();
+ typedef LONG (WINAPI* RegQueryValueExT)( HKEY, char const* /*LPTSTR*/, LPDWORD, LPDWORD, LPBYTE, LPDWORD );
+ typedef LONG (WINAPI* RegOpenKeyT)( HKEY, char const* /*LPCTSTR*/, PHKEY );
+ typedef LONG (WINAPI* RegCloseKeyT)( HKEY );
+
+ info_t();
+
+ IsDebuggerPresentT m_is_debugger_present;
+ RegOpenKeyT m_reg_open_key;
+ RegQueryValueExT m_reg_query_value;
+ RegCloseKeyT m_reg_close_key;
+
+} s_info;
+
+//____________________________________________________________________________//
+
+info_t::info_t()
+{
+ dyn_symbol( m_is_debugger_present, "kernel32", "IsDebuggerPresent" );
+ dyn_symbol( m_reg_open_key, "advapi32", "RegOpenKeyA" );
+ dyn_symbol( m_reg_query_value, "advapi32", "RegQueryValueExA" );
+ dyn_symbol( m_reg_close_key, "advapi32", "RegCloseKey" );
+}
+
+//____________________________________________________________________________//
+
+#elif defined(BOOST_UNIX_BASED_DEBUG)
+
+// ************************************************************************** //
+// ************** fd_holder ************** //
+// ************************************************************************** //
+
+struct fd_holder {
+ explicit fd_holder( int fd ) : m_fd( fd ) {}
+ ~fd_holder()
+ {
+ if( m_fd != -1 )
+ ::close( m_fd );
+ }
+
+ operator int() { return m_fd; }
+
+private:
+ // Data members
+ int m_fd;
+};
+
+
+// ************************************************************************** //
+// ************** process_info ************** //
+// ************************************************************************** //
+
+struct process_info {
+ // Constructor
+ explicit process_info( int pid );
+
+ // access methods
+ int parent_pid() const { return m_parent_pid; }
+ const_string binary_name() const { return m_binary_name; }
+ const_string binary_path() const { return m_binary_path; }
+
+private:
+ // Data members
+ int m_parent_pid;
+ const_string m_binary_name;
+ const_string m_binary_path;
+
+#if defined(BOOST_SUN_BASED_DEBUG)
+ struct psinfo m_psi;
+#elif defined(BOOST_LINUX_BASED_DEBUG)
+ char m_stat_line[BOOST_TEST_STAT_LINE_MAX+1];
+#endif
+ char m_binary_path_buff[500+1]; // !! ??
+};
+
+//____________________________________________________________________________//
+
+process_info::process_info( int pid )
+: m_parent_pid( 0 )
+{
+#if defined(BOOST_SUN_BASED_DEBUG)
+ char fname_buff[30];
+
+ ::snprintf( fname_buff, sizeof(fname_buff), "/proc/%d/psinfo", pid );
+
+ fd_holder psinfo_fd( ::open( fname_buff, O_RDONLY ) );
+
+ if( psinfo_fd == -1 )
+ return;
+
+ if( ::read( psinfo_fd, &m_psi, sizeof(m_psi) ) == -1 )
+ return;
+
+ m_parent_pid = m_psi.pr_ppid;
+
+ m_binary_name.assign( m_psi.pr_fname );
+
+ //-------------------------- //
+
+ ::snprintf( fname_buff, sizeof(fname_buff), "/proc/%d/as", pid );
+
+ fd_holder as_fd( ::open( fname_buff, O_RDONLY ) );
+ uintptr_t binary_name_pos;
+
+ // !! ?? could we avoid reading whole m_binary_path_buff?
+ if( as_fd == -1 ||
+ ::lseek( as_fd, m_psi.pr_argv, SEEK_SET ) == -1 ||
+ ::read ( as_fd, &binary_name_pos, sizeof(binary_name_pos) ) == -1 ||
+ ::lseek( as_fd, binary_name_pos, SEEK_SET ) == -1 ||
+ ::read ( as_fd, m_binary_path_buff, sizeof(m_binary_path_buff) ) == -1 )
+ return;
+
+ m_binary_path.assign( m_binary_path_buff );
+
+#elif defined(BOOST_LINUX_BASED_DEBUG)
+ char fname_buff[30];
+
+ ::snprintf( fname_buff, sizeof(fname_buff), "/proc/%d/stat", pid );
+
+ fd_holder psinfo_fd( ::open( fname_buff, O_RDONLY ) );
+
+ if( psinfo_fd == -1 )
+ return;
+
+ ssize_t num_read = ::read( psinfo_fd, m_stat_line, sizeof(m_stat_line)-1 );
+ if( num_read == -1 )
+ return;
+
+ m_stat_line[num_read] = 0;
+
+ char const* name_beg = m_stat_line;
+ while( *name_beg && *name_beg != '(' )
+ ++name_beg;
+
+ char const* name_end = name_beg+1;
+ while( *name_end && *name_end != ')' )
+ ++name_end;
+
+ std::sscanf( name_end+1, "%*s%d", &m_parent_pid );
+
+ m_binary_name.assign( name_beg+1, name_end );
+
+ ::snprintf( fname_buff, sizeof(fname_buff), "/proc/%d/exe", pid );
+ num_read = ::readlink( fname_buff, m_binary_path_buff, sizeof(m_binary_path_buff)-1 );
+
+ if( num_read == -1 )
+ return;
+
+ m_binary_path_buff[num_read] = 0;
+ m_binary_path.assign( m_binary_path_buff, num_read );
+#endif
+}
+
+//____________________________________________________________________________//
+
+// ************************************************************************** //
+// ************** prepare_window_title ************** //
+// ************************************************************************** //
+
+static char*
+prepare_window_title( dbg_startup_info const& dsi )
+{
+ typedef unit_test::const_string str_t;
+
+ static char title_str[50];
+
+ str_t path_sep( "\\/" );
+
+ str_t::iterator it = unit_test::find_last_of( dsi.binary_path.begin(), dsi.binary_path.end(),
+ path_sep.begin(), path_sep.end() );
+
+ if( it == dsi.binary_path.end() )
+ it = dsi.binary_path.begin();
+ else
+ ++it;
+
+ ::snprintf( title_str, sizeof(title_str), "%*s %ld", (int)(dsi.binary_path.end()-it), it, dsi.pid );
+
+ return title_str;
+}
+
+//____________________________________________________________________________//
+
+// ************************************************************************** //
+// ************** save_execlp ************** //
+// ************************************************************************** //
+
+typedef unit_test::basic_cstring<char> mbuffer;
+
+inline char*
+copy_arg( mbuffer& dest, const_string arg )
+{
+ if( dest.size() < arg.size()+1 )
+ return 0;
+
+ char* res = dest.begin();
+
+ std::memcpy( res, arg.begin(), arg.size()+1 );
+
+ dest.trim_left( arg.size()+1 );
+
+ return res;
+}
+
+//____________________________________________________________________________//
+
+bool
+safe_execlp( char const* file, ... )
+{
+ static char* argv_buff[200];
+
+ va_list args;
+ char const* arg;
+
+ // first calculate actual number of arguments
+ int num_args = 2; // file name and 0 at least
+
+ va_start( args, file );
+ while( !!(arg = va_arg( args, char const* )) )
+ num_args++;
+ va_end( args );
+
+ // reserve space for the argument pointers array
+ char** argv_it = argv_buff;
+ mbuffer work_buff( reinterpret_cast<char*>(argv_buff), sizeof(argv_buff) );
+ work_buff.trim_left( num_args * sizeof(char*) );
+
+ // copy all the argument values into local storage
+ if( !(*argv_it++ = copy_arg( work_buff, file )) )
+ return false;
+
+ printf( "!! %s\n", file );
+
+ va_start( args, file );
+ while( !!(arg = va_arg( args, char const* )) ) {
+ printf( "!! %s\n", arg );
+ if( !(*argv_it++ = copy_arg( work_buff, arg )) )
+ return false;
+ }
+ va_end( args );
+
+ *argv_it = 0;
+
+ return ::execvp( file, argv_buff ) != -1;
+}
+
+//____________________________________________________________________________//
+
+// ************************************************************************** //
+// ************** start_debugger_in_emacs ************** //
+// ************************************************************************** //
+
+static void
+start_debugger_in_emacs( dbg_startup_info const& dsi, char const* emacs_name, char const* dbg_command )
+{
+ char const* title = prepare_window_title( dsi );
+
+ if( !title )
+ return;
+
+ dsi.display.is_empty()
+ ? safe_execlp( emacs_name, "-title", title, "--eval", dbg_command, 0 )
+ : safe_execlp( emacs_name, "-title", title, "-display", dsi.display.begin(), "--eval", dbg_command, 0 );
+}
+
+//____________________________________________________________________________//
+
+// ************************************************************************** //
+// ************** gdb starters ************** //
+// ************************************************************************** //
+
+static char const*
+prepare_gdb_cmnd_file( dbg_startup_info const& dsi )
+{
+ // prepare pid value
+ char pid_buff[16];
+ ::snprintf( pid_buff, sizeof(pid_buff), "%ld", dsi.pid );
+ unit_test::const_string pid_str( pid_buff );
+
+ static char cmd_file_name[] = "/tmp/btl_gdb_cmd_XXXXXX"; // !! ??
+
+ // prepare commands
+ fd_holder cmd_fd( ::mkstemp( cmd_file_name ) );
+
+ if( cmd_fd == -1 )
+ return 0;
+
+#define WRITE_STR( str ) if( ::write( cmd_fd, str.begin(), str.size() ) == -1 ) return 0;
+#define WRITE_CSTR( str ) if( ::write( cmd_fd, str, sizeof( str )-1 ) == -1 ) return 0;
+
+ WRITE_CSTR( "file " );
+ WRITE_STR( dsi.binary_path );
+ WRITE_CSTR( "\nattach " );
+ WRITE_STR( pid_str );
+ WRITE_CSTR( "\nshell unlink " );
+ WRITE_STR( dsi.init_done_lock );
+ WRITE_CSTR( "\ncont" );
+ if( dsi.break_or_continue )
+ WRITE_CSTR( "\nup 4" );
+
+ WRITE_CSTR( "\necho \\n" ); // !! ??
+ WRITE_CSTR( "\nlist -" );
+ WRITE_CSTR( "\nlist" );
+ WRITE_CSTR( "\nshell unlink " );
+ WRITE_CSTR( cmd_file_name );
+
+ return cmd_file_name;
+}
+
+//____________________________________________________________________________//
+
+static void
+start_gdb_in_console( dbg_startup_info const& dsi )
+{
+ char const* cmnd_file_name = prepare_gdb_cmnd_file( dsi );
+
+ if( !cmnd_file_name )
+ return;
+
+ safe_execlp( "gdb", "-q", "-x", cmnd_file_name, 0 );
+}
+
+//____________________________________________________________________________//
+
+static void
+start_gdb_in_xterm( dbg_startup_info const& dsi )
+{
+ char const* title = prepare_window_title( dsi );
+ char const* cmnd_file_name = prepare_gdb_cmnd_file( dsi );
+
+ if( !title || !cmnd_file_name )
+ return;
+
+ safe_execlp( "xterm", "-T", title, "-display", dsi.display.begin(),
+ "-bg", "black", "-fg", "white", "-geometry", "88x30+10+10", "-fn", "9x15", "-e",
+ "gdb", "-q", "-x", cmnd_file_name, 0 );
+}
+
+//____________________________________________________________________________//
+
+static void
+start_gdb_in_emacs( dbg_startup_info const& dsi )
+{
+ char const* cmnd_file_name = prepare_gdb_cmnd_file( dsi );
+ if( !cmnd_file_name )
+ return;
+
+ char dbg_cmd_buff[500]; // !! ??
+ ::snprintf( dbg_cmd_buff, sizeof(dbg_cmd_buff), "(progn (gdb \"gdb -q -x %s\"))", cmnd_file_name );
+
+ start_debugger_in_emacs( dsi, "emacs", dbg_cmd_buff );
+}
+
+//____________________________________________________________________________//
+
+static void
+start_gdb_in_xemacs( dbg_startup_info const& )
+{
+ // !! ??
+}
+
+//____________________________________________________________________________//
+
+// ************************************************************************** //
+// ************** dbx starters ************** //
+// ************************************************************************** //
+
+static char const*
+prepare_dbx_cmd_line( dbg_startup_info const& dsi, bool list_source = true )
+{
+ static char cmd_line_buff[500]; // !! ??
+
+ ::snprintf( cmd_line_buff, sizeof(cmd_line_buff), "unlink %s;cont;%s%s",
+ dsi.init_done_lock.begin(),
+ dsi.break_or_continue ? "up 2;": "",
+ list_source ? "echo \" \";list -w3;" : "" );
+
+ return cmd_line_buff;
+}
+
+//____________________________________________________________________________//
+
+static void
+start_dbx_in_console( dbg_startup_info const& dsi )
+{
+ char pid_buff[16];
+ ::snprintf( pid_buff, sizeof(pid_buff), "%ld", dsi.pid );
+
+ safe_execlp( "dbx", "-q", "-c", prepare_dbx_cmd_line( dsi ), dsi.binary_path.begin(), pid_buff, 0 );
+}
+
+//____________________________________________________________________________//
+
+static void
+start_dbx_in_xterm( dbg_startup_info const& dsi )
+{
+ char const* title = prepare_window_title( dsi );
+ if( !title )
+ return;
+
+ char pid_buff[16]; // !! ??
+ ::snprintf( pid_buff, sizeof(pid_buff), "%ld", dsi.pid );
+
+ safe_execlp( "xterm", "-T", title, "-display", dsi.display.begin(),
+ "-bg", "black", "-fg", "white", "-geometry", "88x30+10+10", "-fn", "9x15", "-e",
+ "dbx", "-q", "-c", prepare_dbx_cmd_line( dsi ), dsi.binary_path.begin(), pid_buff, 0 );
+}
+
+//____________________________________________________________________________//
+
+static void
+start_dbx_in_emacs( dbg_startup_info const& /*dsi*/ )
+{
+// char dbg_cmd_buff[500]; // !! ??
+//
+// ::snprintf( dbg_cmd_buff, sizeof(dbg_cmd_buff), "(progn (dbx \"dbx -q -c cont %s %ld\"))", dsi.binary_path.begin(), dsi.pid );
+
+// start_debugger_in_emacs( dsi, "emacs", dbg_cmd_buff );
+}
+
+//____________________________________________________________________________//
+
+static void
+start_dbx_in_xemacs( dbg_startup_info const& )
+{
+ // !! ??
+}
+
+//____________________________________________________________________________//
+
+static void
+start_dbx_in_ddd( dbg_startup_info const& dsi )
+{
+ char const* title = prepare_window_title( dsi );
+ if( !title )
+ return;
+
+ char pid_buff[16]; // !! ??
+ ::snprintf( pid_buff, sizeof(pid_buff), "%ld", dsi.pid );
+
+ safe_execlp( "ddd", "-display", dsi.display.begin(),
+ "--dbx", "-q", "-c", prepare_dbx_cmd_line( dsi, false ), dsi.binary_path.begin(), pid_buff, 0 );
+}
+
+//____________________________________________________________________________//
+
+// ************************************************************************** //
+// ************** debug::info_t ************** //
+// ************************************************************************** //
+
+static struct info_t {
+ // Constructor
+ info_t();
+
+ // Public properties
+ unit_test::readwrite_property<std::string> p_dbg;
+
+ // Data members
+ std::map<std::string,dbg_starter> m_dbg_starter_reg;
+} s_info;
+
+//____________________________________________________________________________//
+
+info_t::info_t()
+{
+ p_dbg.value = ::getenv( "DISPLAY" )
+ ? std::string( BOOST_STRINGIZE( BOOST_TEST_GUI_DBG ) )
+ : std::string( BOOST_STRINGIZE( BOOST_TEST_CNL_DBG ) );
+
+ m_dbg_starter_reg[std::string("gdb")] = &start_gdb_in_console;
+ m_dbg_starter_reg[std::string("gdb-emacs")] = &start_gdb_in_emacs;
+ m_dbg_starter_reg[std::string("gdb-xterm")] = &start_gdb_in_xterm;
+ m_dbg_starter_reg[std::string("gdb-xemacs")] = &start_gdb_in_xemacs;
+
+ m_dbg_starter_reg[std::string("dbx")] = &start_dbx_in_console;
+ m_dbg_starter_reg[std::string("dbx-emacs")] = &start_dbx_in_emacs;
+ m_dbg_starter_reg[std::string("dbx-xterm")] = &start_dbx_in_xterm;
+ m_dbg_starter_reg[std::string("dbx-xemacs")] = &start_dbx_in_xemacs;
+ m_dbg_starter_reg[std::string("dbx-ddd")] = &start_dbx_in_ddd;
+}
+
+//____________________________________________________________________________//
+
+#endif
+
+} // local namespace
+
+// ************************************************************************** //
+// ************** check if program is running under debugger ************** //
+// ************************************************************************** //
+
+bool
+under_debugger()
+{
+#if defined(BOOST_WIN32_BASED_DEBUG) // *********************** WIN32
+
+ return !!s_info.m_is_debugger_present && s_info.m_is_debugger_present();
+
+#elif defined(BOOST_UNIX_BASED_DEBUG) // ********************** UNIX
+
+ // !! ?? could/should we cache the result somehow?
+ const_string dbg_list = BOOST_TEST_STRINGIZE( BOOST_TEST_DBG_LIST );
+
+ pid_t pid = ::getpid();
+
+ while( pid != 0 ) {
+ process_info pi( pid );
+
+ // !! ?? should we use tokenizer here instead?
+ if( dbg_list.find( pi.binary_name() ) != const_string::npos )
+ return true;
+
+ pid = (pi.parent_pid() == pid ? 0 : pi.parent_pid());
+ }
+
+ return false;
+
+#else // ****************************************************** default
+
+ return false;
+
+#endif
+}
+
+//____________________________________________________________________________//
+
+// ************************************************************************** //
+// ************** cause program to break execution ************** //
+// ************** in debugger at call point ************** //
+// ************************************************************************** //
+
+void
+debugger_break()
+{
+ // !! ?? auto-start debugger?
+
+#if defined(BOOST_WIN32_BASED_DEBUG) // *********************** WIN32
+
+#if BOOST_WORKAROUND(BOOST_MSVC, >= 1300) || \
+ BOOST_WORKAROUND(__GNUC__, >= 3) && !defined(__MINGW32__) || \
+ defined(__INTEL_COMPILER)
+# define BOOST_DEBUG_BREAK __debugbreak
+#else
+# define BOOST_DEBUG_BREAK DebugBreak
+#endif
+
+#ifndef __MINGW32__
+ if( !under_debugger() ) {
+ __try {
+ __try {
+ BOOST_DEBUG_BREAK();
+ }
+ __except( UnhandledExceptionFilter(GetExceptionInformation()) )
+ {
+ // User opted to ignore the breakpoint
+ return;
+ }
+ }
+ __except (EXCEPTION_EXECUTE_HANDLER)
+ {
+ // If we got here, the user has pushed Debug. Debugger is already attached to our process and we
+ // continue to let the another BOOST_DEBUG_BREAK to be called.
+ }
+ }
+#endif
+
+ BOOST_DEBUG_BREAK();
+
+#elif defined(BOOST_UNIX_BASED_DEBUG) // ********************** UNIX
+
+ ::kill( ::getpid(), SIGTRAP );
+
+#else // ****************************************************** default
+
+#endif
+}
+
+//____________________________________________________________________________//
+
+// ************************************************************************** //
+// ************** console debugger setup ************** //
+// ************************************************************************** //
+
+#if defined(BOOST_UNIX_BASED_DEBUG) // ************************ UNIX
+
+std::string
+set_debugger( unit_test::const_string dbg_id, dbg_starter s )
+{
+ std::string old = s_info.p_dbg;
+
+ assign_op( s_info.p_dbg.value, dbg_id, 0 );
+
+ if( !!s )
+ s_info.m_dbg_starter_reg[s_info.p_dbg] = s;
+
+ return old;
+}
+
+#else // ***************************************************** default
+
+std::string
+set_debugger( unit_test::const_string, dbg_starter )
+{
+ return std::string();
+}
+
+#endif
+
+//____________________________________________________________________________//
+
+// ************************************************************************** //
+// ************** attach debugger to the current process ************** //
+// ************************************************************************** //
+
+bool
+attach_debugger( bool break_or_continue )
+{
+ if( under_debugger() )
+ return false;
+
+#if defined(BOOST_WIN32_BASED_DEBUG) // *********************** WIN32
+
+ const int MAX_CMD_LINE = 200;
+
+ // *************************************************** //
+ // Debugger "ready" event
+
+ SECURITY_ATTRIBUTES attr;
+ attr.nLength = sizeof(attr);
+ attr.lpSecurityDescriptor = NULL;
+ attr.bInheritHandle = true;
+
+ // manual resettable, initially non signaled, unnamed event,
+ // that will signal me that debugger initialization is done
+ HANDLE dbg_init_done_ev = ::CreateEvent(
+ &attr, // pointer to security attributes
+ true, // flag for manual-reset event
+ false, // flag for initial state
+ NULL // pointer to event-object name
+ );
+
+ if( !dbg_init_done_ev )
+ return false;
+
+ // *************************************************** //
+ // Debugger command line format
+
+ HKEY reg_key;
+
+ if( !s_info.m_reg_open_key || (*s_info.m_reg_open_key)(
+ HKEY_LOCAL_MACHINE, // handle of open key
+ "Software\\Microsoft\\Windows NT\\CurrentVersion\\AeDebug", // name of subkey to open
+ ®_key ) != ERROR_SUCCESS ) // address of handle of open key
+ return false;
+
+ char format[MAX_CMD_LINE];
+ DWORD format_size = MAX_CMD_LINE;
+ DWORD type = REG_SZ;
+
+ if( !s_info.m_reg_query_value || (*s_info.m_reg_query_value)(
+ reg_key, // handle of open key
+ "Debugger", // name of subkey to query
+ 0, // reserved
+ &type, // value type
+ (LPBYTE)format, // buffer for returned string
+ &format_size ) != ERROR_SUCCESS ) // in: buffer size; out: actual size of returned string
+ return false;
+
+ if( !s_info.m_reg_close_key || (*s_info.m_reg_close_key)( reg_key ) != ERROR_SUCCESS )
+ return false;
+
+ // *************************************************** //
+ // Debugger command line
+
+ char cmd_line[MAX_CMD_LINE];
+ std::sprintf( cmd_line, format, ::GetCurrentProcessId(), dbg_init_done_ev );
+
+ // *************************************************** //
+ // Debugger window parameters
+
+ STARTUPINFOA startup_info;
+ std::memset( &startup_info, 0, sizeof(startup_info) );
+
+ startup_info.cb = sizeof(startup_info);
+ startup_info.dwFlags = STARTF_USESHOWWINDOW;
+ startup_info.wShowWindow = SW_SHOWNORMAL;
+
+ // debugger process s_info
+ PROCESS_INFORMATION debugger_info;
+
+ bool created = !!::CreateProcessA(
+ NULL, // pointer to name of executable module; NULL - use the one in command line
+ cmd_line, // pointer to command line string
+ NULL, // pointer to process security attributes; NULL - debugger's handle can't be inherited
+ NULL, // pointer to thread security attributes; NULL - debugger's handle can't be inherited
+ true, // debugger inherit opened handles
+ 0, // priority flags; 0 - normal priority
+ NULL, // pointer to new environment block; NULL - use this process environment
+ NULL, // pointer to current directory name; NULL - use this process correct directory
+ &startup_info, // pointer to STARTUPINFO that specifies main window appearance
+ &debugger_info // pointer to PROCESS_INFORMATION that will contain the new process identification
+ );
+
+ if( created )
+ ::WaitForSingleObject( dbg_init_done_ev, INFINITE );
+
+ ::CloseHandle( dbg_init_done_ev );
+
+ if( !created )
+ return false;
+
+ if( break_or_continue )
+ debugger_break();
+
+ return true;
+
+#elif defined(BOOST_UNIX_BASED_DEBUG) // ********************** UNIX
+
+ char init_done_lock_fn[] = "/tmp/btl_dbg_init_done_XXXXXX";
+ fd_holder init_done_lock_fd( ::mkstemp( init_done_lock_fn ) );
+
+ if( init_done_lock_fd == -1 )
+ return false;
+
+ pid_t child_pid = fork();
+
+ if( child_pid == -1 )
+ return false;
+
+ if( child_pid != 0 ) { // parent process - here we will start the debugger
+ dbg_startup_info dsi;
+
+ process_info pi( child_pid );
+ if( pi.binary_path().is_empty() )
+ ::exit( -1 );
+
+ dsi.pid = child_pid;
+ dsi.break_or_continue = break_or_continue;
+ dsi.binary_path = pi.binary_path();
+ dsi.display = ::getenv( "DISPLAY" );
+ dsi.init_done_lock = init_done_lock_fn;
+
+ dbg_starter starter = s_info.m_dbg_starter_reg[s_info.p_dbg];
+ if( !!starter )
+ starter( dsi );
+
+ ::perror( "Boost.Test execution monitor failed to start a debugger:" );
+
+ ::exit( -1 );
+ }
+
+ // child process - here we will continue our test module execution ; // !! ?? should it be vice versa
+
+ while( ::access( init_done_lock_fn, F_OK ) == 0 ) {
+ struct timeval to = { 0, 100 };
+
+ ::select( 0, 0, 0, 0, &to );
+ }
+
+// char dummy;
+// while( ::read( init_done_lock_fd, &dummy, sizeof(char) ) == 0 );
+
+ if( break_or_continue )
+ debugger_break();
+
+ return true;
+
+#else // ****************************************************** default
+
+ return false;
+
+#endif
+}
+
+//____________________________________________________________________________//
+
+// ************************************************************************** //
+// ************** switch on/off detect memory leaks feature ************** //
+// ************************************************************************** //
+
+void
+detect_memory_leaks( bool on_off )
+{
+ unit_test::ut_detail::ignore_unused_variable_warning( on_off );
+
+#ifdef BOOST_MS_CRT_BASED_DEBUG
+ int flags = _CrtSetDbgFlag( _CRTDBG_REPORT_FLAG );
+
+ if( !on_off )
+ flags &= ~_CRTDBG_LEAK_CHECK_DF;
+ else {
+ flags |= _CRTDBG_LEAK_CHECK_DF;
+ _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE);
+ _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDOUT);
+ }
+
+ _CrtSetDbgFlag ( flags );
+#endif // BOOST_MS_CRT_BASED_DEBUG
+}
+
+//____________________________________________________________________________//
+
+// ************************************************************************** //
+// ************** cause program to break execution in ************** //
+// ************** debugger at specific allocation point ************** //
+// ************************************************************************** //
+
+void
+break_memory_alloc( long mem_alloc_order_num )
+{
+ unit_test::ut_detail::ignore_unused_variable_warning( mem_alloc_order_num );
+
+#ifdef BOOST_MS_CRT_BASED_DEBUG
+ _CrtSetBreakAlloc( mem_alloc_order_num );
+#endif // BOOST_MS_CRT_BASED_DEBUG
+}
+
+} // namespace debug
+
+} // namespace ndnboost
+
+//____________________________________________________________________________//
+
+#include <ndnboost/test/detail/enable_warnings.hpp>
+
+#endif // BOOST_TEST_DEBUG_API_IPP_112006GER
+
diff --git a/ndnboost/test/impl/exception_safety.ipp b/ndnboost/test/impl/exception_safety.ipp
new file mode 100644
index 0000000..c3680a9
--- /dev/null
+++ b/ndnboost/test/impl/exception_safety.ipp
@@ -0,0 +1,537 @@
+// (C) Copyright Gennadiy Rozental 2005-2008.
+// Use, modification, and distribution are subject to the
+// Boost Software License, Version 1.0. (See accompanying file
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// See http://www.boost.org/libs/test for the library home page.
+//
+// File : $RCSfile$
+//
+// Version : $Revision: 54633 $
+//
+// Description : Facilities to perform exception safety tests
+// ***************************************************************************
+
+#ifndef BOOST_TEST_EXECUTION_SAFETY_IPP_112005GER
+#define BOOST_TEST_EXECUTION_SAFETY_IPP_112005GER
+
+// Boost.Test
+#include <ndnboost/test/detail/config.hpp>
+
+#if BOOST_TEST_SUPPORT_INTERACTION_TESTING
+
+#include <ndnboost/test/detail/global_typedef.hpp>
+#include <ndnboost/test/detail/unit_test_parameters.hpp>
+
+#include <ndnboost/test/utils/callback.hpp>
+#include <ndnboost/test/utils/wrap_stringstream.hpp>
+#include <ndnboost/test/utils/iterator/token_iterator.hpp>
+
+#include <ndnboost/test/interaction_based.hpp>
+#include <ndnboost/test/test_tools.hpp>
+#include <ndnboost/test/unit_test_log.hpp>
+#include <ndnboost/test/framework.hpp>
+#include <ndnboost/test/test_observer.hpp>
+#include <ndnboost/test/debug.hpp>
+
+#include <ndnboost/test/detail/suppress_warnings.hpp>
+
+// Boost
+#include <ndnboost/lexical_cast.hpp>
+
+// STL
+#include <vector>
+#include <cstdlib>
+#include <map>
+#include <iomanip>
+#include <cctype>
+#include <ndnboost/limits.hpp>
+
+//____________________________________________________________________________//
+
+namespace ndnboost {
+
+using namespace ::ndnboost::unit_test;
+
+namespace itest {
+
+// ************************************************************************** //
+// ************** execution_path_point ************** //
+// ************************************************************************** //
+
+enum exec_path_point_type { EPP_SCOPE, EPP_EXCEPT, EPP_DECISION, EPP_ALLOC };
+
+struct execution_path_point {
+ execution_path_point( exec_path_point_type t, const_string file, std::size_t line_num )
+ : m_type( t )
+ , m_file_name( file )
+ , m_line_num( line_num )
+ {}
+
+ exec_path_point_type m_type;
+ const_string m_file_name;
+ std::size_t m_line_num;
+
+ // Execution path point specific
+ struct decision_data {
+ bool value;
+ unsigned forced_exception_point;
+ };
+ struct scope_data {
+ unsigned size;
+ char const* name;
+ };
+ struct except_data {
+ char const* description;
+ };
+ struct alloc_data {
+ void* ptr;
+ std::size_t size;
+ };
+
+ union {
+ struct decision_data m_decision;
+ struct scope_data m_scope;
+ struct except_data m_except;
+ struct alloc_data m_alloc;
+ };
+};
+
+// ************************************************************************** //
+// ************** exception safety test implementation ************** //
+// ************************************************************************** //
+
+struct exception_safety_tester : itest::manager, test_observer {
+ // helpers types
+ struct unique_exception {};
+
+ // Constructor
+ explicit exception_safety_tester( const_string test_name );
+ ~exception_safety_tester();
+
+ // check last run and prepare for next
+ bool next_execution_path();
+
+ // memory tracking
+
+ // manager interface implementation
+ virtual void exception_point( const_string file, std::size_t line_num, const_string description );
+ virtual bool decision_point( const_string file, std::size_t line_num );
+ virtual unsigned enter_scope( const_string file, std::size_t line_num, const_string scope_name );
+ virtual void leave_scope( unsigned enter_scope_point );
+ virtual void allocated( const_string file, std::size_t line_num, void* p, std::size_t s );
+ virtual void freed( void* p );
+
+ // test observer interface
+ virtual void assertion_result( bool passed );
+ virtual int priority() { return (std::numeric_limits<int>::max)(); } // we want this observer to run the last
+
+private:
+ void failure_point();
+ void report_error();
+
+ typedef std::vector<execution_path_point> exec_path;
+ typedef std::map<void*,unsigned> registry;
+
+ // Data members
+ bool m_internal_activity;
+
+ unsigned m_exception_point_counter;
+ unsigned m_forced_exception_point;
+
+ unsigned m_exec_path_point;
+ exec_path m_execution_path;
+
+ unsigned m_exec_path_counter;
+ unsigned m_break_exec_path;
+
+ bool m_invairant_failed;
+ registry m_memory_in_use;
+};
+
+//____________________________________________________________________________//
+
+struct activity_guard {
+ bool& m_v;
+
+ activity_guard( bool& v ) : m_v( v ) { m_v = true; }
+ ~activity_guard() { m_v = false; }
+};
+
+//____________________________________________________________________________//
+
+exception_safety_tester::exception_safety_tester( const_string test_name )
+: m_internal_activity( true )
+, m_exception_point_counter( 0 )
+, m_forced_exception_point( 1 )
+, m_exec_path_point( 0 )
+, m_exec_path_counter( 1 )
+, m_break_exec_path( static_cast<unsigned>(-1) )
+, m_invairant_failed( false )
+{
+ framework::register_observer( *this );
+
+ if( !runtime_config::break_exec_path().is_empty() ) {
+ using namespace unit_test;
+
+ string_token_iterator tit( runtime_config::break_exec_path(),
+ (dropped_delimeters = ":",kept_delimeters = " ") );
+
+ const_string test_to_break = *tit;
+
+ if( test_to_break == test_name ) {
+ ++tit;
+
+ m_break_exec_path = lexical_cast<unsigned>( *tit );
+ }
+ }
+
+ m_internal_activity = false;
+}
+
+//____________________________________________________________________________//
+
+exception_safety_tester::~exception_safety_tester()
+{
+ m_internal_activity = true;
+
+ framework::deregister_observer( *this );
+}
+
+//____________________________________________________________________________//
+
+bool
+exception_safety_tester::next_execution_path()
+{
+ activity_guard ag( m_internal_activity );
+
+ // check memory usage
+ if( m_execution_path.size() > 0 ) {
+ bool errors_detected = m_invairant_failed || (m_memory_in_use.size() != 0);
+ framework::assertion_result( !errors_detected );
+
+ if( errors_detected )
+ report_error();
+
+ m_memory_in_use.clear();
+ }
+
+ m_exec_path_point = 0;
+ m_exception_point_counter = 0;
+ m_invairant_failed = false;
+ ++m_exec_path_counter;
+
+ while( m_execution_path.size() > 0 ) {
+ switch( m_execution_path.back().m_type ) {
+ case EPP_SCOPE:
+ case EPP_ALLOC:
+ m_execution_path.pop_back();
+ break;
+
+ case EPP_DECISION:
+ if( !m_execution_path.back().m_decision.value ) {
+ m_execution_path.pop_back();
+ break;
+ }
+
+ m_execution_path.back().m_decision.value = false;
+ m_forced_exception_point = m_execution_path.back().m_decision.forced_exception_point;
+ return true;
+
+ case EPP_EXCEPT:
+ m_execution_path.pop_back();
+ ++m_forced_exception_point;
+ return true;
+ }
+ }
+
+ BOOST_TEST_MESSAGE( "Total tested " << --m_exec_path_counter << " execution path" );
+
+ return false;
+}
+
+//____________________________________________________________________________//
+
+void
+exception_safety_tester::exception_point( const_string file, std::size_t line_num, const_string description )
+{
+ activity_guard ag( m_internal_activity );
+
+ if( ++m_exception_point_counter == m_forced_exception_point ) {
+ m_execution_path.push_back(
+ execution_path_point( EPP_EXCEPT, file, line_num ) );
+
+ m_execution_path.back().m_except.description = description.begin();
+
+ ++m_exec_path_point;
+
+ failure_point();
+ }
+}
+
+//____________________________________________________________________________//
+
+bool
+exception_safety_tester::decision_point( const_string file, std::size_t line_num )
+{
+ activity_guard ag( m_internal_activity );
+
+ if( m_exec_path_point < m_execution_path.size() ) {
+ BOOST_REQUIRE_MESSAGE( m_execution_path[m_exec_path_point].m_type == EPP_DECISION &&
+ m_execution_path[m_exec_path_point].m_file_name == file &&
+ m_execution_path[m_exec_path_point].m_line_num == line_num,
+ "Function under test exibit non-deterministic behavior" );
+ }
+ else {
+ m_execution_path.push_back(
+ execution_path_point( EPP_DECISION, file, line_num ) );
+
+ m_execution_path.back().m_decision.value = true;
+ m_execution_path.back().m_decision.forced_exception_point = m_forced_exception_point;
+ }
+
+ return m_execution_path[m_exec_path_point++].m_decision.value;
+}
+
+//____________________________________________________________________________//
+
+unsigned
+exception_safety_tester::enter_scope( const_string file, std::size_t line_num, const_string scope_name )
+{
+ activity_guard ag( m_internal_activity );
+
+ if( m_exec_path_point < m_execution_path.size() ) {
+ BOOST_REQUIRE_MESSAGE( m_execution_path[m_exec_path_point].m_type == EPP_SCOPE &&
+ m_execution_path[m_exec_path_point].m_file_name == file &&
+ m_execution_path[m_exec_path_point].m_line_num == line_num,
+ "Function under test exibit non-deterministic behavior" );
+ }
+ else {
+ m_execution_path.push_back(
+ execution_path_point( EPP_SCOPE, file, line_num ) );
+ }
+
+ m_execution_path[m_exec_path_point].m_scope.size = 0;
+ m_execution_path[m_exec_path_point].m_scope.name = scope_name.begin();
+
+ return m_exec_path_point++;
+}
+
+//____________________________________________________________________________//
+
+void
+exception_safety_tester::leave_scope( unsigned enter_scope_point )
+{
+ activity_guard ag( m_internal_activity );
+
+ BOOST_REQUIRE_MESSAGE( m_execution_path[enter_scope_point].m_type == EPP_SCOPE,
+ "Function under test exibit non-deterministic behavior" );
+
+ m_execution_path[enter_scope_point].m_scope.size = m_exec_path_point - enter_scope_point;
+}
+
+//____________________________________________________________________________//
+
+void
+exception_safety_tester::allocated( const_string file, std::size_t line_num, void* p, std::size_t s )
+{
+ if( m_internal_activity )
+ return;
+
+ activity_guard ag( m_internal_activity );
+
+ if( m_exec_path_point < m_execution_path.size() )
+ BOOST_REQUIRE_MESSAGE( m_execution_path[m_exec_path_point].m_type == EPP_ALLOC,
+ "Function under test exibit non-deterministic behavior" );
+ else
+ m_execution_path.push_back(
+ execution_path_point( EPP_ALLOC, file, line_num ) );
+
+ m_execution_path[m_exec_path_point].m_alloc.ptr = p;
+ m_execution_path[m_exec_path_point].m_alloc.size = s;
+
+ m_memory_in_use.insert( std::make_pair( p, m_exec_path_point++ ) );
+}
+
+//____________________________________________________________________________//
+
+void
+exception_safety_tester::freed( void* p )
+{
+ if( m_internal_activity )
+ return;
+
+ activity_guard ag( m_internal_activity );
+
+ registry::iterator it = m_memory_in_use.find( p );
+ if( it != m_memory_in_use.end() ) {
+ m_execution_path[it->second].m_alloc.ptr = 0;
+ m_memory_in_use.erase( it );
+ }
+}
+
+//____________________________________________________________________________//
+
+void
+exception_safety_tester::assertion_result( bool passed )
+{
+ if( !m_internal_activity && !passed ) {
+ m_invairant_failed = true;
+
+ failure_point();
+ }
+}
+
+//____________________________________________________________________________//
+
+void
+exception_safety_tester::failure_point()
+{
+ if( m_exec_path_counter == m_break_exec_path )
+ debug::debugger_break();
+
+ throw unique_exception();
+}
+
+//____________________________________________________________________________//
+
+namespace {
+
+inline void
+format_location( wrap_stringstream& formatter, execution_path_point const& /*p*/, unsigned indent )
+{
+ if( indent )
+ formatter << std::left << std::setw( indent ) << "";
+
+// !! ?? optional if( p.m_file_name )
+// formatter << p.m_file_name << '(' << p.m_line_num << "): ";
+}
+
+//____________________________________________________________________________//
+
+template<typename ExecPathIt>
+inline void
+format_execution_path( wrap_stringstream& formatter, ExecPathIt it, ExecPathIt end, unsigned indent = 0 )
+{
+ while( it != end ) {
+ switch( it->m_type ) {
+ case EPP_SCOPE:
+ format_location( formatter, *it, indent );
+ formatter << "> \"" << it->m_scope.name << "\"\n";
+ format_execution_path( formatter, it+1, it + it->m_scope.size, indent + 2 );
+ format_location( formatter, *it, indent );
+ formatter << "< \"" << it->m_scope.name << "\"\n";
+ it += it->m_scope.size;
+ break;
+
+ case EPP_DECISION:
+ format_location( formatter, *it, indent );
+ formatter << "Decision made as " << std::boolalpha << it->m_decision.value << '\n';
+ ++it;
+ break;
+
+ case EPP_EXCEPT:
+ format_location( formatter, *it, indent );
+ formatter << "Forced failure";
+ if( it->m_except.description )
+ formatter << ": " << it->m_except.description;
+ formatter << "\n";
+ ++it;
+ break;
+
+ case EPP_ALLOC:
+ if( it->m_alloc.ptr ) {
+ format_location( formatter, *it, indent );
+ formatter << "Allocated memory block 0x" << std::uppercase << it->m_alloc.ptr
+ << ", " << it->m_alloc.size << " bytes long: <";
+
+ unsigned i;
+ for( i = 0; i < std::min<std::size_t>( it->m_alloc.size, 8 ); i++ ) {
+ unsigned char c = static_cast<unsigned char*>(it->m_alloc.ptr)[i];
+ if( (std::isprint)( c ) )
+ formatter << c;
+ else
+ formatter << '.';
+ }
+
+ formatter << "> ";
+
+ for( i = 0; i < std::min<std::size_t>( it->m_alloc.size, 8 ); i++ ) {
+ unsigned c = static_cast<unsigned char*>(it->m_alloc.ptr)[i];
+ formatter << std::hex << std::uppercase << c << ' ';
+ }
+
+ formatter << "\n";
+ }
+ ++it;
+ break;
+ }
+ }
+}
+
+//____________________________________________________________________________//
+
+} // local namespace
+
+void
+exception_safety_tester::report_error()
+{
+ activity_guard ag( m_internal_activity );
+
+ unit_test_log << unit_test::log::begin( m_execution_path.back().m_file_name,
+ m_execution_path.back().m_line_num )
+ << log_all_errors;
+
+ wrap_stringstream formatter;
+
+ if( m_invairant_failed )
+ formatter << "Failed invariant";
+
+ if( m_memory_in_use.size() != 0 ) {
+ if( m_invairant_failed )
+ formatter << " and ";
+
+ formatter << static_cast<unsigned int>(m_memory_in_use.size()) << " memory leak";
+ if( m_memory_in_use.size() > 1 )
+ formatter << 's';
+ }
+ formatter << " detected in the execution path " << m_exec_path_counter << ":\n";
+
+ format_execution_path( formatter, m_execution_path.begin(), m_execution_path.end() );
+
+ unit_test_log << const_string( formatter.str() ) << unit_test::log::end();
+}
+
+//____________________________________________________________________________//
+
+// ************************************************************************** //
+// ************** exception safety test ************** //
+// ************************************************************************** //
+
+void BOOST_TEST_DECL
+exception_safety( callback0<> const& F, const_string test_name )
+{
+ exception_safety_tester est( test_name );
+
+ do {
+ try {
+ F();
+ }
+ catch( exception_safety_tester::unique_exception const& ) {}
+
+ } while( est.next_execution_path() );
+}
+
+//____________________________________________________________________________//
+
+} // namespace itest
+
+} // namespace ndnboost
+
+//____________________________________________________________________________//
+
+#include <ndnboost/test/detail/enable_warnings.hpp>
+
+#endif // non-ancient compiler
+
+#endif // BOOST_TEST_EXECUTION_SAFETY_IPP_112005GER
diff --git a/ndnboost/test/impl/execution_monitor.ipp b/ndnboost/test/impl/execution_monitor.ipp
new file mode 100644
index 0000000..5337347
--- /dev/null
+++ b/ndnboost/test/impl/execution_monitor.ipp
@@ -0,0 +1,1367 @@
+// (C) Copyright Gennadiy Rozental 2001-2008.
+// (C) Copyright Beman Dawes and Ullrich Koethe 1995-2001.
+// Use, modification, and distribution are subject to the
+// Boost Software License, Version 1.0. (See accompanying file
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// See http://www.boost.org/libs/test for the library home page.
+//
+// File : $RCSfile$
+//
+// Version : $Revision: 57992 $
+//
+// Description : provides execution monitor implementation for all supported
+// configurations, including Microsoft structured exception based, unix signals
+// based and special workarounds for borland
+//
+// Note that when testing requirements or user wishes preclude use of this
+// file as a separate compilation unit, it may be included as a header file.
+//
+// Header dependencies are deliberately restricted to reduce coupling to other
+// boost libraries.
+// ***************************************************************************
+
+#ifndef BOOST_TEST_EXECUTION_MONITOR_IPP_012205GER
+#define BOOST_TEST_EXECUTION_MONITOR_IPP_012205GER
+
+// Boost.Test
+#include <ndnboost/test/detail/config.hpp>
+#include <ndnboost/test/detail/workaround.hpp>
+#include <ndnboost/test/execution_monitor.hpp>
+#include <ndnboost/test/debug.hpp>
+
+// Boost
+#include <ndnboost/cstdlib.hpp> // for exit codes
+#include <ndnboost/config.hpp> // for workarounds
+#include <ndnboost/exception/get_error_info.hpp> // for get_error_info
+#include <ndnboost/exception/current_exception_cast.hpp> // for current_exception_cast
+
+// STL
+#include <string> // for std::string
+#include <new> // for std::bad_alloc
+#include <typeinfo> // for std::bad_cast, std::bad_typeid
+#include <exception> // for std::exception, std::bad_exception
+#include <stdexcept> // for std exception hierarchy
+#include <cstring> // for C string API
+#include <cassert> // for assert
+#include <cstddef> // for NULL
+#include <cstdio> // for vsnprintf
+#include <cstdarg> // for varargs
+
+#ifdef BOOST_NO_STDC_NAMESPACE
+namespace std { using ::strerror; using ::strlen; using ::strncat; }
+#endif
+
+// to use vsnprintf
+#if defined(__SUNPRO_CC) || defined(__SunOS)
+# include <stdio.h>
+# include <stdarg.h>
+using std::va_list;
+#endif
+
+// to use vsnprintf
+#if defined(__QNXNTO__)
+# include <stdio.h>
+#endif
+
+#if defined(_WIN32) && !defined(BOOST_DISABLE_WIN32) && \
+ (!defined(__COMO__) && !defined(__MWERKS__) && !defined(__GNUC__) || \
+ BOOST_WORKAROUND(__MWERKS__, >= 0x3000))
+
+# define BOOST_SEH_BASED_SIGNAL_HANDLING
+
+# include <windows.h>
+
+# if defined(__MWERKS__) || (defined(_MSC_VER) && !defined(UNDER_CE))
+# include <eh.h>
+# endif
+
+# if defined(__BORLANDC__) && __BORLANDC__ >= 0x560 || defined(__MWERKS__)
+# include <stdint.h>
+# endif
+
+# if defined(__BORLANDC__) && __BORLANDC__ < 0x560
+ typedef unsigned uintptr_t;
+# endif
+
+# if BOOST_WORKAROUND(_MSC_VER, < 1300 ) || defined(UNDER_CE)
+typedef void* uintptr_t;
+# endif
+
+// for the FP control routines
+#include <float.h>
+
+#ifndef EM_INVALID
+#define EM_INVALID _EM_INVALID
+#endif
+
+#ifndef EM_DENORMAL
+#define EM_DENORMAL _EM_DENORMAL
+#endif
+
+#ifndef EM_ZERODIVIDE
+#define EM_ZERODIVIDE _EM_ZERODIVIDE
+#endif
+
+#ifndef EM_OVERFLOW
+#define EM_OVERFLOW _EM_OVERFLOW
+#endif
+
+#ifndef EM_UNDERFLOW
+#define EM_UNDERFLOW _EM_UNDERFLOW
+#endif
+
+#ifndef MCW_EM
+#define MCW_EM _MCW_EM
+#endif
+
+# if !defined(NDEBUG) && defined(_MSC_VER) && !defined(UNDER_CE)
+# include <crtdbg.h>
+# define BOOST_TEST_CRT_HOOK_TYPE _CRT_REPORT_HOOK
+# define BOOST_TEST_CRT_ASSERT _CRT_ASSERT
+# define BOOST_TEST_CRT_ERROR _CRT_ERROR
+# define BOOST_TEST_CRT_SET_HOOK(H) _CrtSetReportHook(H)
+# else
+# define BOOST_TEST_CRT_HOOK_TYPE void*
+# define BOOST_TEST_CRT_ASSERT 2
+# define BOOST_TEST_CRT_ERROR 1
+# define BOOST_TEST_CRT_SET_HOOK(H) (void*)(H)
+# endif
+
+# if !BOOST_WORKAROUND(_MSC_VER, >= 1400 ) || defined(UNDER_CE)
+
+typedef void* _invalid_parameter_handler;
+
+inline _invalid_parameter_handler
+_set_invalid_parameter_handler( _invalid_parameter_handler arg )
+{
+ return arg;
+}
+
+# endif
+
+# if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x0564)) || defined(UNDER_CE)
+
+namespace { void _set_se_translator( void* ) {} }
+
+# endif
+
+#elif defined(BOOST_HAS_SIGACTION)
+
+# define BOOST_SIGACTION_BASED_SIGNAL_HANDLING
+
+# include <unistd.h>
+# include <signal.h>
+# include <setjmp.h>
+
+# if defined(__FreeBSD__)
+
+# ifndef SIGPOLL
+# define SIGPOLL SIGIO
+# endif
+
+# if (__FreeBSD_version < 70100)
+
+# define ILL_ILLADR 0 // ILL_RESAD_FAULT
+# define ILL_PRVOPC ILL_PRIVIN_FAULT
+# define ILL_ILLOPN 2 // ILL_RESOP_FAULT
+# define ILL_COPROC ILL_FPOP_FAULT
+
+# define BOOST_TEST_LIMITED_SIGNAL_DETAILS
+# define BOOST_TEST_IGNORE_SIGCHLD
+
+# endif
+# endif
+
+# if !defined(__CYGWIN__) && !defined(__QNXNTO__)
+# define BOOST_TEST_USE_ALT_STACK
+# endif
+
+# if defined(SIGPOLL) && !defined(__CYGWIN__) && \
+ !(defined(macintosh) || defined(__APPLE__) || defined(__APPLE_CC__)) && \
+ !defined(__NetBSD__) && \
+ !defined(__QNXNTO__)
+# define BOOST_TEST_CATCH_SIGPOLL
+# endif
+
+# ifdef BOOST_TEST_USE_ALT_STACK
+# define BOOST_TEST_ALT_STACK_SIZE SIGSTKSZ
+# endif
+
+#else
+
+# define BOOST_NO_SIGNAL_HANDLING
+
+#endif
+
+#ifndef UNDER_CE
+#include <errno.h>
+#endif
+
+#include <ndnboost/test/detail/suppress_warnings.hpp>
+
+//____________________________________________________________________________//
+
+namespace ndnboost {
+
+// ************************************************************************** //
+// ************** report_error ************** //
+// ************************************************************************** //
+
+namespace detail {
+
+#ifdef __BORLANDC__
+# define BOOST_TEST_VSNPRINTF( a1, a2, a3, a4 ) std::vsnprintf( (a1), (a2), (a3), (a4) )
+#elif BOOST_WORKAROUND(_MSC_VER, <= 1310) || \
+ BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3000)) || \
+ defined(UNDER_CE)
+# define BOOST_TEST_VSNPRINTF( a1, a2, a3, a4 ) _vsnprintf( (a1), (a2), (a3), (a4) )
+#else
+# define BOOST_TEST_VSNPRINTF( a1, a2, a3, a4 ) vsnprintf( (a1), (a2), (a3), (a4) )
+#endif
+
+template <typename ErrorInfo>
+typename ErrorInfo::value_type
+extract( ndnboost::exception const* ex )
+{
+ if( !ex )
+ return 0;
+
+ typename ErrorInfo::value_type const * val = ndnboost::get_error_info<ErrorInfo>( *ex );
+
+ return val ? *val : 0;
+}
+
+//____________________________________________________________________________//
+
+static void
+report_error( execution_exception::error_code ec, ndnboost::exception const* be, char const* format, va_list* args )
+{
+ static const int REPORT_ERROR_BUFFER_SIZE = 512;
+ static char buf[REPORT_ERROR_BUFFER_SIZE];
+
+ BOOST_TEST_VSNPRINTF( buf, sizeof(buf)-1, format, *args );
+ buf[sizeof(buf)-1] = 0;
+
+ va_end( *args );
+
+ throw execution_exception( ec, buf, execution_exception::location( extract<throw_file>( be ),
+ extract<throw_line>( be ),
+ extract<throw_function>( be ) ) );
+}
+
+//____________________________________________________________________________//
+
+static void
+report_error( execution_exception::error_code ec, char const* format, ... )
+{
+ va_list args;
+ va_start( args, format );
+
+ report_error( ec, 0, format, &args );
+}
+
+//____________________________________________________________________________//
+
+static void
+report_error( execution_exception::error_code ec, ndnboost::exception const* be, char const* format, ... )
+{
+ va_list args;
+ va_start( args, format );
+
+ report_error( ec, be, format, &args );
+}
+
+//____________________________________________________________________________//
+
+template<typename Tr,typename Functor>
+inline int
+do_invoke( Tr const& tr, Functor const& F )
+{
+ return tr ? (*tr)( F ) : F();
+}
+
+//____________________________________________________________________________//
+
+} // namespace detail
+
+#if defined(BOOST_SIGACTION_BASED_SIGNAL_HANDLING)
+
+// ************************************************************************** //
+// ************** Sigaction based signal handling ************** //
+// ************************************************************************** //
+
+namespace detail {
+
+// ************************************************************************** //
+// ************** ndnboost::detail::system_signal_exception ************** //
+// ************************************************************************** //
+
+class system_signal_exception {
+public:
+ // Constructor
+ system_signal_exception()
+ : m_sig_info( 0 )
+ , m_context( 0 )
+ {}
+
+ // Access methods
+ void operator()( siginfo_t* i, void* c )
+ {
+ m_sig_info = i;
+ m_context = c;
+ }
+ void report() const;
+
+private:
+ // Data members
+ siginfo_t* m_sig_info; // system signal detailed info
+ void* m_context; // signal context
+};
+
+//____________________________________________________________________________//
+
+void
+system_signal_exception::report() const
+{
+ if( !m_sig_info )
+ return; // no error actually occur?
+
+ switch( m_sig_info->si_code ) {
+ case SI_USER:
+ report_error( execution_exception::system_error,
+ "signal: generated by kill() (or family); uid=%d; pid=%d",
+ (int)m_sig_info->si_uid, (int)m_sig_info->si_pid );
+ break;
+ case SI_QUEUE:
+ report_error( execution_exception::system_error,
+ "signal: sent by sigqueue()" );
+ break;
+ case SI_TIMER:
+ report_error( execution_exception::system_error,
+ "signal: the expiration of a timer set by timer_settimer()" );
+ break;
+ case SI_ASYNCIO:
+ report_error( execution_exception::system_error,
+ "signal: generated by the completion of an asynchronous I/O request" );
+ break;
+ case SI_MESGQ:
+ report_error( execution_exception::system_error,
+ "signal: generated by the the arrival of a message on an empty message queue" );
+ break;
+ default:
+ break;
+ }
+
+ switch( m_sig_info->si_signo ) {
+ case SIGILL:
+ switch( m_sig_info->si_code ) {
+#ifndef BOOST_TEST_LIMITED_SIGNAL_DETAILS
+ case ILL_ILLOPC:
+ report_error( execution_exception::system_fatal_error,
+ "signal: illegal opcode; address of failing instruction: 0x%08lx",
+ m_sig_info->si_addr );
+ break;
+ case ILL_ILLTRP:
+ report_error( execution_exception::system_fatal_error,
+ "signal: illegal trap; address of failing instruction: 0x%08lx",
+ m_sig_info->si_addr );
+ break;
+ case ILL_PRVREG:
+ report_error( execution_exception::system_fatal_error,
+ "signal: privileged register; address of failing instruction: 0x%08lx",
+ m_sig_info->si_addr );
+ break;
+ case ILL_BADSTK:
+ report_error( execution_exception::system_fatal_error,
+ "signal: internal stack error; address of failing instruction: 0x%08lx",
+ m_sig_info->si_addr );
+ break;
+#endif
+ case ILL_ILLOPN:
+ report_error( execution_exception::system_fatal_error,
+ "signal: illegal operand; address of failing instruction: 0x%08lx",
+ m_sig_info->si_addr );
+ break;
+ case ILL_ILLADR:
+ report_error( execution_exception::system_fatal_error,
+ "signal: illegal addressing mode; address of failing instruction: 0x%08lx",
+ m_sig_info->si_addr );
+ break;
+ case ILL_PRVOPC:
+ report_error( execution_exception::system_fatal_error,
+ "signal: privileged opcode; address of failing instruction: 0x%08lx",
+ m_sig_info->si_addr );
+ break;
+ case ILL_COPROC:
+ report_error( execution_exception::system_fatal_error,
+ "signal: co-processor error; address of failing instruction: 0x%08lx",
+ m_sig_info->si_addr );
+ break;
+ default:
+ report_error( execution_exception::system_fatal_error,
+ "signal: SIGILL, si_code: %d (illegal instruction; address of failing instruction: 0x%08lx)",
+ m_sig_info->si_addr, m_sig_info->si_code );
+ break;
+ }
+ break;
+
+ case SIGFPE:
+ switch( m_sig_info->si_code ) {
+ case FPE_INTDIV:
+ report_error( execution_exception::system_error,
+ "signal: integer divide by zero; address of failing instruction: 0x%08lx",
+ m_sig_info->si_addr );
+ break;
+ case FPE_INTOVF:
+ report_error( execution_exception::system_error,
+ "signal: integer overflow; address of failing instruction: 0x%08lx",
+ m_sig_info->si_addr );
+ break;
+ case FPE_FLTDIV:
+ report_error( execution_exception::system_error,
+ "signal: floating point divide by zero; address of failing instruction: 0x%08lx",
+ m_sig_info->si_addr );
+ break;
+ case FPE_FLTOVF:
+ report_error( execution_exception::system_error,
+ "signal: floating point overflow; address of failing instruction: 0x%08lx",
+ m_sig_info->si_addr );
+ break;
+ case FPE_FLTUND:
+ report_error( execution_exception::system_error,
+ "signal: floating point underflow; address of failing instruction: 0x%08lx",
+ m_sig_info->si_addr );
+ break;
+ case FPE_FLTRES:
+ report_error( execution_exception::system_error,
+ "signal: floating point inexact result; address of failing instruction: 0x%08lx",
+ m_sig_info->si_addr );
+ break;
+ case FPE_FLTINV:
+ report_error( execution_exception::system_error,
+ "signal: invalid floating point operation; address of failing instruction: 0x%08lx",
+ m_sig_info->si_addr );
+ break;
+ case FPE_FLTSUB:
+ report_error( execution_exception::system_error,
+ "signal: subscript out of range; address of failing instruction: 0x%08lx",
+ m_sig_info->si_addr );
+ break;
+ default:
+ report_error( execution_exception::system_error,
+ "signal: SIGFPE, si_code: %d (errnoneous arithmetic operations; address of failing instruction: 0x%08lx)",
+ m_sig_info->si_addr, m_sig_info->si_code );
+ break;
+ }
+ break;
+
+ case SIGSEGV:
+ switch( m_sig_info->si_code ) {
+#ifndef BOOST_TEST_LIMITED_SIGNAL_DETAILS
+ case SEGV_MAPERR:
+ report_error( execution_exception::system_fatal_error,
+ "memory access violation at address: 0x%08lx: no mapping at fault address",
+ m_sig_info->si_addr );
+ break;
+ case SEGV_ACCERR:
+ report_error( execution_exception::system_fatal_error,
+ "memory access violation at address: 0x%08lx: invalid permissions",
+ m_sig_info->si_addr );
+ break;
+#endif
+ default:
+ report_error( execution_exception::system_fatal_error,
+ "signal: SIGSEGV, si_code: %d (memory access violation at address: 0x%08lx)",
+ m_sig_info->si_addr, m_sig_info->si_code );
+ break;
+ }
+ break;
+
+ case SIGBUS:
+ switch( m_sig_info->si_code ) {
+#ifndef BOOST_TEST_LIMITED_SIGNAL_DETAILS
+ case BUS_ADRALN:
+ report_error( execution_exception::system_fatal_error,
+ "memory access violation at address: 0x%08lx: invalid address alignment",
+ m_sig_info->si_addr );
+ break;
+ case BUS_ADRERR:
+ report_error( execution_exception::system_fatal_error,
+ "memory access violation at address: 0x%08lx: non-existent physical address",
+ m_sig_info->si_addr );
+ break;
+ case BUS_OBJERR:
+ report_error( execution_exception::system_fatal_error,
+ "memory access violation at address: 0x%08lx: object specific hardware error",
+ m_sig_info->si_addr );
+ break;
+#endif
+ default:
+ report_error( execution_exception::system_fatal_error,
+ "signal: SIGSEGV, si_code: %d (memory access violation at address: 0x%08lx)",
+ m_sig_info->si_addr, m_sig_info->si_code );
+ break;
+ }
+ break;
+
+ case SIGCHLD:
+ switch( m_sig_info->si_code ) {
+#ifndef BOOST_TEST_LIMITED_SIGNAL_DETAILS
+ case CLD_EXITED:
+ report_error( execution_exception::system_error,
+ "child has exited; pid: %d; uid: %d; exit value: %d",
+ (int)m_sig_info->si_pid, (int)m_sig_info->si_uid, (int)m_sig_info->si_status );
+ break;
+ case CLD_KILLED:
+ report_error( execution_exception::system_error,
+ "child was killed; pid: %d; uid: %d; exit value: %d",
+ (int)m_sig_info->si_pid, (int)m_sig_info->si_uid, (int)m_sig_info->si_status );
+ break;
+ case CLD_DUMPED:
+ report_error( execution_exception::system_error,
+ "child terminated abnormally; pid: %d; uid: %d; exit value: %d",
+ (int)m_sig_info->si_pid, (int)m_sig_info->si_uid, (int)m_sig_info->si_status );
+ break;
+ case CLD_TRAPPED:
+ report_error( execution_exception::system_error,
+ "traced child has trapped; pid: %d; uid: %d; exit value: %d",
+ (int)m_sig_info->si_pid, (int)m_sig_info->si_uid, (int)m_sig_info->si_status );
+ break;
+ case CLD_STOPPED:
+ report_error( execution_exception::system_error,
+ "child has stopped; pid: %d; uid: %d; exit value: %d",
+ (int)m_sig_info->si_pid, (int)m_sig_info->si_uid, (int)m_sig_info->si_status );
+ break;
+ case CLD_CONTINUED:
+ report_error( execution_exception::system_error,
+ "stopped child had continued; pid: %d; uid: %d; exit value: %d",
+ (int)m_sig_info->si_pid, (int)m_sig_info->si_uid, (int)m_sig_info->si_status );
+ break;
+#endif
+ default:
+ report_error( execution_exception::system_error,
+ "signal: SIGCHLD, si_code: %d (child process has terminated; pid: %d; uid: %d; exit value: %d)",
+ (int)m_sig_info->si_pid, (int)m_sig_info->si_uid, (int)m_sig_info->si_status, m_sig_info->si_code );
+ break;
+ }
+ break;
+
+#if defined(BOOST_TEST_CATCH_SIGPOLL)
+
+ case SIGPOLL:
+ switch( m_sig_info->si_code ) {
+#ifndef BOOST_TEST_LIMITED_SIGNAL_DETAILS
+ case POLL_IN:
+ report_error( execution_exception::system_error,
+ "data input available; band event %d",
+ (int)m_sig_info->si_band );
+ break;
+ case POLL_OUT:
+ report_error( execution_exception::system_error,
+ "output buffers available; band event %d",
+ (int)m_sig_info->si_band );
+ break;
+ case POLL_MSG:
+ report_error( execution_exception::system_error,
+ "input message available; band event %d",
+ (int)m_sig_info->si_band );
+ break;
+ case POLL_ERR:
+ report_error( execution_exception::system_error,
+ "i/o error; band event %d",
+ (int)m_sig_info->si_band );
+ break;
+ case POLL_PRI:
+ report_error( execution_exception::system_error,
+ "high priority input available; band event %d",
+ (int)m_sig_info->si_band );
+ break;
+#if defined(POLL_ERR) && defined(POLL_HUP) && (POLL_ERR - POLL_HUP)
+ case POLL_HUP:
+ report_error( execution_exception::system_error,
+ "device disconnected; band event %d",
+ (int)m_sig_info->si_band );
+ break;
+#endif
+#endif
+ default:
+ report_error( execution_exception::system_error,
+ "signal: SIGPOLL, si_code: %d (asynchronous I/O event occured; band event %d)",
+ (int)m_sig_info->si_band, m_sig_info->si_code );
+ break;
+ }
+ break;
+
+#endif
+
+ case SIGABRT:
+ report_error( execution_exception::system_error,
+ "signal: SIGABRT (application abort requested)" );
+ break;
+
+ case SIGALRM:
+ report_error( execution_exception::timeout_error,
+ "signal: SIGALRM (timeout while executing function)" );
+ break;
+
+ default:
+ report_error( execution_exception::system_error, "unrecognized signal" );
+ }
+}
+
+//____________________________________________________________________________//
+
+// ************************************************************************** //
+// ************** ndnboost::detail::signal_action ************** //
+// ************************************************************************** //
+
+// Forward declaration
+extern "C" {
+static void execution_monitor_jumping_signal_handler( int sig, siginfo_t* info, void* context );
+static void execution_monitor_attaching_signal_handler( int sig, siginfo_t* info, void* context );
+}
+
+class signal_action {
+ typedef struct sigaction* sigaction_ptr;
+public:
+ //Constructor
+ signal_action();
+ signal_action( int sig, bool install, bool attach_dbg, char* alt_stack );
+ ~signal_action();
+
+private:
+ // Data members
+ int m_sig;
+ bool m_installed;
+ struct sigaction m_new_action;
+ struct sigaction m_old_action;
+};
+
+//____________________________________________________________________________//
+
+signal_action::signal_action()
+: m_installed( false )
+{}
+
+//____________________________________________________________________________//
+
+signal_action::signal_action( int sig, bool install, bool attach_dbg, char* alt_stack )
+: m_sig( sig )
+, m_installed( install )
+{
+ if( !install )
+ return;
+
+ std::memset( &m_new_action, 0, sizeof(struct sigaction) );
+
+ BOOST_TEST_SYS_ASSERT( ::sigaction( m_sig , sigaction_ptr(), &m_new_action ) != -1 );
+
+ if( m_new_action.sa_sigaction || m_new_action.sa_handler ) {
+ m_installed = false;
+ return;
+ }
+
+ m_new_action.sa_flags |= SA_SIGINFO;
+ m_new_action.sa_sigaction = attach_dbg ? &execution_monitor_attaching_signal_handler
+ : &execution_monitor_jumping_signal_handler;
+ BOOST_TEST_SYS_ASSERT( sigemptyset( &m_new_action.sa_mask ) != -1 );
+
+#ifdef BOOST_TEST_USE_ALT_STACK
+ if( alt_stack )
+ m_new_action.sa_flags |= SA_ONSTACK;
+#endif
+
+ BOOST_TEST_SYS_ASSERT( ::sigaction( m_sig, &m_new_action, &m_old_action ) != -1 );
+}
+
+//____________________________________________________________________________//
+
+signal_action::~signal_action()
+{
+ if( m_installed )
+ ::sigaction( m_sig, &m_old_action , sigaction_ptr() );
+}
+
+//____________________________________________________________________________//
+
+// ************************************************************************** //
+// ************** ndnboost::detail::signal_handler ************** //
+// ************************************************************************** //
+
+class signal_handler {
+public:
+ // Constructor
+ explicit signal_handler( bool catch_system_errors, int timeout, bool attach_dbg, char* alt_stack );
+
+ // Destructor
+ ~signal_handler();
+
+ // access methods
+ static sigjmp_buf& jump_buffer()
+ {
+ assert( !!s_active_handler );
+
+ return s_active_handler->m_sigjmp_buf;
+ }
+
+ static system_signal_exception& sys_sig()
+ {
+ assert( !!s_active_handler );
+
+ return s_active_handler->m_sys_sig;
+ }
+
+private:
+ // Data members
+ signal_handler* m_prev_handler;
+ int m_timeout;
+
+ signal_action m_ILL_action;
+ signal_action m_FPE_action;
+ signal_action m_SEGV_action;
+ signal_action m_BUS_action;
+ signal_action m_CHLD_action;
+ signal_action m_POLL_action;
+ signal_action m_ABRT_action;
+ signal_action m_ALRM_action;
+
+ sigjmp_buf m_sigjmp_buf;
+ system_signal_exception m_sys_sig;
+
+ static signal_handler* s_active_handler;
+};
+
+// !! need to be placed in thread specific storage
+typedef signal_handler* signal_handler_ptr;
+signal_handler* signal_handler::s_active_handler = signal_handler_ptr();
+
+//____________________________________________________________________________//
+
+signal_handler::signal_handler( bool catch_system_errors, int timeout, bool attach_dbg, char* alt_stack )
+: m_prev_handler( s_active_handler )
+, m_timeout( timeout )
+, m_ILL_action ( SIGILL , catch_system_errors, attach_dbg, alt_stack )
+, m_FPE_action ( SIGFPE , catch_system_errors, attach_dbg, alt_stack )
+, m_SEGV_action( SIGSEGV, catch_system_errors, attach_dbg, alt_stack )
+, m_BUS_action ( SIGBUS , catch_system_errors, attach_dbg, alt_stack )
+#ifndef BOOST_TEST_IGNORE_SIGCHLD
+, m_CHLD_action( SIGCHLD, catch_system_errors, attach_dbg, alt_stack )
+#endif
+#ifdef BOOST_TEST_CATCH_SIGPOLL
+, m_POLL_action( SIGPOLL, catch_system_errors, attach_dbg, alt_stack )
+#endif
+, m_ABRT_action( SIGABRT, catch_system_errors, attach_dbg, alt_stack )
+, m_ALRM_action( SIGALRM, timeout > 0 , attach_dbg, alt_stack )
+{
+ s_active_handler = this;
+
+ if( m_timeout > 0 ) {
+ ::alarm( 0 );
+ ::alarm( timeout );
+ }
+
+#ifdef BOOST_TEST_USE_ALT_STACK
+ if( alt_stack ) {
+ stack_t sigstk;
+ std::memset( &sigstk, 0, sizeof(stack_t) );
+
+ BOOST_TEST_SYS_ASSERT( ::sigaltstack( 0, &sigstk ) != -1 );
+
+ if( sigstk.ss_flags & SS_DISABLE ) {
+ sigstk.ss_sp = alt_stack;
+ sigstk.ss_size = BOOST_TEST_ALT_STACK_SIZE;
+ sigstk.ss_flags = 0;
+ BOOST_TEST_SYS_ASSERT( ::sigaltstack( &sigstk, 0 ) != -1 );
+ }
+ }
+#endif
+}
+
+//____________________________________________________________________________//
+
+signal_handler::~signal_handler()
+{
+ assert( s_active_handler == this );
+
+ if( m_timeout > 0 )
+ ::alarm( 0 );
+
+#ifdef BOOST_TEST_USE_ALT_STACK
+#ifdef __GNUC__
+ // We shouldn't need to explicitly initialize all the members here,
+ // but gcc warns if we don't, so add initializers for each of the
+ // members specified in the POSIX std:
+ stack_t sigstk = { 0, 0, 0 };
+#else
+ stack_t sigstk = { };
+#endif
+
+ sigstk.ss_size = MINSIGSTKSZ;
+ sigstk.ss_flags = SS_DISABLE;
+ BOOST_TEST_SYS_ASSERT( ::sigaltstack( &sigstk, 0 ) != -1 );
+#endif
+
+ s_active_handler = m_prev_handler;
+}
+
+//____________________________________________________________________________//
+
+// ************************************************************************** //
+// ************** execution_monitor_signal_handler ************** //
+// ************************************************************************** //
+
+extern "C" {
+
+static bool ignore_sigchild( siginfo_t* info )
+{
+ return info->si_signo == SIGCHLD
+#ifndef BOOST_TEST_LIMITED_SIGNAL_DETAILS
+ && info->si_code == CLD_EXITED
+#endif
+#ifdef BOOST_TEST_IGNORE_NON_ZERO_CHILD_CODE
+ ;
+#else
+ && (int)info->si_status == 0;
+#endif
+}
+
+//____________________________________________________________________________//
+
+static void execution_monitor_jumping_signal_handler( int sig, siginfo_t* info, void* context )
+{
+ if( ignore_sigchild( info ) )
+ return;
+
+ signal_handler::sys_sig()( info, context );
+
+ siglongjmp( signal_handler::jump_buffer(), sig );
+}
+
+//____________________________________________________________________________//
+
+static void execution_monitor_attaching_signal_handler( int sig, siginfo_t* info, void* context )
+{
+ if( ignore_sigchild( info ) )
+ return;
+
+ if( !debug::attach_debugger( false ) )
+ execution_monitor_jumping_signal_handler( sig, info, context );
+
+ // debugger attached; it will handle the signal
+ BOOST_TEST_SYS_ASSERT( ::signal( sig, SIG_DFL ) != SIG_ERR );
+}
+
+//____________________________________________________________________________//
+
+}
+
+} // namespace detail
+
+// ************************************************************************** //
+// ************** execution_monitor::catch_signals ************** //
+// ************************************************************************** //
+
+int
+execution_monitor::catch_signals( unit_test::callback0<int> const& F )
+{
+ using namespace detail;
+
+#if defined(__CYGWIN__)
+ p_catch_system_errors.value = false;
+#endif
+
+#ifdef BOOST_TEST_USE_ALT_STACK
+ if( !!p_use_alt_stack && !m_alt_stack )
+ m_alt_stack.reset( new char[BOOST_TEST_ALT_STACK_SIZE] );
+#else
+ p_use_alt_stack.value = false;
+#endif
+
+ signal_handler local_signal_handler( p_catch_system_errors, p_timeout, p_auto_start_dbg,
+ !p_use_alt_stack ? 0 : m_alt_stack.get() );
+
+ if( !sigsetjmp( signal_handler::jump_buffer(), 1 ) )
+ return detail::do_invoke( m_custom_translators , F );
+ else
+ throw local_signal_handler.sys_sig();
+}
+
+//____________________________________________________________________________//
+
+#elif defined(BOOST_SEH_BASED_SIGNAL_HANDLING)
+
+// ************************************************************************** //
+// ************** Microsoft structured exception handling ************** //
+// ************************************************************************** //
+
+#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x0564))
+namespace { void _set_se_translator( void* ) {} }
+#endif
+
+namespace detail {
+
+// ************************************************************************** //
+// ************** ndnboost::detail::system_signal_exception ************** //
+// ************************************************************************** //
+
+class system_signal_exception {
+public:
+ // Constructor
+ explicit system_signal_exception( execution_monitor* em )
+ : m_em( em )
+ , m_se_id( 0 )
+ , m_fault_address( 0 )
+ , m_dir( false )
+ {}
+
+ void report() const;
+ int operator()( unsigned int id, _EXCEPTION_POINTERS* exps );
+
+private:
+ // Data members
+ execution_monitor* m_em;
+
+ unsigned int m_se_id;
+ void* m_fault_address;
+ bool m_dir;
+};
+
+static void
+seh_catch_preventer( unsigned int /* id */, _EXCEPTION_POINTERS* /* exps */ )
+{
+ throw;
+}
+
+//____________________________________________________________________________//
+
+int
+system_signal_exception::operator()( unsigned int id, _EXCEPTION_POINTERS* exps )
+{
+ const unsigned int MSFT_CPP_EXCEPT = 0xE06d7363; // EMSC
+
+ if( !m_em->p_catch_system_errors || (id == MSFT_CPP_EXCEPT) )
+ return EXCEPTION_CONTINUE_SEARCH;
+
+ if( !!m_em->p_auto_start_dbg && debug::attach_debugger( false ) ) {
+ m_em->p_catch_system_errors.value = false;
+ _set_se_translator( &seh_catch_preventer );
+
+ return EXCEPTION_CONTINUE_EXECUTION;
+ }
+
+ m_se_id = id;
+ if( m_se_id == EXCEPTION_ACCESS_VIOLATION && exps->ExceptionRecord->NumberParameters == 2 ) {
+ m_fault_address = (void*)exps->ExceptionRecord->ExceptionInformation[1];
+ m_dir = exps->ExceptionRecord->ExceptionInformation[0] == 0;
+ }
+
+ return EXCEPTION_EXECUTE_HANDLER;
+}
+
+//____________________________________________________________________________//
+
+void
+system_signal_exception::report() const
+{
+ switch( m_se_id ) {
+ // cases classified as system_fatal_error
+ case EXCEPTION_ACCESS_VIOLATION: {
+ if( !m_fault_address )
+ detail::report_error( execution_exception::system_fatal_error, "memory access violation" );
+ else
+ detail::report_error(
+ execution_exception::system_fatal_error,
+ "memory access violation occurred at address 0x%08lx, while attempting to %s",
+ m_fault_address,
+ m_dir ? " read inaccessible data"
+ : " write to an inaccessible (or protected) address"
+ );
+ break;
+ }
+
+ case EXCEPTION_ILLEGAL_INSTRUCTION:
+ detail::report_error( execution_exception::system_fatal_error, "illegal instruction" );
+ break;
+
+ case EXCEPTION_PRIV_INSTRUCTION:
+ detail::report_error( execution_exception::system_fatal_error, "tried to execute an instruction whose operation is not allowed in the current machine mode" );
+ break;
+
+ case EXCEPTION_IN_PAGE_ERROR:
+ detail::report_error( execution_exception::system_fatal_error, "access to a memory page that is not present" );
+ break;
+
+ case EXCEPTION_STACK_OVERFLOW:
+ detail::report_error( execution_exception::system_fatal_error, "stack overflow" );
+ break;
+
+ case EXCEPTION_NONCONTINUABLE_EXCEPTION:
+ detail::report_error( execution_exception::system_fatal_error, "tried to continue execution after a non continuable exception occurred" );
+ break;
+
+ // cases classified as (non-fatal) system_trap
+ case EXCEPTION_DATATYPE_MISALIGNMENT:
+ detail::report_error( execution_exception::system_error, "data misalignment" );
+ break;
+
+ case EXCEPTION_INT_DIVIDE_BY_ZERO:
+ detail::report_error( execution_exception::system_error, "integer divide by zero" );
+ break;
+
+ case EXCEPTION_INT_OVERFLOW:
+ detail::report_error( execution_exception::system_error, "integer overflow" );
+ break;
+
+ case EXCEPTION_ARRAY_BOUNDS_EXCEEDED:
+ detail::report_error( execution_exception::system_error, "array bounds exceeded" );
+ break;
+
+ case EXCEPTION_FLT_DIVIDE_BY_ZERO:
+ detail::report_error( execution_exception::system_error, "floating point divide by zero" );
+ break;
+
+ case EXCEPTION_FLT_STACK_CHECK:
+ detail::report_error( execution_exception::system_error,
+ "stack overflowed or underflowed as the result of a floating-point operation" );
+ break;
+
+ case EXCEPTION_FLT_DENORMAL_OPERAND:
+ detail::report_error( execution_exception::system_error,
+ "operand of floating point operation is denormal" );
+ break;
+
+# if 0 // !! ??
+ case EXCEPTION_FLT_INEXACT_RESULT:
+ detail::report_error( execution_exception::system_error,
+ "result of a floating-point operation cannot be represented exactly" );
+ break;
+#endif
+
+ case EXCEPTION_FLT_OVERFLOW:
+ detail::report_error( execution_exception::system_error,
+ "exponent of a floating-point operation is greater than the magnitude allowed by the corresponding type" );
+ break;
+
+ case EXCEPTION_FLT_UNDERFLOW:
+ detail::report_error( execution_exception::system_error,
+ "exponent of a floating-point operation is less than the magnitude allowed by the corresponding type" );
+ break;
+
+ case EXCEPTION_FLT_INVALID_OPERATION:
+ detail::report_error( execution_exception::system_error, "floating point error" );
+ break;
+
+ case EXCEPTION_BREAKPOINT:
+ detail::report_error( execution_exception::system_error, "breakpoint encountered" );
+ break;
+
+ default:
+ detail::report_error( execution_exception::system_error, "unrecognized exception. Id: 0x%08lx", m_se_id );
+ break;
+ }
+}
+
+//____________________________________________________________________________//
+
+// ************************************************************************** //
+// ************** assert_reporting_function ************** //
+// ************************************************************************** //
+
+int BOOST_TEST_CALL_DECL
+assert_reporting_function( int reportType, char* userMessage, int* )
+{
+ switch( reportType ) {
+ case BOOST_TEST_CRT_ASSERT:
+ detail::report_error( execution_exception::user_error, userMessage );
+
+ return 1; // return value and retVal are not important since we never reach this line
+ case BOOST_TEST_CRT_ERROR:
+ detail::report_error( execution_exception::system_error, userMessage );
+
+ return 1; // return value and retVal are not important since we never reach this line
+ default:
+ return 0; // use usual reporting method
+ }
+} // assert_reporting_function
+
+//____________________________________________________________________________//
+
+void BOOST_TEST_CALL_DECL
+invalid_param_handler( wchar_t const* /* expr */,
+ wchar_t const* /* func */,
+ wchar_t const* /* file */,
+ unsigned int /* line */,
+ uintptr_t /* reserved */)
+{
+ detail::report_error( execution_exception::user_error,
+ "Invalid parameter detected by C runtime library" );
+}
+
+//____________________________________________________________________________//
+
+void BOOST_TEST_CALL_DECL
+switch_fp_exceptions( bool on_off )
+{
+ if( !on_off )
+ _clearfp();
+
+ int cw = ::_controlfp( 0, 0 );
+
+ int exceptions_mask = EM_INVALID|EM_DENORMAL|EM_ZERODIVIDE|EM_OVERFLOW|EM_UNDERFLOW;
+
+ if( on_off )
+ cw &= ~exceptions_mask; // Set the exception masks on, turn exceptions off
+ else
+ cw |= exceptions_mask; // Set the exception masks off, turn exceptions on
+
+ if( on_off )
+ _clearfp();
+
+ // Set the control word
+ ::_controlfp( cw, MCW_EM );
+}
+
+//____________________________________________________________________________//
+
+} // namespace detail
+
+// ************************************************************************** //
+// ************** execution_monitor::catch_signals ************** //
+// ************************************************************************** //
+
+int
+execution_monitor::catch_signals( unit_test::callback0<int> const& F )
+{
+ _invalid_parameter_handler old_iph = _invalid_parameter_handler();
+ BOOST_TEST_CRT_HOOK_TYPE old_crt_hook = 0;
+
+ if( !p_catch_system_errors )
+ _set_se_translator( &detail::seh_catch_preventer );
+ else {
+ if( !!p_detect_fp_exceptions )
+ detail::switch_fp_exceptions( true );
+
+ old_crt_hook = BOOST_TEST_CRT_SET_HOOK( &detail::assert_reporting_function );
+
+ old_iph = _set_invalid_parameter_handler(
+ reinterpret_cast<_invalid_parameter_handler>( &detail::invalid_param_handler ) );
+ }
+
+ detail::system_signal_exception SSE( this );
+
+ int ret_val = 0;
+
+ __try {
+ __try {
+ ret_val = detail::do_invoke( m_custom_translators, F );
+ }
+ __except( SSE( GetExceptionCode(), GetExceptionInformation() ) ) {
+ throw SSE;
+ }
+ }
+ __finally {
+ if( !!p_catch_system_errors ) {
+ if( !!p_detect_fp_exceptions )
+ detail::switch_fp_exceptions( false );
+
+ BOOST_TEST_CRT_SET_HOOK( old_crt_hook );
+
+ _set_invalid_parameter_handler( old_iph );
+ }
+ }
+
+ return ret_val;
+}
+
+//____________________________________________________________________________//
+
+#else // default signal handler
+
+namespace detail {
+
+class system_signal_exception {
+public:
+ void report() const {}
+};
+
+} // namespace detail
+
+int
+execution_monitor::catch_signals( unit_test::callback0<int> const& F )
+{
+ return detail::do_invoke( m_custom_translators , F );
+}
+
+//____________________________________________________________________________//
+
+#endif // choose signal handler
+
+// ************************************************************************** //
+// ************** execution_monitor::execute ************** //
+// ************************************************************************** //
+
+int
+execution_monitor::execute( unit_test::callback0<int> const& F )
+{
+ if( debug::under_debugger() )
+ p_catch_system_errors.value = false;
+
+ try {
+ return catch_signals( F );
+ }
+
+ // Catch-clause reference arguments are a bit different from function
+ // arguments (ISO 15.3 paragraphs 18 & 19). Apparently const isn't
+ // required. Programmers ask for const anyhow, so we supply it. That's
+ // easier than answering questions about non-const usage.
+
+ catch( char const* ex )
+ { detail::report_error( execution_exception::cpp_exception_error,
+ "C string: %s", ex ); }
+ catch( std::string const& ex )
+ { detail::report_error( execution_exception::cpp_exception_error,
+ "std::string: %s", ex.c_str() ); }
+
+ // std:: exceptions
+
+ catch( std::bad_alloc const& ex )
+ { detail::report_error( execution_exception::cpp_exception_error,
+ current_exception_cast<ndnboost::exception const>(),
+ "std::bad_alloc: %s", ex.what() ); }
+
+#if BOOST_WORKAROUND(__BORLANDC__, <= 0x0551)
+ catch( std::bad_cast const& ex )
+ { detail::report_error( execution_exception::cpp_exception_error,
+ current_exception_cast<ndnboost::exception const>(),
+ "std::bad_cast" ); }
+ catch( std::bad_typeid const& ex )
+ { detail::report_error( execution_exception::cpp_exception_error,
+ current_exception_cast<ndnboost::exception const>(),
+ "std::bad_typeid" ); }
+#else
+ catch( std::bad_cast const& ex )
+ { detail::report_error( execution_exception::cpp_exception_error,
+ current_exception_cast<ndnboost::exception const>(),
+ "std::bad_cast: %s", ex.what() ); }
+ catch( std::bad_typeid const& ex )
+ { detail::report_error( execution_exception::cpp_exception_error,
+ current_exception_cast<ndnboost::exception const>(),
+ "std::bad_typeid: %s", ex.what() ); }
+#endif
+
+ catch( std::bad_exception const& ex )
+ { detail::report_error( execution_exception::cpp_exception_error,
+ current_exception_cast<ndnboost::exception const>(),
+ "std::bad_exception: %s", ex.what() ); }
+ catch( std::domain_error const& ex )
+ { detail::report_error( execution_exception::cpp_exception_error,
+ current_exception_cast<ndnboost::exception const>(),
+ "std::domain_error: %s", ex.what() ); }
+ catch( std::invalid_argument const& ex )
+ { detail::report_error( execution_exception::cpp_exception_error,
+ current_exception_cast<ndnboost::exception const>(),
+ "std::invalid_argument: %s", ex.what() ); }
+ catch( std::length_error const& ex )
+ { detail::report_error( execution_exception::cpp_exception_error,
+ current_exception_cast<ndnboost::exception const>(),
+ "std::length_error: %s", ex.what() ); }
+ catch( std::out_of_range const& ex )
+ { detail::report_error( execution_exception::cpp_exception_error,
+ current_exception_cast<ndnboost::exception const>(),
+ "std::out_of_range: %s", ex.what() ); }
+ catch( std::range_error const& ex )
+ { detail::report_error( execution_exception::cpp_exception_error,
+ current_exception_cast<ndnboost::exception const>(),
+ "std::range_error: %s", ex.what() ); }
+ catch( std::overflow_error const& ex )
+ { detail::report_error( execution_exception::cpp_exception_error,
+ current_exception_cast<ndnboost::exception const>(),
+ "std::overflow_error: %s", ex.what() ); }
+ catch( std::underflow_error const& ex )
+ { detail::report_error( execution_exception::cpp_exception_error,
+ current_exception_cast<ndnboost::exception const>(),
+ "std::underflow_error: %s", ex.what() ); }
+ catch( std::logic_error const& ex )
+ { detail::report_error( execution_exception::cpp_exception_error,
+ current_exception_cast<ndnboost::exception const>(),
+ "std::logic_error: %s", ex.what() ); }
+ catch( std::runtime_error const& ex )
+ { detail::report_error( execution_exception::cpp_exception_error,
+ current_exception_cast<ndnboost::exception const>(),
+ "std::runtime_error: %s", ex.what() ); }
+ catch( std::exception const& ex )
+ { detail::report_error( execution_exception::cpp_exception_error,
+ current_exception_cast<ndnboost::exception const>(),
+ "std::exception: %s", ex.what() ); }
+
+ catch( ndnboost::exception const& ex )
+ { detail::report_error( execution_exception::cpp_exception_error,
+ &ex,
+ "unknown ndnboost::exception" ); }
+
+ // system errors
+ catch( system_error const& ex )
+ { detail::report_error( execution_exception::cpp_exception_error,
+ "system_error produced by: %s: %s", ex.p_failed_exp.get(), std::strerror( ex.p_errno ) ); }
+ catch( detail::system_signal_exception const& ex )
+ { ex.report(); }
+
+ // not an error
+ catch( execution_aborted const& )
+ { return 0; }
+
+ // just forward
+ catch( execution_exception const& )
+ { throw; }
+
+ // unknown error
+ catch( ... )
+ { detail::report_error( execution_exception::cpp_exception_error, "unknown type" ); }
+
+ return 0; // never reached; supplied to quiet compiler warnings
+} // execute
+
+//____________________________________________________________________________//
+
+// ************************************************************************** //
+// ************** system_error ************** //
+// ************************************************************************** //
+
+system_error::system_error( char const* exp )
+#ifdef UNDER_CE
+: p_errno( GetLastError() )
+#else
+: p_errno( errno )
+#endif
+, p_failed_exp( exp )
+{}
+
+//____________________________________________________________________________//
+
+// ************************************************************************** //
+// ************** execution_exception ************** //
+// ************************************************************************** //
+
+execution_exception::execution_exception( error_code ec_, const_string what_msg_, location const& location_ )
+: m_error_code( ec_ )
+, m_what( what_msg_.empty() ? BOOST_TEST_L( "uncaught exception, system error or abort requested" ) : what_msg_ )
+, m_location( location_ )
+{}
+
+//____________________________________________________________________________//
+
+execution_exception::location::location( char const* file_name, size_t line_num, char const* func )
+: m_file_name( file_name ? file_name : "unknown location" )
+, m_line_num( line_num )
+, m_function( func )
+{}
+
+//____________________________________________________________________________//
+
+} // namespace ndnboost
+
+#include <ndnboost/test/detail/enable_warnings.hpp>
+
+#endif // BOOST_TEST_EXECUTION_MONITOR_IPP_012205GER
+
diff --git a/ndnboost/test/impl/framework.ipp b/ndnboost/test/impl/framework.ipp
new file mode 100644
index 0000000..cdbce24
--- /dev/null
+++ b/ndnboost/test/impl/framework.ipp
@@ -0,0 +1,503 @@
+// (C) Copyright Gennadiy Rozental 2005-2008.
+// Distributed under 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)
+
+// See http://www.boost.org/libs/test for the library home page.
+//
+// File : $RCSfile$
+//
+// Version : $Revision: 57991 $
+//
+// Description : implements framework API - main driver for the test
+// ***************************************************************************
+
+#ifndef BOOST_TEST_FRAMEWORK_IPP_021005GER
+#define BOOST_TEST_FRAMEWORK_IPP_021005GER
+
+// Boost.Test
+#include <ndnboost/test/framework.hpp>
+#include <ndnboost/test/execution_monitor.hpp>
+#include <ndnboost/test/debug.hpp>
+#include <ndnboost/test/unit_test_suite_impl.hpp>
+#include <ndnboost/test/unit_test_log.hpp>
+#include <ndnboost/test/unit_test_monitor.hpp>
+#include <ndnboost/test/test_observer.hpp>
+#include <ndnboost/test/results_collector.hpp>
+#include <ndnboost/test/progress_monitor.hpp>
+#include <ndnboost/test/results_reporter.hpp>
+#include <ndnboost/test/test_tools.hpp>
+
+#include <ndnboost/test/detail/unit_test_parameters.hpp>
+#include <ndnboost/test/detail/global_typedef.hpp>
+
+#include <ndnboost/test/utils/foreach.hpp>
+
+// Boost
+#include <ndnboost/timer.hpp>
+
+// STL
+#include <map>
+#include <set>
+#include <cstdlib>
+#include <ctime>
+
+#ifdef BOOST_NO_STDC_NAMESPACE
+namespace std { using ::time; using ::srand; }
+#endif
+
+#include <ndnboost/test/detail/suppress_warnings.hpp>
+
+//____________________________________________________________________________//
+
+namespace ndnboost {
+
+namespace unit_test {
+
+// ************************************************************************** //
+// ************** test_start calls wrapper ************** //
+// ************************************************************************** //
+
+namespace ut_detail {
+
+struct test_start_caller {
+ test_start_caller( test_observer* to, counter_t tc_amount )
+ : m_to( to )
+ , m_tc_amount( tc_amount )
+ {}
+
+ int operator()()
+ {
+ m_to->test_start( m_tc_amount );
+ return 0;
+ }
+
+private:
+ // Data members
+ test_observer* m_to;
+ counter_t m_tc_amount;
+};
+
+//____________________________________________________________________________//
+
+struct test_init_caller {
+ explicit test_init_caller( init_unit_test_func init_func )
+ : m_init_func( init_func )
+ {}
+ int operator()()
+ {
+#ifdef BOOST_TEST_ALTERNATIVE_INIT_API
+ if( !(*m_init_func)() )
+ throw std::runtime_error( "test module initialization failed" );
+#else
+ test_suite* manual_test_units = (*m_init_func)( framework::master_test_suite().argc, framework::master_test_suite().argv );
+
+ if( manual_test_units )
+ framework::master_test_suite().add( manual_test_units );
+#endif
+ return 0;
+ }
+
+ // Data members
+ init_unit_test_func m_init_func;
+};
+
+}
+
+// ************************************************************************** //
+// ************** framework ************** //
+// ************************************************************************** //
+
+class framework_impl : public test_tree_visitor {
+public:
+ framework_impl()
+ : m_master_test_suite( 0 )
+ , m_curr_test_case( INV_TEST_UNIT_ID )
+ , m_next_test_case_id( MIN_TEST_CASE_ID )
+ , m_next_test_suite_id( MIN_TEST_SUITE_ID )
+ , m_is_initialized( false )
+ , m_test_in_progress( false )
+ {}
+
+ ~framework_impl() { clear(); }
+
+ void clear()
+ {
+ while( !m_test_units.empty() ) {
+ test_unit_store::value_type const& tu = *m_test_units.begin();
+ test_unit* tu_ptr = tu.second;
+
+ // the delete will erase this element from map
+ if( ut_detail::test_id_2_unit_type( tu.second->p_id ) == tut_suite )
+ delete (test_suite const*)tu_ptr;
+ else
+ delete (test_case const*)tu_ptr;
+ }
+ }
+
+ void set_tu_id( test_unit& tu, test_unit_id id ) { tu.p_id.value = id; }
+
+ // test_tree_visitor interface implementation
+ void visit( test_case const& tc )
+ {
+ if( !tc.check_dependencies() ) {
+ BOOST_TEST_FOREACH( test_observer*, to, m_observers )
+ to->test_unit_skipped( tc );
+
+ return;
+ }
+
+ BOOST_TEST_FOREACH( test_observer*, to, m_observers )
+ to->test_unit_start( tc );
+
+ ndnboost::timer tc_timer;
+ test_unit_id bkup = m_curr_test_case;
+ m_curr_test_case = tc.p_id;
+ unit_test_monitor_t::error_level run_result = unit_test_monitor.execute_and_translate( tc );
+
+ unsigned long elapsed = static_cast<unsigned long>( tc_timer.elapsed() * 1e6 );
+
+ if( unit_test_monitor.is_critical_error( run_result ) ) {
+ BOOST_TEST_FOREACH( test_observer*, to, m_observers )
+ to->test_aborted();
+ }
+
+ BOOST_TEST_FOREACH( test_observer*, to, m_observers )
+ to->test_unit_finish( tc, elapsed );
+
+ m_curr_test_case = bkup;
+
+ if( unit_test_monitor.is_critical_error( run_result ) )
+ throw test_being_aborted();
+ }
+
+ bool test_suite_start( test_suite const& ts )
+ {
+ if( !ts.check_dependencies() ) {
+ BOOST_TEST_FOREACH( test_observer*, to, m_observers )
+ to->test_unit_skipped( ts );
+
+ return false;
+ }
+
+ BOOST_TEST_FOREACH( test_observer*, to, m_observers )
+ to->test_unit_start( ts );
+
+ return true;
+ }
+
+ void test_suite_finish( test_suite const& ts )
+ {
+ BOOST_TEST_FOREACH( test_observer*, to, m_observers )
+ to->test_unit_finish( ts, 0 );
+ }
+
+ //////////////////////////////////////////////////////////////////
+ struct priority_order {
+ bool operator()( test_observer* lhs, test_observer* rhs ) const
+ {
+ return (lhs->priority() < rhs->priority()) || ((lhs->priority() == rhs->priority()) && (lhs < rhs));
+ }
+ };
+
+ typedef std::map<test_unit_id,test_unit*> test_unit_store;
+ typedef std::set<test_observer*,priority_order> observer_store;
+
+ master_test_suite_t* m_master_test_suite;
+ test_unit_id m_curr_test_case;
+ test_unit_store m_test_units;
+
+ test_unit_id m_next_test_case_id;
+ test_unit_id m_next_test_suite_id;
+
+ bool m_is_initialized;
+ bool m_test_in_progress;
+
+ observer_store m_observers;
+};
+
+//____________________________________________________________________________//
+
+namespace {
+
+#if defined(__CYGWIN__)
+framework_impl& s_frk_impl() { static framework_impl* the_inst = 0; if(!the_inst) the_inst = new framework_impl; return *the_inst; }
+#else
+framework_impl& s_frk_impl() { static framework_impl the_inst; return the_inst; }
+#endif
+
+} // local namespace
+
+//____________________________________________________________________________//
+
+namespace framework {
+
+void
+init( init_unit_test_func init_func, int argc, char* argv[] )
+{
+ runtime_config::init( argc, argv );
+
+ // set the log level and format
+ unit_test_log.set_threshold_level( runtime_config::log_level() );
+ unit_test_log.set_format( runtime_config::log_format() );
+
+ // set the report level and format
+ results_reporter::set_level( runtime_config::report_level() );
+ results_reporter::set_format( runtime_config::report_format() );
+
+ register_observer( results_collector );
+ register_observer( unit_test_log );
+
+ if( runtime_config::show_progress() )
+ register_observer( progress_monitor );
+
+ if( runtime_config::detect_memory_leaks() > 0 ) {
+ debug::detect_memory_leaks( true );
+ debug::break_memory_alloc( runtime_config::detect_memory_leaks() );
+ }
+
+ // init master unit test suite
+ master_test_suite().argc = argc;
+ master_test_suite().argv = argv;
+
+ try {
+ ndnboost::execution_monitor em;
+
+ ut_detail::test_init_caller tic( init_func );
+
+ em.execute( tic );
+ }
+ catch( execution_exception const& ex ) {
+ throw setup_error( ex.what() );
+ }
+
+ s_frk_impl().m_is_initialized = true;
+}
+
+//____________________________________________________________________________//
+
+bool
+is_initialized()
+{
+ return s_frk_impl().m_is_initialized;
+}
+
+//____________________________________________________________________________//
+
+void
+register_test_unit( test_case* tc )
+{
+ BOOST_TEST_SETUP_ASSERT( tc->p_id == INV_TEST_UNIT_ID, BOOST_TEST_L( "test case already registered" ) );
+
+ test_unit_id new_id = s_frk_impl().m_next_test_case_id;
+
+ BOOST_TEST_SETUP_ASSERT( new_id != MAX_TEST_CASE_ID, BOOST_TEST_L( "too many test cases" ) );
+
+ typedef framework_impl::test_unit_store::value_type map_value_type;
+
+ s_frk_impl().m_test_units.insert( map_value_type( new_id, tc ) );
+ s_frk_impl().m_next_test_case_id++;
+
+ s_frk_impl().set_tu_id( *tc, new_id );
+}
+
+//____________________________________________________________________________//
+
+void
+register_test_unit( test_suite* ts )
+{
+ BOOST_TEST_SETUP_ASSERT( ts->p_id == INV_TEST_UNIT_ID, BOOST_TEST_L( "test suite already registered" ) );
+
+ test_unit_id new_id = s_frk_impl().m_next_test_suite_id;
+
+ BOOST_TEST_SETUP_ASSERT( new_id != MAX_TEST_SUITE_ID, BOOST_TEST_L( "too many test suites" ) );
+
+ typedef framework_impl::test_unit_store::value_type map_value_type;
+ s_frk_impl().m_test_units.insert( map_value_type( new_id, ts ) );
+ s_frk_impl().m_next_test_suite_id++;
+
+ s_frk_impl().set_tu_id( *ts, new_id );
+}
+
+//____________________________________________________________________________//
+
+void
+deregister_test_unit( test_unit* tu )
+{
+ s_frk_impl().m_test_units.erase( tu->p_id );
+}
+
+//____________________________________________________________________________//
+
+void
+clear()
+{
+ s_frk_impl().clear();
+}
+
+//____________________________________________________________________________//
+
+void
+register_observer( test_observer& to )
+{
+ s_frk_impl().m_observers.insert( &to );
+}
+
+//____________________________________________________________________________//
+
+void
+deregister_observer( test_observer& to )
+{
+ s_frk_impl().m_observers.erase( &to );
+}
+
+//____________________________________________________________________________//
+
+void
+reset_observers()
+{
+ s_frk_impl().m_observers.clear();
+}
+
+//____________________________________________________________________________//
+
+master_test_suite_t&
+master_test_suite()
+{
+ if( !s_frk_impl().m_master_test_suite )
+ s_frk_impl().m_master_test_suite = new master_test_suite_t;
+
+ return *s_frk_impl().m_master_test_suite;
+}
+
+//____________________________________________________________________________//
+
+test_case const&
+current_test_case()
+{
+ return get<test_case>( s_frk_impl().m_curr_test_case );
+}
+
+//____________________________________________________________________________//
+
+test_unit&
+get( test_unit_id id, test_unit_type t )
+{
+ test_unit* res = s_frk_impl().m_test_units[id];
+
+ if( (res->p_type & t) == 0 )
+ throw internal_error( "Invalid test unit type" );
+
+ return *res;
+}
+
+//____________________________________________________________________________//
+
+void
+run( test_unit_id id, bool continue_test )
+{
+ if( id == INV_TEST_UNIT_ID )
+ id = master_test_suite().p_id;
+
+ test_case_counter tcc;
+ traverse_test_tree( id, tcc );
+
+ BOOST_TEST_SETUP_ASSERT( tcc.p_count != 0 , runtime_config::test_to_run().is_empty()
+ ? BOOST_TEST_L( "test tree is empty" )
+ : BOOST_TEST_L( "no test cases matching filter" ) );
+
+ bool call_start_finish = !continue_test || !s_frk_impl().m_test_in_progress;
+ bool was_in_progress = s_frk_impl().m_test_in_progress;
+
+ s_frk_impl().m_test_in_progress = true;
+
+ if( call_start_finish ) {
+ BOOST_TEST_FOREACH( test_observer*, to, s_frk_impl().m_observers ) {
+ ndnboost::execution_monitor em;
+
+ try {
+ em.execute( ut_detail::test_start_caller( to, tcc.p_count ) );
+ }
+ catch( execution_exception const& ex ) {
+ throw setup_error( ex.what() );
+ }
+ }
+ }
+
+ switch( runtime_config::random_seed() ) {
+ case 0:
+ break;
+ case 1: {
+ unsigned int seed = static_cast<unsigned int>( std::time( 0 ) );
+ BOOST_TEST_MESSAGE( "Test cases order is shuffled using seed: " << seed );
+ std::srand( seed );
+ break;
+ }
+ default:
+ BOOST_TEST_MESSAGE( "Test cases order is shuffled using seed: " << runtime_config::random_seed() );
+ std::srand( runtime_config::random_seed() );
+ }
+
+ try {
+ traverse_test_tree( id, s_frk_impl() );
+ }
+ catch( test_being_aborted const& ) {
+ // abort already reported
+ }
+
+ if( call_start_finish ) {
+ BOOST_TEST_FOREACH( test_observer*, to, s_frk_impl().m_observers )
+ to->test_finish();
+ }
+
+ s_frk_impl().m_test_in_progress = was_in_progress;
+}
+
+//____________________________________________________________________________//
+
+void
+run( test_unit const* tu, bool continue_test )
+{
+ run( tu->p_id, continue_test );
+}
+
+//____________________________________________________________________________//
+
+void
+assertion_result( bool passed )
+{
+ BOOST_TEST_FOREACH( test_observer*, to, s_frk_impl().m_observers )
+ to->assertion_result( passed );
+}
+
+//____________________________________________________________________________//
+
+void
+exception_caught( execution_exception const& ex )
+{
+ BOOST_TEST_FOREACH( test_observer*, to, s_frk_impl().m_observers )
+ to->exception_caught( ex );
+}
+
+//____________________________________________________________________________//
+
+void
+test_unit_aborted( test_unit const& tu )
+{
+ BOOST_TEST_FOREACH( test_observer*, to, s_frk_impl().m_observers )
+ to->test_unit_aborted( tu );
+}
+
+//____________________________________________________________________________//
+
+} // namespace framework
+
+} // namespace unit_test
+
+} // namespace ndnboost
+
+//____________________________________________________________________________//
+
+#include <ndnboost/test/detail/enable_warnings.hpp>
+
+#endif // BOOST_TEST_FRAMEWORK_IPP_021005GER
diff --git a/ndnboost/test/impl/interaction_based.ipp b/ndnboost/test/impl/interaction_based.ipp
new file mode 100644
index 0000000..03ee9be
--- /dev/null
+++ b/ndnboost/test/impl/interaction_based.ipp
@@ -0,0 +1,90 @@
+// (C) Copyright Gennadiy Rozental 2005-2008.
+// Use, modification, and distribution are subject to the
+// Boost Software License, Version 1.0. (See accompanying file
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// See http://www.boost.org/libs/test for the library home page.
+//
+// File : $RCSfile$
+//
+// Version : $Revision: 54633 $
+//
+// Description : Facilities to perform interaction-based testing
+// ***************************************************************************
+
+#ifndef BOOST_TEST_INTERACTION_BASED_IPP_112105GER
+#define BOOST_TEST_INTERACTION_BASED_IPP_112105GER
+
+// Boost.Test
+#include <ndnboost/test/detail/config.hpp>
+
+#if BOOST_TEST_SUPPORT_INTERACTION_TESTING
+
+// Boost.Test
+#include <ndnboost/test/detail/config.hpp>
+#include <ndnboost/test/utils/callback.hpp>
+#include <ndnboost/test/interaction_based.hpp>
+#include <ndnboost/test/mock_object.hpp>
+#include <ndnboost/test/framework.hpp> // for setup_error
+
+#include <ndnboost/test/detail/suppress_warnings.hpp>
+
+// STL
+#include <stdexcept>
+#include <string>
+
+//____________________________________________________________________________//
+
+namespace ndnboost {
+
+namespace itest { // interaction-based testing
+
+// ************************************************************************** //
+// ************** manager ************** //
+// ************************************************************************** //
+
+manager::manager()
+{
+ instance_ptr( true, this );
+}
+
+//____________________________________________________________________________//
+
+manager::~manager()
+{
+ instance_ptr( true );
+}
+
+//____________________________________________________________________________//
+
+manager*
+manager::instance_ptr( bool reset, manager* new_ptr )
+{
+ static manager dummy( 0 );
+
+ static manager* ptr = &dummy;
+
+ if( reset ) {
+ if( new_ptr ) {
+ BOOST_TEST_SETUP_ASSERT( ptr == &dummy, BOOST_TEST_L( "Can't run two interation based test the same time" ) );
+
+ ptr = new_ptr;
+ }
+ else
+ ptr = &dummy;
+ }
+
+ return ptr;
+}
+
+} // namespace itest
+
+} // namespace ndnboost
+
+//____________________________________________________________________________//
+
+#include <ndnboost/test/detail/enable_warnings.hpp>
+
+#endif // not ancient compiler
+
+#endif // BOOST_TEST_INTERACTION_BASED_IPP_112105GER
diff --git a/ndnboost/test/impl/logged_expectations.ipp b/ndnboost/test/impl/logged_expectations.ipp
new file mode 100644
index 0000000..4db7b81
--- /dev/null
+++ b/ndnboost/test/impl/logged_expectations.ipp
@@ -0,0 +1,246 @@
+// (C) Copyright Gennadiy Rozental 2005-2008.
+// Use, modification, and distribution are subject to the
+// Boost Software License, ELOG_VER 1.0. (See accompanying file
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// See http://www.boost.org/libs/test for the library home page.
+//
+// File : $RCSfile$
+//
+// Version : $Revision: 54633 $
+//
+// Description : Facilities to perform interaction based testng of logged expectations
+// ***************************************************************************
+
+#ifndef BOOST_TEST_LOGGED_EXPECTATIONS_IPP_120905GER
+#define BOOST_TEST_LOGGED_EXPECTATIONS_IPP_120905GER
+
+// Boost.Test
+#include <ndnboost/test/detail/config.hpp>
+
+#if BOOST_TEST_SUPPORT_INTERACTION_TESTING
+
+#include <ndnboost/test/detail/global_typedef.hpp>
+
+#include <ndnboost/test/utils/callback.hpp>
+#include <ndnboost/test/utils/iterator/token_iterator.hpp>
+
+#include <ndnboost/test/interaction_based.hpp>
+#include <ndnboost/test/test_tools.hpp>
+
+#include <ndnboost/test/detail/suppress_warnings.hpp>
+
+// Boost
+#include <ndnboost/lexical_cast.hpp>
+
+// STL
+#include <fstream>
+
+//____________________________________________________________________________//
+
+namespace ndnboost {
+
+using namespace ::ndnboost::unit_test;
+
+namespace itest {
+
+// ************************************************************************** //
+// ************** logged expectation test implementation ************** //
+// ************************************************************************** //
+
+struct expectations_logger : itest::manager {
+ // Constructor
+ expectations_logger( const_string log_file_name, bool test_or_log );
+
+ virtual bool decision_point( const_string, std::size_t );
+ virtual unsigned enter_scope( const_string, std::size_t, const_string scope_name );
+ virtual void allocated( const_string, std::size_t, void*, std::size_t s );
+ virtual void data_flow( const_string d );
+ virtual std::string return_value( const_string default_value );
+
+private:
+ // Data members
+ bool m_test_or_log;
+ std::fstream m_log_file;
+};
+
+literal_string ELOG_VER = "1.0";
+literal_string CLMN_SEP = "|";
+static const char LINE_SEP = '\n';
+
+literal_string FILE_SIG = "ELOG";
+literal_string SCOPE_SIG = "SCOPE";
+literal_string ALLOC_SIG = "ALLOC";
+literal_string DP_SIG = "SWITCH";
+literal_string DATA_SIG = "DATA";
+literal_string RETURN_SIG = "RETURN";
+
+//____________________________________________________________________________//
+
+expectations_logger::expectations_logger( const_string log_file_name, bool test_or_log )
+: m_test_or_log( test_or_log )
+{
+ BOOST_REQUIRE_MESSAGE( !log_file_name.is_empty(), "Empty expectations log file name" );
+
+ m_log_file.open( log_file_name.begin(), test_or_log ? std::ios::in : std::ios::out );
+
+ BOOST_REQUIRE_MESSAGE( m_log_file.is_open(),
+ "Can't open expectations log file " << log_file_name
+ << " for " << ( m_test_or_log ? "reading" : "writing") );
+
+ if( m_test_or_log ) {
+ std::string line;
+
+ std::getline( m_log_file, line, LINE_SEP );
+
+ const_string cline( line );
+ string_token_iterator tit( cline, (dropped_delimeters = CLMN_SEP, kept_delimeters = dt_none));
+
+ BOOST_CHECK_EQUAL( *tit, FILE_SIG );
+ ++tit;
+ BOOST_CHECK_EQUAL( *tit, ELOG_VER );
+ }
+ else {
+ m_log_file << FILE_SIG << CLMN_SEP << ELOG_VER << LINE_SEP;
+ }
+}
+
+//____________________________________________________________________________//
+
+bool
+expectations_logger::decision_point( const_string, std::size_t )
+{
+ if( m_test_or_log ) {
+ std::string line;
+
+ std::getline( m_log_file, line, LINE_SEP );
+
+ const_string cline( line );
+ string_token_iterator tit( cline, (dropped_delimeters = CLMN_SEP, kept_delimeters = dt_none));
+
+ BOOST_CHECK_EQUAL( *tit, DP_SIG ); ++tit;
+ return lexical_cast<bool>( *tit );
+ }
+ else {
+ m_log_file << DP_SIG << CLMN_SEP << std::boolalpha << true << LINE_SEP;
+
+ return true;
+ }
+}
+
+//____________________________________________________________________________//
+
+unsigned
+expectations_logger::enter_scope( const_string, std::size_t, const_string scope_name )
+{
+ if( m_test_or_log ) {
+ std::string line;
+
+ std::getline( m_log_file, line, LINE_SEP );
+
+ const_string cline( line );
+ string_token_iterator tit( cline, (dropped_delimeters = CLMN_SEP, kept_delimeters = dt_none));
+
+ BOOST_CHECK_EQUAL( *tit, SCOPE_SIG ); ++tit;
+ BOOST_CHECK_EQUAL( *tit, scope_name );
+ }
+ else {
+ m_log_file << SCOPE_SIG << CLMN_SEP << scope_name << LINE_SEP;
+ }
+
+ return 0;
+}
+
+//____________________________________________________________________________//
+
+void
+expectations_logger::allocated( const_string, std::size_t, void*, std::size_t s )
+{
+ if( m_test_or_log ) {
+ std::string line;
+
+ std::getline( m_log_file, line, LINE_SEP );
+
+ const_string cline( line );
+ string_token_iterator tit( cline, (dropped_delimeters = CLMN_SEP, kept_delimeters = dt_none));
+
+ BOOST_CHECK_EQUAL( *tit, ALLOC_SIG ); ++tit;
+ BOOST_CHECK_EQUAL( lexical_cast<std::size_t>( *tit ), s );
+ }
+ else {
+ m_log_file << ALLOC_SIG << CLMN_SEP << s << LINE_SEP;
+ }
+}
+
+//____________________________________________________________________________//
+
+void
+expectations_logger::data_flow( const_string d )
+{
+ if( m_test_or_log ) {
+ std::string line;
+
+ std::getline( m_log_file, line, LINE_SEP );
+
+ const_string cline( line );
+ string_token_iterator tit( cline, (dropped_delimeters = CLMN_SEP, kept_delimeters = dt_none));
+
+ BOOST_CHECK_EQUAL( *tit, DATA_SIG ); ++tit;
+ BOOST_CHECK_EQUAL( *tit, d );
+ }
+ else {
+ m_log_file << DATA_SIG << CLMN_SEP << d << LINE_SEP;
+ }
+}
+
+//____________________________________________________________________________//
+
+std::string
+expectations_logger::return_value( const_string default_value )
+{
+ if( m_test_or_log ) {
+ std::string line;
+
+ std::getline( m_log_file, line, LINE_SEP );
+
+ const_string cline( line );
+ string_token_iterator tit( cline, (dropped_delimeters = CLMN_SEP, kept_delimeters = dt_none));
+
+ BOOST_CHECK_EQUAL( *tit, RETURN_SIG ); ++tit;
+
+ return std::string( tit->begin(), tit->size() );
+ }
+ else {
+ m_log_file << RETURN_SIG << CLMN_SEP << default_value << LINE_SEP;
+
+ return std::string();
+ }
+}
+
+//____________________________________________________________________________//
+
+// ************************************************************************** //
+// ************** logged expectations test ************** //
+// ************************************************************************** //
+
+void BOOST_TEST_DECL
+logged_expectations( callback0<> const& F, const_string log_file_name, bool test_or_log )
+{
+ expectations_logger el( log_file_name, test_or_log );
+
+ F();
+}
+
+//____________________________________________________________________________//
+
+} // namespace itest
+
+} // namespace ndnboost
+
+//____________________________________________________________________________//
+
+#include <ndnboost/test/detail/enable_warnings.hpp>
+
+#endif // not ancient compiler
+
+#endif // BOOST_TEST_LOGGED_EXPECTATIONS_IPP_120905GER
diff --git a/ndnboost/test/impl/plain_report_formatter.ipp b/ndnboost/test/impl/plain_report_formatter.ipp
new file mode 100644
index 0000000..1f0aaac
--- /dev/null
+++ b/ndnboost/test/impl/plain_report_formatter.ipp
@@ -0,0 +1,198 @@
+// (C) Copyright Gennadiy Rozental 2005-2008.
+// Distributed under 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)
+
+// See http://www.boost.org/libs/test for the library home page.
+//
+// File : $RCSfile$
+//
+// Version : $Revision: 49312 $
+//
+// Description : plain report formatter definition
+// ***************************************************************************
+
+#ifndef BOOST_TEST_PLAIN_REPORT_FORMATTER_IPP_020105GER
+#define BOOST_TEST_PLAIN_REPORT_FORMATTER_IPP_020105GER
+
+// Boost.Test
+#include <ndnboost/test/output/plain_report_formatter.hpp>
+#include <ndnboost/test/utils/custom_manip.hpp>
+#include <ndnboost/test/results_collector.hpp>
+#include <ndnboost/test/unit_test_suite_impl.hpp>
+
+#include <ndnboost/test/utils/basic_cstring/io.hpp>
+
+// STL
+#include <iomanip>
+#include <ndnboost/config/no_tr1/cmath.hpp>
+#include <iostream>
+
+#include <ndnboost/test/detail/suppress_warnings.hpp>
+
+# ifdef BOOST_NO_STDC_NAMESPACE
+namespace std { using ::log10; }
+# endif
+
+//____________________________________________________________________________//
+
+namespace ndnboost {
+
+namespace unit_test {
+
+namespace output {
+
+namespace {
+
+typedef custom_manip<struct quote_t> quote;
+
+template<typename T>
+inline std::ostream&
+operator<<( custom_printer<quote> const& p, T const& value )
+{
+ *p << '"' << value << '"';
+
+ return *p;
+}
+
+//____________________________________________________________________________//
+
+void
+print_stat_value( std::ostream& ostr, counter_t v, counter_t indent, counter_t total,
+ const_string name, const_string res )
+{
+ if( v > 0 ) {
+ ostr << std::setw( indent ) << ""
+ << v << ' ' << name << ( v != 1 ? "s" : "" );
+ if( total > 0 )
+ ostr << " out of " << total;
+
+ ostr << ' ' << res << '\n';
+ }
+}
+
+//____________________________________________________________________________//
+
+} // local namespace
+
+// ************************************************************************** //
+// ************** plain_report_formatter ************** //
+// ************************************************************************** //
+
+void
+plain_report_formatter::results_report_start( std::ostream& ostr )
+{
+ m_indent = 0;
+ ostr << '\n';
+}
+
+//____________________________________________________________________________//
+
+void
+plain_report_formatter::results_report_finish( std::ostream& ostr )
+{
+ ostr.flush();
+}
+
+//____________________________________________________________________________//
+
+void
+plain_report_formatter::test_unit_report_start( test_unit const& tu, std::ostream& ostr )
+{
+ test_results const& tr = results_collector.results( tu.p_id );
+
+ const_string descr;
+
+ if( tr.passed() )
+ descr = "passed";
+ else if( tr.p_skipped )
+ descr = "skipped";
+ else if( tr.p_aborted )
+ descr = "aborted";
+ else
+ descr = "failed";
+
+ ostr << std::setw( m_indent ) << ""
+ << "Test " << (tu.p_type == tut_case ? "case " : "suite " ) << quote() << tu.p_name << ' ' << descr;
+
+ if( tr.p_skipped ) {
+ ostr << " due to " << (tu.check_dependencies() ? "test aborting\n" : "failed dependancy\n" );
+ m_indent += 2;
+ return;
+ }
+
+ counter_t total_assertions = tr.p_assertions_passed + tr.p_assertions_failed;
+ counter_t total_tc = tr.p_test_cases_passed + tr.p_test_cases_failed + tr.p_test_cases_skipped;
+
+ if( total_assertions > 0 || total_tc > 0 )
+ ostr << " with:";
+
+ ostr << '\n';
+ m_indent += 2;
+
+ print_stat_value( ostr, tr.p_assertions_passed, m_indent, total_assertions, "assertion", "passed" );
+ print_stat_value( ostr, tr.p_assertions_failed, m_indent, total_assertions, "assertion", "failed" );
+ print_stat_value( ostr, tr.p_expected_failures, m_indent, 0 , "failure" , "expected" );
+ print_stat_value( ostr, tr.p_test_cases_passed, m_indent, total_tc , "test case", "passed" );
+ print_stat_value( ostr, tr.p_test_cases_failed, m_indent, total_tc , "test case", "failed" );
+ print_stat_value( ostr, tr.p_test_cases_skipped, m_indent, total_tc , "test case", "skipped" );
+ print_stat_value( ostr, tr.p_test_cases_aborted, m_indent, total_tc , "test case", "aborted" );
+
+ ostr << '\n';
+}
+
+//____________________________________________________________________________//
+
+void
+plain_report_formatter::test_unit_report_finish( test_unit const&, std::ostream& )
+{
+ m_indent -= 2;
+}
+
+//____________________________________________________________________________//
+
+void
+plain_report_formatter::do_confirmation_report( test_unit const& tu, std::ostream& ostr )
+{
+ test_results const& tr = results_collector.results( tu.p_id );
+
+ if( tr.passed() ) {
+ ostr << "*** No errors detected\n";
+ return;
+ }
+
+ if( tr.p_skipped ) {
+ ostr << "*** Test " << tu.p_type_name << " skipped due to "
+ << (tu.check_dependencies() ? "test aborting\n" : "failed dependancy\n" );
+ return;
+ }
+
+ if( tr.p_assertions_failed == 0 ) {
+ ostr << "*** errors detected in test " << tu.p_type_name << " " << quote() << tu.p_name
+ << "; see standard output for details\n";
+ return;
+ }
+
+ counter_t num_failures = tr.p_assertions_failed;
+
+ ostr << "*** " << num_failures << " failure" << ( num_failures != 1 ? "s" : "" ) << " detected";
+
+ if( tr.p_expected_failures > 0 )
+ ostr << " (" << tr.p_expected_failures << " failure" << ( tr.p_expected_failures != 1 ? "s" : "" ) << " expected)";
+
+ ostr << " in test " << tu.p_type_name << " " << quote() << tu.p_name << "\n";
+}
+
+//____________________________________________________________________________//
+
+} // namespace output
+
+} // namespace unit_test
+
+} // namespace ndnboost
+
+//____________________________________________________________________________//
+
+#include <ndnboost/test/detail/enable_warnings.hpp>
+
+#endif // BOOST_TEST_PLAIN_REPORT_FORMATTER_IPP_020105GER
diff --git a/ndnboost/test/impl/progress_monitor.ipp b/ndnboost/test/impl/progress_monitor.ipp
new file mode 100644
index 0000000..ac93432
--- /dev/null
+++ b/ndnboost/test/impl/progress_monitor.ipp
@@ -0,0 +1,110 @@
+// (C) Copyright Gennadiy Rozental 2005-2008.
+// Distributed under 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)
+
+// See http://www.boost.org/libs/test for the library home page.
+//
+// File : $RCSfile$
+//
+// Version : $Revision: 57992 $
+//
+// Description : implements simple text based progress monitor
+// ***************************************************************************
+
+#ifndef BOOST_TEST_PROGRESS_MONITOR_IPP_020105GER
+#define BOOST_TEST_PROGRESS_MONITOR_IPP_020105GER
+
+// Boost.Test
+#include <ndnboost/test/progress_monitor.hpp>
+#include <ndnboost/test/unit_test_suite_impl.hpp>
+
+#include <ndnboost/test/detail/unit_test_parameters.hpp>
+
+// Boost
+#include <ndnboost/progress.hpp>
+#include <ndnboost/scoped_ptr.hpp>
+
+#include <ndnboost/test/detail/suppress_warnings.hpp>
+
+//____________________________________________________________________________//
+
+namespace ndnboost {
+
+namespace unit_test {
+
+// ************************************************************************** //
+// ************** progress_monitor ************** //
+// ************************************************************************** //
+
+namespace {
+
+struct progress_monitor_impl {
+ // Constructor
+ progress_monitor_impl()
+ : m_stream( runtime_config::log_sink() )
+ {}
+
+ std::ostream* m_stream;
+ scoped_ptr<progress_display> m_progress_display;
+};
+
+progress_monitor_impl& s_pm_impl() { static progress_monitor_impl the_inst; return the_inst; }
+
+} // local namespace
+
+//____________________________________________________________________________//
+
+void
+progress_monitor_t::test_start( counter_t test_cases_amount )
+{
+ s_pm_impl().m_progress_display.reset( new progress_display( test_cases_amount, *s_pm_impl().m_stream ) );
+}
+
+//____________________________________________________________________________//
+
+void
+progress_monitor_t::test_aborted()
+{
+ (*s_pm_impl().m_progress_display) += s_pm_impl().m_progress_display->count();
+}
+
+//____________________________________________________________________________//
+
+void
+progress_monitor_t::test_unit_finish( test_unit const& tu, unsigned long )
+{
+ if( tu.p_type == tut_case )
+ ++(*s_pm_impl().m_progress_display);
+}
+
+//____________________________________________________________________________//
+
+void
+progress_monitor_t::test_unit_skipped( test_unit const& tu )
+{
+ test_case_counter tcc;
+ traverse_test_tree( tu, tcc );
+
+ (*s_pm_impl().m_progress_display) += tcc.p_count;
+}
+
+//____________________________________________________________________________//
+
+void
+progress_monitor_t::set_stream( std::ostream& ostr )
+{
+ s_pm_impl().m_stream = &ostr;
+}
+
+//____________________________________________________________________________//
+
+} // namespace unit_test
+
+} // namespace ndnboost
+
+//____________________________________________________________________________//
+
+#include <ndnboost/test/detail/enable_warnings.hpp>
+
+#endif // BOOST_TEST_PROGRESS_MONITOR_IPP_020105GER
diff --git a/ndnboost/test/impl/results_collector.ipp b/ndnboost/test/impl/results_collector.ipp
new file mode 100644
index 0000000..7b676cf
--- /dev/null
+++ b/ndnboost/test/impl/results_collector.ipp
@@ -0,0 +1,294 @@
+// (C) Copyright Gennadiy Rozental 2005-2008.
+// Distributed under 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)
+
+// See http://www.boost.org/libs/test for the library home page.
+//
+// File : $RCSfile$
+//
+// Version : $Revision: 57992 $
+//
+// Description : implements Unit Test results collecting facility.
+// ***************************************************************************
+
+#ifndef BOOST_TEST_RESULTS_COLLECTOR_IPP_021105GER
+#define BOOST_TEST_RESULTS_COLLECTOR_IPP_021105GER
+
+// Boost.Test
+#include <ndnboost/test/unit_test_suite_impl.hpp>
+#include <ndnboost/test/unit_test_log.hpp>
+#include <ndnboost/test/results_collector.hpp>
+#include <ndnboost/test/framework.hpp>
+
+// Boost
+#include <ndnboost/cstdlib.hpp>
+
+// STL
+#include <map>
+
+#include <ndnboost/test/detail/suppress_warnings.hpp>
+
+//____________________________________________________________________________//
+
+namespace ndnboost {
+
+namespace unit_test {
+
+// ************************************************************************** //
+// ************** test_results ************** //
+// ************************************************************************** //
+
+test_results::test_results()
+{
+ clear();
+}
+
+//____________________________________________________________________________//
+
+bool
+test_results::passed() const
+{
+ return !p_skipped &&
+ p_test_cases_failed == 0 &&
+ p_assertions_failed <= p_expected_failures &&
+ !p_aborted;
+}
+
+//____________________________________________________________________________//
+
+int
+test_results::result_code() const
+{
+ return passed() ? exit_success
+ : ( (p_assertions_failed > p_expected_failures || p_skipped )
+ ? exit_test_failure
+ : exit_exception_failure );
+}
+
+//____________________________________________________________________________//
+
+void
+test_results::operator+=( test_results const& tr )
+{
+ p_assertions_passed.value += tr.p_assertions_passed;
+ p_assertions_failed.value += tr.p_assertions_failed;
+ p_test_cases_passed.value += tr.p_test_cases_passed;
+ p_test_cases_failed.value += tr.p_test_cases_failed;
+ p_test_cases_skipped.value += tr.p_test_cases_skipped;
+ p_test_cases_aborted.value += tr.p_test_cases_aborted;
+}
+
+//____________________________________________________________________________//
+
+void
+test_results::clear()
+{
+ p_assertions_passed.value = 0;
+ p_assertions_failed.value = 0;
+ p_expected_failures.value = 0;
+ p_test_cases_passed.value = 0;
+ p_test_cases_failed.value = 0;
+ p_test_cases_skipped.value = 0;
+ p_test_cases_aborted.value = 0;
+ p_aborted.value = false;
+ p_skipped.value = true;
+}
+
+//____________________________________________________________________________//
+
+// ************************************************************************** //
+// ************** results_collector ************** //
+// ************************************************************************** //
+
+#if !BOOST_WORKAROUND(BOOST_MSVC, <1300)
+
+namespace {
+
+struct results_collector_impl {
+ std::map<test_unit_id,test_results> m_results_store;
+};
+
+results_collector_impl& s_rc_impl() { static results_collector_impl the_inst; return the_inst; }
+
+} // local namespace
+
+#else
+
+struct results_collector_impl {
+ std::map<test_unit_id,test_results> m_results_store;
+};
+
+static results_collector_impl& s_rc_impl() { static results_collector_impl the_inst; return the_inst; }
+
+#endif
+
+//____________________________________________________________________________//
+
+void
+results_collector_t::test_start( counter_t )
+{
+ s_rc_impl().m_results_store.clear();
+}
+
+//____________________________________________________________________________//
+
+void
+results_collector_t::test_finish()
+{
+ // do nothing
+}
+
+//____________________________________________________________________________//
+
+void
+results_collector_t::test_aborted()
+{
+ // do nothing
+}
+
+//____________________________________________________________________________//
+
+void
+results_collector_t::test_unit_start( test_unit const& tu )
+{
+ // init test_results entry
+ test_results& tr = s_rc_impl().m_results_store[tu.p_id];
+
+ tr.clear();
+
+ tr.p_expected_failures.value = tu.p_expected_failures;
+ tr.p_skipped.value = false;
+}
+
+//____________________________________________________________________________//
+
+class results_collect_helper : public test_tree_visitor {
+public:
+ explicit results_collect_helper( test_results& tr, test_unit const& ts ) : m_tr( tr ), m_ts( ts ) {}
+
+ void visit( test_case const& tc )
+ {
+ test_results const& tr = results_collector.results( tc.p_id );
+ m_tr += tr;
+
+ if( tr.passed() )
+ m_tr.p_test_cases_passed.value++;
+ else if( tr.p_skipped )
+ m_tr.p_test_cases_skipped.value++;
+ else {
+ if( tr.p_aborted )
+ m_tr.p_test_cases_aborted.value++;
+ m_tr.p_test_cases_failed.value++;
+ }
+ }
+ bool test_suite_start( test_suite const& ts )
+ {
+ if( m_ts.p_id == ts.p_id )
+ return true;
+ else {
+ m_tr += results_collector.results( ts.p_id );
+ return false;
+ }
+ }
+
+private:
+ // Data members
+ test_results& m_tr;
+ test_unit const& m_ts;
+};
+
+//____________________________________________________________________________//
+
+void
+results_collector_t::test_unit_finish( test_unit const& tu, unsigned long )
+{
+ if( tu.p_type == tut_suite ) {
+ results_collect_helper ch( s_rc_impl().m_results_store[tu.p_id], tu );
+
+ traverse_test_tree( tu, ch );
+ }
+ else {
+ test_results const& tr = s_rc_impl().m_results_store[tu.p_id];
+
+ bool num_failures_match = tr.p_aborted || tr.p_assertions_failed >= tr.p_expected_failures;
+ if( !num_failures_match )
+ BOOST_TEST_MESSAGE( "Test case " << tu.p_name << " has fewer failures than expected" );
+
+ bool check_any_assertions = tr.p_aborted || (tr.p_assertions_failed != 0) || (tr.p_assertions_passed != 0);
+ if( !check_any_assertions )
+ BOOST_TEST_MESSAGE( "Test case " << tu.p_name << " did not check any assertions" );
+ }
+}
+
+//____________________________________________________________________________//
+
+void
+results_collector_t::test_unit_skipped( test_unit const& tu )
+{
+ if( tu.p_type == tut_suite ) {
+ test_case_counter tcc;
+ traverse_test_tree( tu, tcc );
+
+ test_results& tr = s_rc_impl().m_results_store[tu.p_id];
+
+ tr.clear();
+
+ tr.p_skipped.value = true;
+ tr.p_test_cases_skipped.value = tcc.p_count;
+ }
+}
+
+//____________________________________________________________________________//
+
+void
+results_collector_t::assertion_result( bool passed )
+{
+ test_results& tr = s_rc_impl().m_results_store[framework::current_test_case().p_id];
+
+ if( passed )
+ tr.p_assertions_passed.value++;
+ else
+ tr.p_assertions_failed.value++;
+
+ if( tr.p_assertions_failed == 1 )
+ first_failed_assertion();
+}
+
+//____________________________________________________________________________//
+
+void
+results_collector_t::exception_caught( execution_exception const& )
+{
+ test_results& tr = s_rc_impl().m_results_store[framework::current_test_case().p_id];
+
+ tr.p_assertions_failed.value++;
+}
+
+//____________________________________________________________________________//
+
+void
+results_collector_t::test_unit_aborted( test_unit const& tu )
+{
+ s_rc_impl().m_results_store[tu.p_id].p_aborted.value = true;
+}
+
+//____________________________________________________________________________//
+
+test_results const&
+results_collector_t::results( test_unit_id id ) const
+{
+ return s_rc_impl().m_results_store[id];
+}
+
+//____________________________________________________________________________//
+
+} // namespace unit_test
+
+} // namespace ndnboost
+
+//____________________________________________________________________________//
+
+#include <ndnboost/test/detail/enable_warnings.hpp>
+
+#endif // BOOST_TEST_RESULTS_COLLECTOR_IPP_021105GER
diff --git a/ndnboost/test/impl/results_reporter.ipp b/ndnboost/test/impl/results_reporter.ipp
new file mode 100644
index 0000000..1009a3d
--- /dev/null
+++ b/ndnboost/test/impl/results_reporter.ipp
@@ -0,0 +1,202 @@
+// (C) Copyright Gennadiy Rozental 2005-2008.
+// Distributed under 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)
+
+// See http://www.boost.org/libs/test for the library home page.
+//
+// File : $RCSfile$
+//
+// Version : $Revision: 57992 $
+//
+// Description : result reporting facilties
+// ***************************************************************************
+
+#ifndef BOOST_TEST_RESULTS_REPORTER_IPP_020105GER
+#define BOOST_TEST_RESULTS_REPORTER_IPP_020105GER
+
+// Boost.Test
+#include <ndnboost/test/results_reporter.hpp>
+#include <ndnboost/test/unit_test_suite_impl.hpp>
+#include <ndnboost/test/results_collector.hpp>
+#include <ndnboost/test/framework.hpp>
+#include <ndnboost/test/output/plain_report_formatter.hpp>
+#include <ndnboost/test/output/xml_report_formatter.hpp>
+
+#include <ndnboost/test/detail/unit_test_parameters.hpp>
+
+// Boost
+#include <ndnboost/scoped_ptr.hpp>
+#include <ndnboost/io/ios_state.hpp>
+typedef ::ndnboost::io::ios_base_all_saver io_saver_type;
+
+// STL
+#include <iostream>
+
+#include <ndnboost/test/detail/suppress_warnings.hpp>
+
+//____________________________________________________________________________//
+
+namespace ndnboost {
+
+namespace unit_test {
+
+namespace results_reporter {
+
+// ************************************************************************** //
+// ************** result reporter implementation ************** //
+// ************************************************************************** //
+
+namespace {
+
+struct results_reporter_impl : test_tree_visitor {
+ // Constructor
+ results_reporter_impl()
+ : m_output( runtime_config::report_sink() )
+ , m_stream_state_saver( new io_saver_type( *m_output ) )
+ , m_report_level( CONFIRMATION_REPORT )
+ , m_formatter( new output::plain_report_formatter )
+ {}
+
+ // test tree visitor interface implementation
+ void visit( test_case const& tc )
+ {
+ m_formatter->test_unit_report_start( tc, *m_output );
+ m_formatter->test_unit_report_finish( tc, *m_output );
+ }
+ bool test_suite_start( test_suite const& ts )
+ {
+ m_formatter->test_unit_report_start( ts, *m_output );
+
+ if( m_report_level == DETAILED_REPORT && !results_collector.results( ts.p_id ).p_skipped )
+ return true;
+
+ m_formatter->test_unit_report_finish( ts, *m_output );
+ return false;
+ }
+ void test_suite_finish( test_suite const& ts )
+ {
+ m_formatter->test_unit_report_finish( ts, *m_output );
+ }
+
+ typedef scoped_ptr<io_saver_type> saver_ptr;
+
+ // Data members
+ std::ostream* m_output;
+ saver_ptr m_stream_state_saver;
+ report_level m_report_level;
+ scoped_ptr<format> m_formatter;
+};
+
+results_reporter_impl& s_rr_impl() { static results_reporter_impl the_inst; return the_inst; }
+
+} // local namespace
+
+// ************************************************************************** //
+// ************** report configuration ************** //
+// ************************************************************************** //
+
+void
+set_level( report_level l )
+{
+ if( l != INV_REPORT_LEVEL )
+ s_rr_impl().m_report_level = l;
+}
+
+//____________________________________________________________________________//
+
+void
+set_stream( std::ostream& ostr )
+{
+ s_rr_impl().m_output = &ostr;
+ s_rr_impl().m_stream_state_saver.reset( new io_saver_type( ostr ) );
+}
+
+//____________________________________________________________________________//
+
+std::ostream&
+get_stream()
+{
+ return *s_rr_impl().m_output;
+}
+
+//____________________________________________________________________________//
+
+void
+set_format( output_format rf )
+{
+ switch( rf ) {
+ case CLF:
+ set_format( new output::plain_report_formatter );
+ break;
+ case XML:
+ set_format( new output::xml_report_formatter );
+ break;
+ default:
+ break;
+ }
+}
+
+//____________________________________________________________________________//
+
+void
+set_format( results_reporter::format* f )
+{
+ if( f )
+ s_rr_impl().m_formatter.reset( f );
+}
+
+//____________________________________________________________________________//
+
+// ************************************************************************** //
+// ************** report initiation ************** //
+// ************************************************************************** //
+
+void
+make_report( report_level l, test_unit_id id )
+{
+ if( l == INV_REPORT_LEVEL )
+ l = s_rr_impl().m_report_level;
+
+ if( l == NO_REPORT )
+ return;
+
+ if( id == INV_TEST_UNIT_ID )
+ id = framework::master_test_suite().p_id;
+
+ s_rr_impl().m_stream_state_saver->restore();
+
+ report_level bkup = s_rr_impl().m_report_level;
+ s_rr_impl().m_report_level = l;
+
+ s_rr_impl().m_formatter->results_report_start( *s_rr_impl().m_output );
+
+ switch( l ) {
+ case CONFIRMATION_REPORT:
+ s_rr_impl().m_formatter->do_confirmation_report( framework::get<test_unit>( id ), *s_rr_impl().m_output );
+ break;
+ case SHORT_REPORT:
+ case DETAILED_REPORT:
+ traverse_test_tree( id, s_rr_impl() );
+ break;
+ default:
+ break;
+ }
+
+ s_rr_impl().m_formatter->results_report_finish( *s_rr_impl().m_output );
+ s_rr_impl().m_report_level = bkup;
+}
+
+//____________________________________________________________________________//
+
+} // namespace results_reporter
+
+} // namespace unit_test
+
+} // namespace ndnboost
+
+//____________________________________________________________________________//
+
+#include <ndnboost/test/detail/enable_warnings.hpp>
+
+#endif // BOOST_TEST_RESULTS_REPORTER_IPP_020105GER
diff --git a/ndnboost/test/impl/test_main.ipp b/ndnboost/test/impl/test_main.ipp
new file mode 100644
index 0000000..5991f1c
--- /dev/null
+++ b/ndnboost/test/impl/test_main.ipp
@@ -0,0 +1,68 @@
+// (C) Copyright Gennadiy Rozental 2001-2008.
+// (C) Copyright Beman Dawes 1995-2001.
+// Distributed under 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)
+
+// See http://www.boost.org/libs/test for the library home page.
+//
+// File : $RCSfile$
+//
+// Version : $$Revision: 49312 $
+//
+// Description : implements main function for Test Execution Monitor.
+// ***************************************************************************
+
+#ifndef BOOST_TEST_TEST_MAIN_IPP_012205GER
+#define BOOST_TEST_TEST_MAIN_IPP_012205GER
+
+// Boost.Test
+#include <ndnboost/test/framework.hpp>
+#include <ndnboost/test/test_tools.hpp>
+#include <ndnboost/test/unit_test_suite.hpp>
+
+// Boost
+#include <ndnboost/cstdlib.hpp>
+
+#include <ndnboost/test/detail/suppress_warnings.hpp>
+
+//____________________________________________________________________________//
+
+extern int test_main( int argc, char* argv[] ); // prototype for user's test_main()
+
+struct test_main_caller {
+ test_main_caller( int argc, char** argv ) : m_argc( argc ), m_argv( argv ) {}
+
+ void operator()() {
+ int test_main_result = test_main( m_argc, m_argv );
+
+ // translate a test_main non-success return into a test error
+ BOOST_CHECK( test_main_result == 0 || test_main_result == ndnboost::exit_success );
+ }
+
+private:
+ // Data members
+ int m_argc;
+ char** m_argv;
+};
+
+// ************************************************************************** //
+// ************** test main ************** //
+// ************************************************************************** //
+
+::ndnboost::unit_test::test_suite*
+init_unit_test_suite( int argc, char* argv[] ) {
+ using namespace ::ndnboost::unit_test;
+
+ framework::master_test_suite().p_name.value = "Test Program";
+
+ framework::master_test_suite().add( BOOST_TEST_CASE( test_main_caller( argc, argv ) ) );
+
+ return 0;
+}
+
+//____________________________________________________________________________//
+
+#include <ndnboost/test/detail/enable_warnings.hpp>
+
+#endif // BOOST_TEST_TEST_MAIN_IPP_012205GER
diff --git a/ndnboost/test/impl/test_tools.ipp b/ndnboost/test/impl/test_tools.ipp
new file mode 100644
index 0000000..b47ef81
--- /dev/null
+++ b/ndnboost/test/impl/test_tools.ipp
@@ -0,0 +1,628 @@
+// (C) Copyright Gennadiy Rozental 2005-2008.
+// Distributed under 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)
+
+// See http://www.boost.org/libs/test for the library home page.
+//
+// File : $RCSfile$
+//
+// Version : $Revision: 54633 $
+//
+// Description : supplies offline implementation for the Test Tools
+// ***************************************************************************
+
+#ifndef BOOST_TEST_TEST_TOOLS_IPP_012205GER
+#define BOOST_TEST_TEST_TOOLS_IPP_012205GER
+
+// Boost.Test
+#include <ndnboost/test/test_tools.hpp>
+#include <ndnboost/test/unit_test_log.hpp>
+#include <ndnboost/test/output_test_stream.hpp>
+#include <ndnboost/test/framework.hpp>
+#include <ndnboost/test/execution_monitor.hpp> // execution_aborted
+#include <ndnboost/test/unit_test_suite_impl.hpp>
+
+// Boost
+#include <ndnboost/config.hpp>
+
+// STL
+#include <fstream>
+#include <string>
+#include <cstring>
+#include <cctype>
+#include <cwchar>
+#include <stdexcept>
+#include <ios>
+
+// !! should we use #include <cstdarg>
+#include <stdarg.h>
+
+#include <ndnboost/test/detail/suppress_warnings.hpp>
+
+//____________________________________________________________________________//
+
+# ifdef BOOST_NO_STDC_NAMESPACE
+namespace std { using ::strcmp; using ::strlen; using ::isprint; }
+#if !defined( BOOST_NO_CWCHAR )
+namespace std { using ::wcscmp; }
+#endif
+# endif
+
+namespace ndnboost {
+
+namespace test_tools {
+
+// ************************************************************************** //
+// ************** print_log_value ************** //
+// ************************************************************************** //
+
+void
+print_log_value<char>::operator()( std::ostream& ostr, char t )
+{
+ if( (std::isprint)( static_cast<unsigned char>(t) ) )
+ ostr << '\'' << t << '\'';
+ else
+ ostr << std::hex
+#if BOOST_TEST_USE_STD_LOCALE
+ << std::showbase
+#else
+ << "0x"
+#endif
+ << static_cast<int>(t);
+}
+
+//____________________________________________________________________________//
+
+void
+print_log_value<unsigned char>::operator()( std::ostream& ostr, unsigned char t )
+{
+ ostr << std::hex
+ // showbase is only available for new style streams:
+#if BOOST_TEST_USE_STD_LOCALE
+ << std::showbase
+#else
+ << "0x"
+#endif
+ << static_cast<int>(t);
+}
+
+//____________________________________________________________________________//
+
+void
+print_log_value<char const*>::operator()( std::ostream& ostr, char const* t )
+{
+ ostr << ( t ? t : "null string" );
+}
+
+//____________________________________________________________________________//
+
+void
+print_log_value<wchar_t const*>::operator()( std::ostream& ostr, wchar_t const* t )
+{
+ ostr << ( t ? t : L"null string" );
+}
+
+//____________________________________________________________________________//
+
+namespace tt_detail {
+
+// ************************************************************************** //
+// ************** TOOL BOX Implementation ************** //
+// ************************************************************************** //
+
+using ::ndnboost::unit_test::lazy_ostream;
+
+bool
+check_impl( predicate_result const& pr, lazy_ostream const& check_descr,
+ const_string file_name, std::size_t line_num,
+ tool_level tl, check_type ct,
+ std::size_t num_of_args, ... )
+{
+ using namespace unit_test;
+
+ if( !framework::is_initialized() )
+ throw std::runtime_error( "can't use testing tools before framework is initialized" );
+
+ if( !!pr )
+ tl = PASS;
+
+ log_level ll;
+ char const* prefix;
+ char const* suffix;
+
+ switch( tl ) {
+ case PASS:
+ ll = log_successful_tests;
+ prefix = "check ";
+ suffix = " passed";
+ break;
+ case WARN:
+ ll = log_warnings;
+ prefix = "condition ";
+ suffix = " is not satisfied";
+ break;
+ case CHECK:
+ ll = log_all_errors;
+ prefix = "check ";
+ suffix = " failed";
+ break;
+ case REQUIRE:
+ ll = log_fatal_errors;
+ prefix = "critical check ";
+ suffix = " failed";
+ break;
+ default:
+ return true;
+ }
+
+ switch( ct ) {
+ case CHECK_PRED:
+ unit_test_log << unit_test::log::begin( file_name, line_num )
+ << ll << prefix << check_descr << suffix;
+
+ if( !pr.has_empty_message() )
+ unit_test_log << ". " << pr.message();
+
+ unit_test_log << unit_test::log::end();
+ break;
+
+ case CHECK_MSG:
+ unit_test_log << unit_test::log::begin( file_name, line_num ) << ll;
+
+ if( tl == PASS )
+ unit_test_log << prefix << "'" << check_descr << "'" << suffix;
+ else
+ unit_test_log << check_descr;
+
+ if( !pr.has_empty_message() )
+ unit_test_log << ". " << pr.message();
+
+ unit_test_log << unit_test::log::end();
+ break;
+
+ case CHECK_EQUAL:
+ case CHECK_NE:
+ case CHECK_LT:
+ case CHECK_LE:
+ case CHECK_GT:
+ case CHECK_GE: {
+ static char const* check_str [] = { " == ", " != ", " < " , " <= ", " > " , " >= " };
+ static char const* rever_str [] = { " != ", " == ", " >= ", " > " , " <= ", " < " };
+
+ va_list args;
+
+ va_start( args, num_of_args );
+ char const* arg1_descr = va_arg( args, char const* );
+ lazy_ostream const* arg1_val = va_arg( args, lazy_ostream const* );
+ char const* arg2_descr = va_arg( args, char const* );
+ lazy_ostream const* arg2_val = va_arg( args, lazy_ostream const* );
+
+ unit_test_log << unit_test::log::begin( file_name, line_num )
+ << ll << prefix << arg1_descr << check_str[ct-CHECK_EQUAL] << arg2_descr << suffix;
+
+ if( tl != PASS )
+ unit_test_log << " [" << *arg1_val << rever_str[ct-CHECK_EQUAL] << *arg2_val << "]" ;
+
+ va_end( args );
+
+ if( !pr.has_empty_message() )
+ unit_test_log << ". " << pr.message();
+
+ unit_test_log << unit_test::log::end();
+ break;
+ }
+
+ case CHECK_CLOSE:
+ case CHECK_CLOSE_FRACTION: {
+ va_list args;
+
+ va_start( args, num_of_args );
+ char const* arg1_descr = va_arg( args, char const* );
+ lazy_ostream const* arg1_val = va_arg( args, lazy_ostream const* );
+ char const* arg2_descr = va_arg( args, char const* );
+ lazy_ostream const* arg2_val = va_arg( args, lazy_ostream const* );
+ /* toler_descr = */ va_arg( args, char const* );
+ lazy_ostream const* toler_val = va_arg( args, lazy_ostream const* );
+
+ unit_test_log << unit_test::log::begin( file_name, line_num ) << ll;
+
+ unit_test_log << "difference{" << pr.message() << (ct == CHECK_CLOSE ? "%" : "")
+ << "} between " << arg1_descr << "{" << *arg1_val
+ << "} and " << arg2_descr << "{" << *arg2_val
+ << ( tl == PASS ? "} doesn't exceed " : "} exceeds " )
+ << *toler_val;
+ if( ct == CHECK_CLOSE )
+ unit_test_log << "%";
+
+ va_end( args );
+
+ unit_test_log << unit_test::log::end();
+ break;
+ }
+ case CHECK_SMALL: {
+ va_list args;
+
+ va_start( args, num_of_args );
+ char const* arg1_descr = va_arg( args, char const* );
+ lazy_ostream const* arg1_val = va_arg( args, lazy_ostream const* );
+ /* toler_descr = */ va_arg( args, char const* );
+ lazy_ostream const* toler_val = va_arg( args, lazy_ostream const* );
+
+ unit_test_log << unit_test::log::begin( file_name, line_num ) << ll;
+
+ unit_test_log << "absolute value of " << arg1_descr << "{" << *arg1_val << "}"
+ << ( tl == PASS ? " doesn't exceed " : " exceeds " )
+ << *toler_val;
+
+ va_end( args );
+
+ if( !pr.has_empty_message() )
+ unit_test_log << ". " << pr.message();
+
+ unit_test_log << unit_test::log::end();
+ break;
+ }
+
+ case CHECK_PRED_WITH_ARGS: {
+ unit_test_log << unit_test::log::begin( file_name, line_num )
+ << ll << prefix << check_descr;
+
+ // print predicate call description
+ {
+ va_list args;
+ va_start( args, num_of_args );
+
+ unit_test_log << "( ";
+ for( std::size_t i = 0; i < num_of_args; ++i ) {
+ unit_test_log << va_arg( args, char const* );
+ va_arg( args, lazy_ostream const* ); // skip argument value;
+
+ if( i != num_of_args-1 )
+ unit_test_log << ", ";
+ }
+ unit_test_log << " )" << suffix;
+ va_end( args );
+ }
+
+ if( tl != PASS ) {
+ va_list args;
+ va_start( args, num_of_args );
+
+ unit_test_log << " for ( ";
+ for( std::size_t i = 0; i < num_of_args; ++i ) {
+ va_arg( args, char const* ); // skip argument description;
+ unit_test_log << *va_arg( args, lazy_ostream const* );
+
+ if( i != num_of_args-1 )
+ unit_test_log << ", ";
+ }
+ unit_test_log << " )";
+ va_end( args );
+ }
+
+ if( !pr.has_empty_message() )
+ unit_test_log << ". " << pr.message();
+
+ unit_test_log << unit_test::log::end();
+ break;
+ }
+
+ case CHECK_EQUAL_COLL: {
+ va_list args;
+
+ va_start( args, num_of_args );
+ char const* left_begin_descr = va_arg( args, char const* );
+ char const* left_end_descr = va_arg( args, char const* );
+ char const* right_begin_descr = va_arg( args, char const* );
+ char const* right_end_descr = va_arg( args, char const* );
+
+ unit_test_log << unit_test::log::begin( file_name, line_num )
+ << ll << prefix
+ << "{ " << left_begin_descr << ", " << left_end_descr << " } == { "
+ << right_begin_descr << ", " << right_end_descr << " }"
+ << suffix;
+
+ va_end( args );
+
+ if( !pr.has_empty_message() )
+ unit_test_log << ". " << pr.message();
+
+ unit_test_log << unit_test::log::end();
+ break;
+ }
+
+ case CHECK_BITWISE_EQUAL: {
+ va_list args;
+
+ va_start( args, num_of_args );
+ char const* left_descr = va_arg( args, char const* );
+ char const* right_descr = va_arg( args, char const* );
+
+ unit_test_log << unit_test::log::begin( file_name, line_num )
+ << ll << prefix << left_descr << " =.= " << right_descr << suffix;
+
+ va_end( args );
+
+ if( !pr.has_empty_message() )
+ unit_test_log << ". " << pr.message();
+
+ unit_test_log << unit_test::log::end();
+ break;
+ }
+ }
+
+ switch( tl ) {
+ case PASS:
+ framework::assertion_result( true );
+ return true;
+
+ case WARN:
+ return false;
+
+ case CHECK:
+ framework::assertion_result( false );
+ return false;
+
+ case REQUIRE:
+ framework::assertion_result( false );
+
+ framework::test_unit_aborted( framework::current_test_case() );
+
+ throw execution_aborted();
+ }
+
+ return true;
+}
+
+//____________________________________________________________________________//
+
+predicate_result
+equal_impl( char const* left, char const* right )
+{
+ return (left && right) ? std::strcmp( left, right ) == 0 : (left == right);
+}
+
+//____________________________________________________________________________//
+
+#if !defined( BOOST_NO_CWCHAR )
+
+predicate_result
+equal_impl( wchar_t const* left, wchar_t const* right )
+{
+ return (left && right) ? std::wcscmp( left, right ) == 0 : (left == right);
+}
+
+#endif // !defined( BOOST_NO_CWCHAR )
+
+//____________________________________________________________________________//
+
+bool
+is_defined_impl( const_string symbol_name, const_string symbol_value )
+{
+ symbol_value.trim_left( 2 );
+ return symbol_name != symbol_value;
+}
+
+//____________________________________________________________________________//
+
+} // namespace tt_detail
+
+// ************************************************************************** //
+// ************** output_test_stream ************** //
+// ************************************************************************** //
+
+struct output_test_stream::Impl
+{
+ std::fstream m_pattern;
+ bool m_match_or_save;
+ bool m_text_or_binary;
+ std::string m_synced_string;
+
+ char get_char()
+ {
+ char res;
+ do {
+ m_pattern.get( res );
+ } while( m_text_or_binary && res == '\r' && !m_pattern.fail() && !m_pattern.eof() );
+
+ return res;
+ }
+
+ void check_and_fill( predicate_result& res )
+ {
+ if( !res.p_predicate_value )
+ res.message() << "Output content: \"" << m_synced_string << '\"';
+ }
+};
+
+//____________________________________________________________________________//
+
+output_test_stream::output_test_stream( const_string pattern_file_name, bool match_or_save, bool text_or_binary )
+: m_pimpl( new Impl )
+{
+ if( !pattern_file_name.is_empty() ) {
+ std::ios::openmode m = match_or_save ? std::ios::in : std::ios::out;
+ if( !text_or_binary )
+ m |= std::ios::binary;
+
+ m_pimpl->m_pattern.open( pattern_file_name.begin(), m );
+
+ BOOST_WARN_MESSAGE( m_pimpl->m_pattern.is_open(),
+ "Can't open pattern file " << pattern_file_name
+ << " for " << (match_or_save ? "reading" : "writing") );
+ }
+
+ m_pimpl->m_match_or_save = match_or_save;
+ m_pimpl->m_text_or_binary = text_or_binary;
+}
+
+//____________________________________________________________________________//
+
+output_test_stream::~output_test_stream()
+{
+ delete m_pimpl;
+}
+
+//____________________________________________________________________________//
+
+predicate_result
+output_test_stream::is_empty( bool flush_stream )
+{
+ sync();
+
+ result_type res( m_pimpl->m_synced_string.empty() );
+
+ m_pimpl->check_and_fill( res );
+
+ if( flush_stream )
+ flush();
+
+ return res;
+}
+
+//____________________________________________________________________________//
+
+predicate_result
+output_test_stream::check_length( std::size_t length_, bool flush_stream )
+{
+ sync();
+
+ result_type res( m_pimpl->m_synced_string.length() == length_ );
+
+ m_pimpl->check_and_fill( res );
+
+ if( flush_stream )
+ flush();
+
+ return res;
+}
+
+//____________________________________________________________________________//
+
+predicate_result
+output_test_stream::is_equal( const_string arg, bool flush_stream )
+{
+ sync();
+
+ result_type res( const_string( m_pimpl->m_synced_string ) == arg );
+
+ m_pimpl->check_and_fill( res );
+
+ if( flush_stream )
+ flush();
+
+ return res;
+}
+
+//____________________________________________________________________________//
+
+predicate_result
+output_test_stream::match_pattern( bool flush_stream )
+{
+ sync();
+
+ result_type result( true );
+
+ if( !m_pimpl->m_pattern.is_open() ) {
+ result = false;
+ result.message() << "Pattern file can't be opened!";
+ }
+ else {
+ if( m_pimpl->m_match_or_save ) {
+ for ( std::string::size_type i = 0; i < m_pimpl->m_synced_string.length(); ++i ) {
+ char c = m_pimpl->get_char();
+
+ result = !m_pimpl->m_pattern.fail() &&
+ !m_pimpl->m_pattern.eof() &&
+ (m_pimpl->m_synced_string[i] == c);
+
+ if( !result ) {
+ std::string::size_type suffix_size = (std::min)( m_pimpl->m_synced_string.length() - i,
+ static_cast<std::string::size_type>(5) );
+
+ // try to log area around the mismatch
+ result.message() << "Mismatch at position " << i << '\n'
+ << "..." << m_pimpl->m_synced_string.substr( i, suffix_size ) << "..." << '\n'
+ << "..." << c;
+
+ std::string::size_type counter = suffix_size;
+ while( --counter ) {
+ char c = m_pimpl->get_char();
+
+ if( m_pimpl->m_pattern.fail() || m_pimpl->m_pattern.eof() )
+ break;
+
+ result.message() << c;
+ }
+
+ result.message() << "...";
+
+ // skip rest of the bytes. May help for further matching
+ m_pimpl->m_pattern.ignore(
+ static_cast<std::streamsize>( m_pimpl->m_synced_string.length() - i - suffix_size) );
+ break;
+ }
+ }
+ }
+ else {
+ m_pimpl->m_pattern.write( m_pimpl->m_synced_string.c_str(),
+ static_cast<std::streamsize>( m_pimpl->m_synced_string.length() ) );
+ m_pimpl->m_pattern.flush();
+ }
+ }
+
+ if( flush_stream )
+ flush();
+
+ return result;
+}
+
+//____________________________________________________________________________//
+
+void
+output_test_stream::flush()
+{
+ m_pimpl->m_synced_string.erase();
+
+#ifndef BOOST_NO_STRINGSTREAM
+ str( std::string() );
+#else
+ seekp( 0, std::ios::beg );
+#endif
+}
+
+//____________________________________________________________________________//
+
+std::size_t
+output_test_stream::length()
+{
+ sync();
+
+ return m_pimpl->m_synced_string.length();
+}
+
+//____________________________________________________________________________//
+
+void
+output_test_stream::sync()
+{
+#ifdef BOOST_NO_STRINGSTREAM
+ m_pimpl->m_synced_string.assign( str(), pcount() );
+ freeze( false );
+#else
+ m_pimpl->m_synced_string = str();
+#endif
+}
+
+//____________________________________________________________________________//
+
+} // namespace test_tools
+
+} // namespace ndnboost
+
+//____________________________________________________________________________//
+
+#include <ndnboost/test/detail/enable_warnings.hpp>
+
+#endif // BOOST_TEST_TEST_TOOLS_IPP_012205GER
diff --git a/ndnboost/test/impl/unit_test_log.ipp b/ndnboost/test/impl/unit_test_log.ipp
new file mode 100644
index 0000000..63d089e
--- /dev/null
+++ b/ndnboost/test/impl/unit_test_log.ipp
@@ -0,0 +1,444 @@
+// (C) Copyright Gennadiy Rozental 2005-2008.
+// Distributed under 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)
+
+// See http://www.boost.org/libs/test for the library home page.
+//
+// File : $RCSfile$
+//
+// Version : $Revision: 57992 $
+//
+// Description : implemets Unit Test Log
+// ***************************************************************************
+
+#ifndef BOOST_TEST_UNIT_TEST_LOG_IPP_012205GER
+#define BOOST_TEST_UNIT_TEST_LOG_IPP_012205GER
+
+// Boost.Test
+#include <ndnboost/test/unit_test_log.hpp>
+#include <ndnboost/test/unit_test_log_formatter.hpp>
+#include <ndnboost/test/unit_test_suite_impl.hpp>
+#include <ndnboost/test/execution_monitor.hpp>
+
+#include <ndnboost/test/detail/unit_test_parameters.hpp>
+
+#include <ndnboost/test/utils/basic_cstring/compare.hpp>
+
+#include <ndnboost/test/output/compiler_log_formatter.hpp>
+#include <ndnboost/test/output/xml_log_formatter.hpp>
+
+// Boost
+#include <ndnboost/scoped_ptr.hpp>
+#include <ndnboost/io/ios_state.hpp>
+typedef ::ndnboost::io::ios_base_all_saver io_saver_type;
+
+#include <ndnboost/test/detail/suppress_warnings.hpp>
+
+//____________________________________________________________________________//
+
+namespace ndnboost {
+
+namespace unit_test {
+
+// ************************************************************************** //
+// ************** entry_value_collector ************** //
+// ************************************************************************** //
+
+namespace ut_detail {
+
+entry_value_collector const&
+entry_value_collector::operator<<( lazy_ostream const& v ) const
+{
+ unit_test_log << v;
+
+ return *this;
+}
+
+//____________________________________________________________________________//
+
+entry_value_collector const&
+entry_value_collector::operator<<( const_string v ) const
+{
+ unit_test_log << v;
+
+ return *this;
+}
+
+//____________________________________________________________________________//
+
+entry_value_collector::~entry_value_collector()
+{
+ if( m_last )
+ unit_test_log << log::end();
+}
+
+//____________________________________________________________________________//
+
+} // namespace ut_detail
+
+// ************************************************************************** //
+// ************** unit_test_log ************** //
+// ************************************************************************** //
+
+namespace {
+
+struct unit_test_log_impl {
+ // Constructor
+ unit_test_log_impl()
+ : m_stream( runtime_config::log_sink() )
+ , m_stream_state_saver( new io_saver_type( *m_stream ) )
+ , m_threshold_level( log_all_errors )
+ , m_log_formatter( new output::compiler_log_formatter )
+ {
+ }
+
+ // log data
+ typedef scoped_ptr<unit_test_log_formatter> formatter_ptr;
+ typedef scoped_ptr<io_saver_type> saver_ptr;
+
+ std::ostream* m_stream;
+ saver_ptr m_stream_state_saver;
+ log_level m_threshold_level;
+ formatter_ptr m_log_formatter;
+
+ // entry data
+ bool m_entry_in_progress;
+ bool m_entry_started;
+ log_entry_data m_entry_data;
+
+ // check point data
+ log_checkpoint_data m_checkpoint_data;
+
+ // helper functions
+ std::ostream& stream() { return *m_stream; }
+ void set_checkpoint( const_string file, std::size_t line_num, const_string msg )
+ {
+ assign_op( m_checkpoint_data.m_message, msg, 0 );
+ m_checkpoint_data.m_file_name = file;
+ m_checkpoint_data.m_line_num = line_num;
+ }
+};
+
+unit_test_log_impl& s_log_impl() { static unit_test_log_impl the_inst; return the_inst; }
+
+} // local namespace
+
+//____________________________________________________________________________//
+
+void
+unit_test_log_t::test_start( counter_t test_cases_amount )
+{
+ if( s_log_impl().m_threshold_level == log_nothing )
+ return;
+
+ s_log_impl().m_log_formatter->log_start( s_log_impl().stream(), test_cases_amount );
+
+ if( runtime_config::show_build_info() )
+ s_log_impl().m_log_formatter->log_build_info( s_log_impl().stream() );
+
+ s_log_impl().m_entry_in_progress = false;
+}
+
+//____________________________________________________________________________//
+
+void
+unit_test_log_t::test_finish()
+{
+ if( s_log_impl().m_threshold_level == log_nothing )
+ return;
+
+ s_log_impl().m_log_formatter->log_finish( s_log_impl().stream() );
+
+ s_log_impl().stream().flush();
+}
+
+//____________________________________________________________________________//
+
+void
+unit_test_log_t::test_aborted()
+{
+ BOOST_TEST_LOG_ENTRY( log_messages ) << "Test is aborted";
+}
+
+//____________________________________________________________________________//
+
+void
+unit_test_log_t::test_unit_start( test_unit const& tu )
+{
+ if( s_log_impl().m_threshold_level > log_test_units )
+ return;
+
+ if( s_log_impl().m_entry_in_progress )
+ *this << log::end();
+
+ s_log_impl().m_log_formatter->test_unit_start( s_log_impl().stream(), tu );
+}
+
+//____________________________________________________________________________//
+
+void
+unit_test_log_t::test_unit_finish( test_unit const& tu, unsigned long elapsed )
+{
+ if( s_log_impl().m_threshold_level > log_test_units )
+ return;
+
+ s_log_impl().m_checkpoint_data.clear();
+
+ if( s_log_impl().m_entry_in_progress )
+ *this << log::end();
+
+ s_log_impl().m_log_formatter->test_unit_finish( s_log_impl().stream(), tu, elapsed );
+}
+
+//____________________________________________________________________________//
+
+void
+unit_test_log_t::test_unit_skipped( test_unit const& tu )
+{
+ if( s_log_impl().m_threshold_level > log_test_units )
+ return;
+
+ if( s_log_impl().m_entry_in_progress )
+ *this << log::end();
+
+ s_log_impl().m_log_formatter->test_unit_skipped( s_log_impl().stream(), tu );
+}
+
+//____________________________________________________________________________//
+
+void
+unit_test_log_t::test_unit_aborted( test_unit const& )
+{
+ // do nothing
+}
+
+//____________________________________________________________________________//
+
+void
+unit_test_log_t::assertion_result( bool )
+{
+ // do nothing
+}
+
+//____________________________________________________________________________//
+
+void
+unit_test_log_t::exception_caught( execution_exception const& ex )
+{
+ log_level l =
+ ex.code() <= execution_exception::cpp_exception_error ? log_cpp_exception_errors :
+ (ex.code() <= execution_exception::timeout_error ? log_system_errors
+ : log_fatal_errors );
+
+ if( l >= s_log_impl().m_threshold_level ) {
+ if( s_log_impl().m_entry_in_progress )
+ *this << log::end();
+
+ s_log_impl().m_log_formatter->log_exception( s_log_impl().stream(), s_log_impl().m_checkpoint_data, ex );
+ }
+}
+
+//____________________________________________________________________________//
+
+void
+unit_test_log_t::set_checkpoint( const_string file, std::size_t line_num, const_string msg )
+{
+ s_log_impl().set_checkpoint( file, line_num, msg );
+}
+
+//____________________________________________________________________________//
+
+char
+set_unix_slash( char in )
+{
+ return in == '\\' ? '/' : in;
+}
+
+unit_test_log_t&
+unit_test_log_t::operator<<( log::begin const& b )
+{
+ if( s_log_impl().m_entry_in_progress )
+ *this << log::end();
+
+ s_log_impl().m_stream_state_saver->restore();
+
+ s_log_impl().m_entry_data.clear();
+
+ assign_op( s_log_impl().m_entry_data.m_file_name, b.m_file_name, 0 );
+
+ // normalize file name
+ std::transform( s_log_impl().m_entry_data.m_file_name.begin(), s_log_impl().m_entry_data.m_file_name.end(),
+ s_log_impl().m_entry_data.m_file_name.begin(),
+ &set_unix_slash );
+
+ s_log_impl().m_entry_data.m_line_num = b.m_line_num;
+
+ return *this;
+}
+
+//____________________________________________________________________________//
+
+unit_test_log_t&
+unit_test_log_t::operator<<( log::end const& )
+{
+ if( s_log_impl().m_entry_in_progress )
+ s_log_impl().m_log_formatter->log_entry_finish( s_log_impl().stream() );
+
+ s_log_impl().m_entry_in_progress = false;
+
+ return *this;
+}
+
+//____________________________________________________________________________//
+
+unit_test_log_t&
+unit_test_log_t::operator<<( log_level l )
+{
+ s_log_impl().m_entry_data.m_level = l;
+
+ return *this;
+}
+
+//____________________________________________________________________________//
+
+ut_detail::entry_value_collector
+unit_test_log_t::operator()( log_level l )
+{
+ *this << l;
+
+ return ut_detail::entry_value_collector();
+}
+
+//____________________________________________________________________________//
+
+bool
+unit_test_log_t::log_entry_start()
+{
+ if( s_log_impl().m_entry_in_progress )
+ return true;
+
+ switch( s_log_impl().m_entry_data.m_level ) {
+ case log_successful_tests:
+ s_log_impl().m_log_formatter->log_entry_start( s_log_impl().stream(), s_log_impl().m_entry_data,
+ unit_test_log_formatter::BOOST_UTL_ET_INFO );
+ break;
+ case log_messages:
+ s_log_impl().m_log_formatter->log_entry_start( s_log_impl().stream(), s_log_impl().m_entry_data,
+ unit_test_log_formatter::BOOST_UTL_ET_MESSAGE );
+ break;
+ case log_warnings:
+ s_log_impl().m_log_formatter->log_entry_start( s_log_impl().stream(), s_log_impl().m_entry_data,
+ unit_test_log_formatter::BOOST_UTL_ET_WARNING );
+ break;
+ case log_all_errors:
+ case log_cpp_exception_errors:
+ case log_system_errors:
+ s_log_impl().m_log_formatter->log_entry_start( s_log_impl().stream(), s_log_impl().m_entry_data,
+ unit_test_log_formatter::BOOST_UTL_ET_ERROR );
+ break;
+ case log_fatal_errors:
+ s_log_impl().m_log_formatter->log_entry_start( s_log_impl().stream(), s_log_impl().m_entry_data,
+ unit_test_log_formatter::BOOST_UTL_ET_FATAL_ERROR );
+ break;
+ case log_nothing:
+ case log_test_units:
+ case invalid_log_level:
+ return false;
+ }
+
+ s_log_impl().m_entry_in_progress = true;
+
+ return true;
+}
+
+//____________________________________________________________________________//
+
+unit_test_log_t&
+unit_test_log_t::operator<<( const_string value )
+{
+ if( s_log_impl().m_entry_data.m_level >= s_log_impl().m_threshold_level && !value.empty() && log_entry_start() )
+ s_log_impl().m_log_formatter->log_entry_value( s_log_impl().stream(), value );
+
+ return *this;
+}
+
+//____________________________________________________________________________//
+
+unit_test_log_t&
+unit_test_log_t::operator<<( lazy_ostream const& value )
+{
+ if( s_log_impl().m_entry_data.m_level >= s_log_impl().m_threshold_level && !value.empty() && log_entry_start() )
+ s_log_impl().m_log_formatter->log_entry_value( s_log_impl().stream(), value );
+
+ return *this;
+}
+
+//____________________________________________________________________________//
+
+void
+unit_test_log_t::set_stream( std::ostream& str )
+{
+ if( s_log_impl().m_entry_in_progress )
+ return;
+
+ s_log_impl().m_stream = &str;
+ s_log_impl().m_stream_state_saver.reset( new io_saver_type( str ) );
+}
+
+//____________________________________________________________________________//
+
+void
+unit_test_log_t::set_threshold_level( log_level lev )
+{
+ if( s_log_impl().m_entry_in_progress || lev == invalid_log_level )
+ return;
+
+ s_log_impl().m_threshold_level = lev;
+}
+
+//____________________________________________________________________________//
+
+void
+unit_test_log_t::set_format( output_format log_format )
+{
+ if( s_log_impl().m_entry_in_progress )
+ return;
+
+ if( log_format == CLF )
+ set_formatter( new output::compiler_log_formatter );
+ else
+ set_formatter( new output::xml_log_formatter );
+}
+
+//____________________________________________________________________________//
+
+void
+unit_test_log_t::set_formatter( unit_test_log_formatter* the_formatter )
+{
+ s_log_impl().m_log_formatter.reset( the_formatter );
+}
+
+//____________________________________________________________________________//
+
+// ************************************************************************** //
+// ************** unit_test_log_formatter ************** //
+// ************************************************************************** //
+
+void
+unit_test_log_formatter::log_entry_value( std::ostream& ostr, lazy_ostream const& value )
+{
+ log_entry_value( ostr, (wrap_stringstream().ref() << value).str() );
+}
+
+//____________________________________________________________________________//
+
+} // namespace unit_test
+
+} // namespace ndnboost
+
+//____________________________________________________________________________//
+
+#include <ndnboost/test/detail/enable_warnings.hpp>
+
+#endif // BOOST_TEST_UNIT_TEST_LOG_IPP_012205GER
diff --git a/ndnboost/test/impl/unit_test_main.ipp b/ndnboost/test/impl/unit_test_main.ipp
new file mode 100644
index 0000000..bde871f
--- /dev/null
+++ b/ndnboost/test/impl/unit_test_main.ipp
@@ -0,0 +1,246 @@
+// (C) Copyright Gennadiy Rozental 2001-2008.
+// Distributed under 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)
+
+// See http://www.boost.org/libs/test for the library home page.
+//
+// File : $RCSfile$
+//
+// Version : $Revision: 54633 $
+//
+// Description : main function implementation for Unit Test Framework
+// ***************************************************************************
+
+#ifndef BOOST_TEST_UNIT_TEST_MAIN_IPP_012205GER
+#define BOOST_TEST_UNIT_TEST_MAIN_IPP_012205GER
+
+// Boost.Test
+#include <ndnboost/test/framework.hpp>
+#include <ndnboost/test/results_collector.hpp>
+#include <ndnboost/test/unit_test_suite_impl.hpp>
+#include <ndnboost/test/results_reporter.hpp>
+
+#include <ndnboost/test/detail/unit_test_parameters.hpp>
+
+#if !defined(__BORLANDC__) && !BOOST_WORKAROUND( BOOST_MSVC, < 1300 ) && !BOOST_WORKAROUND( __SUNPRO_CC, < 0x5100 )
+#define BOOST_TEST_SUPPORT_RUN_BY_NAME
+#include <ndnboost/test/utils/iterator/token_iterator.hpp>
+#endif
+
+// Boost
+#include <ndnboost/cstdlib.hpp>
+#include <ndnboost/bind.hpp>
+
+// STL
+#include <stdexcept>
+#include <iostream>
+
+#include <ndnboost/test/detail/suppress_warnings.hpp>
+
+//____________________________________________________________________________//
+
+namespace ndnboost {
+
+namespace unit_test {
+
+// ************************************************************************** //
+// ************** test_case_filter ************** //
+// ************************************************************************** //
+
+class test_case_filter : public test_tree_visitor {
+public:
+ struct single_filter {
+ single_filter( const_string in )
+ {
+ if( in == "*" )
+ m_kind = SFK_ALL;
+ else if( first_char( in ) == '*' && last_char( in ) == '*' ) {
+ m_kind = SFK_SUBSTR;
+ m_value = in.substr( 1, in.size()-1 );
+ }
+ else if( first_char( in ) == '*' ) {
+ m_kind = SFK_TRAILING;
+ m_value = in.substr( 1 );
+ }
+ else if( last_char( in ) == '*' ) {
+ m_kind = SFK_LEADING;
+ m_value = in.substr( 0, in.size()-1 );
+ }
+ else {
+ m_kind = SFK_MATCH;
+ m_value = in;
+ }
+ };
+
+ bool pass( test_unit const& tu ) const
+ {
+ const_string name( tu.p_name );
+
+ switch( m_kind ) {
+ default:
+ case SFK_ALL:
+ return true;
+
+ case SFK_LEADING:
+ return name.substr( 0, m_value.size() ) == m_value;
+
+ case SFK_TRAILING:
+ return name.size() >= m_value.size() && name.substr( name.size() - m_value.size() ) == m_value;
+
+ case SFK_SUBSTR:
+ return name.find( m_value ) != const_string::npos;
+
+ case SFK_MATCH:
+ return m_value == tu.p_name.get();
+ }
+ }
+ enum kind { SFK_ALL, SFK_LEADING, SFK_TRAILING, SFK_SUBSTR, SFK_MATCH };
+
+ kind m_kind;
+ const_string m_value;
+ };
+ // Constructor
+#ifndef BOOST_TEST_SUPPORT_RUN_BY_NAME
+ explicit test_case_filter( const_string ) : m_depth( 0 ) {}
+#else
+ explicit test_case_filter( const_string tc_to_run )
+ : m_depth( 0 )
+ {
+ string_token_iterator tit( tc_to_run, (dropped_delimeters = "/", kept_delimeters = dt_none) );
+
+ while( tit != string_token_iterator() ) {
+ m_filters.push_back(
+ std::vector<single_filter>( string_token_iterator( *tit, (dropped_delimeters = ",", kept_delimeters = dt_none) ),
+ string_token_iterator() ) );
+
+ ++tit;
+ }
+ }
+#endif
+
+ void filter_unit( test_unit const& tu )
+ {
+ if( (++m_depth - 1) > m_filters.size() ) {
+ tu.p_enabled.value = true;
+ return;
+ }
+
+ if( m_depth == 1 )
+ return;
+
+ std::vector<single_filter> const& filters = m_filters[m_depth-2];
+
+ tu.p_enabled.value =
+ std::find_if( filters.begin(), filters.end(), bind( &single_filter::pass, _1, ndnboost::ref(tu) ) ) != filters.end();
+ }
+
+ // test tree visitor interface
+ virtual void visit( test_case const& tc )
+ {
+ if( m_depth < m_filters.size() ) {
+ tc.p_enabled.value = false;
+ return;
+ }
+
+ filter_unit( tc );
+
+ --m_depth;
+ }
+
+ virtual bool test_suite_start( test_suite const& ts )
+ {
+ filter_unit( ts );
+
+ if( !ts.p_enabled )
+ --m_depth;
+
+ return ts.p_enabled;
+ }
+
+ virtual void test_suite_finish( test_suite const& ) { --m_depth; }
+
+private:
+ // Data members
+ std::vector<std::vector<single_filter> > m_filters;
+ unsigned m_depth;
+};
+
+// ************************************************************************** //
+// ************** unit_test_main ************** //
+// ************************************************************************** //
+
+int BOOST_TEST_DECL
+unit_test_main( init_unit_test_func init_func, int argc, char* argv[] )
+{
+ try {
+ framework::init( init_func, argc, argv );
+
+ if( !runtime_config::test_to_run().is_empty() ) {
+ test_case_filter filter( runtime_config::test_to_run() );
+
+ traverse_test_tree( framework::master_test_suite().p_id, filter );
+ }
+
+ framework::run();
+
+ results_reporter::make_report();
+
+ return runtime_config::no_result_code()
+ ? ndnboost::exit_success
+ : results_collector.results( framework::master_test_suite().p_id ).result_code();
+ }
+ catch( framework::nothing_to_test const& ) {
+ return ndnboost::exit_success;
+ }
+ catch( framework::internal_error const& ex ) {
+ results_reporter::get_stream() << "Boost.Test framework internal error: " << ex.what() << std::endl;
+
+ return ndnboost::exit_exception_failure;
+ }
+ catch( framework::setup_error const& ex ) {
+ results_reporter::get_stream() << "Test setup error: " << ex.what() << std::endl;
+
+ return ndnboost::exit_exception_failure;
+ }
+ catch( ... ) {
+ results_reporter::get_stream() << "Boost.Test framework internal error: unknown reason" << std::endl;
+
+ return ndnboost::exit_exception_failure;
+ }
+}
+
+} // namespace unit_test
+
+} // namespace ndnboost
+
+#if !defined(BOOST_TEST_DYN_LINK) && !defined(BOOST_TEST_NO_MAIN)
+
+// ************************************************************************** //
+// ************** main function for tests using lib ************** //
+// ************************************************************************** //
+
+int BOOST_TEST_CALL_DECL
+main( int argc, char* argv[] )
+{
+ // prototype for user's unit test init function
+#ifdef BOOST_TEST_ALTERNATIVE_INIT_API
+ extern bool init_unit_test();
+
+ ndnboost::unit_test::init_unit_test_func init_func = &init_unit_test;
+#else
+ extern ::ndnboost::unit_test::test_suite* init_unit_test_suite( int argc, char* argv[] );
+
+ ndnboost::unit_test::init_unit_test_func init_func = &init_unit_test_suite;
+#endif
+
+ return ::ndnboost::unit_test::unit_test_main( init_func, argc, argv );
+}
+
+#endif // !BOOST_TEST_DYN_LINK && !BOOST_TEST_NO_MAIN
+
+//____________________________________________________________________________//
+
+#include <ndnboost/test/detail/enable_warnings.hpp>
+
+#endif // BOOST_TEST_UNIT_TEST_MAIN_IPP_012205GER
diff --git a/ndnboost/test/impl/unit_test_monitor.ipp b/ndnboost/test/impl/unit_test_monitor.ipp
new file mode 100644
index 0000000..0932bf3
--- /dev/null
+++ b/ndnboost/test/impl/unit_test_monitor.ipp
@@ -0,0 +1,101 @@
+// (C) Copyright Gennadiy Rozental 2005-2008.
+// Distributed under 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)
+
+// See http://www.boost.org/libs/test for the library home page.
+//
+// File : $RCSfile$
+//
+// Version : $Revision: 49312 $
+//
+// Description : implements specific subclass of Executon Monitor used by Unit
+// Test Framework to monitor test cases run.
+// ***************************************************************************
+
+#ifndef BOOST_TEST_UNIT_TEST_MONITOR_IPP_012205GER
+#define BOOST_TEST_UNIT_TEST_MONITOR_IPP_012205GER
+
+// Boost.Test
+#include <ndnboost/test/unit_test_monitor.hpp>
+#include <ndnboost/test/unit_test_suite_impl.hpp>
+#include <ndnboost/test/test_tools.hpp>
+#include <ndnboost/test/framework.hpp>
+
+#include <ndnboost/test/detail/unit_test_parameters.hpp>
+
+#include <ndnboost/test/detail/suppress_warnings.hpp>
+
+//____________________________________________________________________________//
+
+namespace ndnboost {
+
+namespace unit_test {
+
+namespace {
+
+template<typename F>
+struct zero_return_wrapper_t {
+ explicit zero_return_wrapper_t( F const& f ) : m_f( f ) {}
+
+ int operator()() { m_f(); return 0; }
+
+ F const& m_f;
+};
+
+template<typename F>
+zero_return_wrapper_t<F>
+zero_return_wrapper( F const& f )
+{
+ return zero_return_wrapper_t<F>( f );
+}
+
+}
+
+// ************************************************************************** //
+// ************** unit_test_monitor ************** //
+// ************************************************************************** //
+
+unit_test_monitor_t::error_level
+unit_test_monitor_t::execute_and_translate( test_case const& tc )
+{
+ try {
+ p_catch_system_errors.value = runtime_config::catch_sys_errors();
+ p_timeout.value = tc.p_timeout.get();
+ p_auto_start_dbg.value = runtime_config::auto_start_dbg();
+ p_use_alt_stack.value = runtime_config::use_alt_stack();
+ p_detect_fp_exceptions.value = runtime_config::detect_fp_exceptions();
+
+ execute( callback0<int>( zero_return_wrapper( tc.test_func() ) ) );
+ }
+ catch( execution_exception const& ex ) {
+ framework::exception_caught( ex );
+ framework::test_unit_aborted( framework::current_test_case() );
+
+ // translate execution_exception::error_code to error_level
+ switch( ex.code() ) {
+ case execution_exception::no_error: return test_ok;
+ case execution_exception::user_error: return unexpected_exception;
+ case execution_exception::cpp_exception_error: return unexpected_exception;
+ case execution_exception::system_error: return os_exception;
+ case execution_exception::timeout_error: return os_timeout;
+ case execution_exception::user_fatal_error:
+ case execution_exception::system_fatal_error: return fatal_error;
+ default: return unexpected_exception;
+ }
+ }
+
+ return test_ok;
+}
+
+//____________________________________________________________________________//
+
+} // namespace unit_test
+
+} // namespace ndnboost
+
+//____________________________________________________________________________//
+
+#include <ndnboost/test/detail/enable_warnings.hpp>
+
+#endif // BOOST_TEST_UNIT_TEST_MONITOR_IPP_012205GER
diff --git a/ndnboost/test/impl/unit_test_parameters.ipp b/ndnboost/test/impl/unit_test_parameters.ipp
new file mode 100644
index 0000000..ffc29c9
--- /dev/null
+++ b/ndnboost/test/impl/unit_test_parameters.ipp
@@ -0,0 +1,527 @@
+// (C) Copyright Gennadiy Rozental 2001-2008.
+// Distributed under 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)
+
+// See http://www.boost.org/libs/test for the library home page.
+//
+// File : $RCSfile$
+//
+// Version : $Revision: 63640 $
+//
+// Description : simple implementation for Unit Test Framework parameter
+// handling routines. May be rewritten in future to use some kind of
+// command-line arguments parsing facility and environment variable handling
+// facility
+// ***************************************************************************
+
+#ifndef BOOST_TEST_UNIT_TEST_PARAMETERS_IPP_012205GER
+#define BOOST_TEST_UNIT_TEST_PARAMETERS_IPP_012205GER
+
+// Boost.Test
+#include <ndnboost/test/detail/unit_test_parameters.hpp>
+#include <ndnboost/test/utils/basic_cstring/basic_cstring.hpp>
+#include <ndnboost/test/utils/basic_cstring/compare.hpp>
+#include <ndnboost/test/utils/basic_cstring/io.hpp>
+#include <ndnboost/test/utils/fixed_mapping.hpp>
+#include <ndnboost/test/debug.hpp>
+#include <ndnboost/test/framework.hpp>
+
+// Boost.Runtime.Param
+#include <ndnboost/test/utils/runtime/cla/dual_name_parameter.hpp>
+#include <ndnboost/test/utils/runtime/cla/parser.hpp>
+
+namespace rt = ndnboost::runtime;
+namespace cla = rt::cla;
+
+
+#ifndef UNDER_CE
+#include <ndnboost/test/utils/runtime/env/variable.hpp>
+
+namespace env = rt::env;
+#endif
+
+
+// Boost
+#include <ndnboost/config.hpp>
+#include <ndnboost/test/detail/suppress_warnings.hpp>
+#include <ndnboost/lexical_cast.hpp>
+#include <ndnboost/test/detail/enable_warnings.hpp>
+
+// STL
+#include <map>
+#include <cstdlib>
+#include <iostream>
+#include <fstream>
+
+#include <ndnboost/test/detail/suppress_warnings.hpp>
+
+//____________________________________________________________________________//
+
+# ifdef BOOST_NO_STDC_NAMESPACE
+namespace std { using ::getenv; using ::strncmp; using ::strcmp; }
+# endif
+
+namespace ndnboost {
+
+namespace unit_test {
+
+// ************************************************************************** //
+// ************** input operations for unit_test's enums ************** //
+// ************************************************************************** //
+
+std::istream&
+operator>>( std::istream& in, unit_test::log_level& ll )
+{
+ static fixed_mapping<const_string,unit_test::log_level,case_ins_less<char const> > log_level_name(
+ "all" , log_successful_tests,
+ "success" , log_successful_tests,
+ "test_suite" , log_test_units,
+ "unit_scope" , log_test_units,
+ "message" , log_messages,
+ "warning" , log_warnings,
+ "error" , log_all_errors,
+ "cpp_exception" , log_cpp_exception_errors,
+ "system_error" , log_system_errors,
+ "fatal_error" , log_fatal_errors,
+ "nothing" , log_nothing,
+
+ invalid_log_level
+ );
+
+ std::string val;
+ in >> val;
+
+ ll = log_level_name[val];
+ BOOST_TEST_SETUP_ASSERT( ll != unit_test::invalid_log_level, "invalid log level " + val );
+
+ return in;
+}
+
+//____________________________________________________________________________//
+
+std::istream&
+operator>>( std::istream& in, unit_test::report_level& rl )
+{
+ fixed_mapping<const_string,unit_test::report_level,case_ins_less<char const> > report_level_name (
+ "confirm", CONFIRMATION_REPORT,
+ "short", SHORT_REPORT,
+ "detailed", DETAILED_REPORT,
+ "no", NO_REPORT,
+
+ INV_REPORT_LEVEL
+ );
+
+ std::string val;
+ in >> val;
+
+ rl = report_level_name[val];
+ BOOST_TEST_SETUP_ASSERT( rl != INV_REPORT_LEVEL, "invalid report level " + val );
+
+ return in;
+}
+
+//____________________________________________________________________________//
+
+std::istream&
+operator>>( std::istream& in, unit_test::output_format& of )
+{
+ fixed_mapping<const_string,unit_test::output_format,case_ins_less<char const> > output_format_name (
+ "HRF", unit_test::CLF,
+ "CLF", unit_test::CLF,
+ "XML", unit_test::XML,
+
+ unit_test::INV_OF
+ );
+
+ std::string val;
+ in >> val;
+
+ of = output_format_name[val];
+ BOOST_TEST_SETUP_ASSERT( of != unit_test::INV_OF, "invalid output format " + val );
+
+ return in;
+}
+
+//____________________________________________________________________________//
+
+// ************************************************************************** //
+// ************** runtime_config ************** //
+// ************************************************************************** //
+
+namespace runtime_config {
+
+namespace {
+
+// framework parameters and corresponding command-line arguments
+std::string AUTO_START_DBG = "auto_start_dbg";
+std::string BREAK_EXEC_PATH = "break_exec_path";
+std::string BUILD_INFO = "build_info";
+std::string CATCH_SYS_ERRORS = "catch_system_errors";
+std::string DETECT_FP_EXCEPT = "detect_fp_exceptions";
+std::string DETECT_MEM_LEAKS = "detect_memory_leaks";
+std::string LOG_FORMAT = "log_format";
+std::string LOG_LEVEL = "log_level";
+std::string LOG_SINK = "log_sink";
+std::string OUTPUT_FORMAT = "output_format";
+std::string RANDOM_SEED = "random";
+std::string REPORT_FORMAT = "report_format";
+std::string REPORT_LEVEL = "report_level";
+std::string REPORT_SINK = "report_sink";
+std::string RESULT_CODE = "result_code";
+std::string TESTS_TO_RUN = "run_test";
+std::string SAVE_TEST_PATTERN = "save_pattern";
+std::string SHOW_PROGRESS = "show_progress";
+std::string USE_ALT_STACK = "use_alt_stack";
+
+fixed_mapping<const_string,const_string> parameter_2_env_var(
+ AUTO_START_DBG , "BOOST_TEST_AUTO_START_DBG",
+ BREAK_EXEC_PATH , "BOOST_TEST_BREAK_EXEC_PATH",
+ BUILD_INFO , "BOOST_TEST_BUILD_INFO",
+ CATCH_SYS_ERRORS , "BOOST_TEST_CATCH_SYSTEM_ERRORS",
+ DETECT_FP_EXCEPT , "BOOST_TEST_DETECT_FP_EXCEPTIONS",
+ DETECT_MEM_LEAKS , "BOOST_TEST_DETECT_MEMORY_LEAK",
+ LOG_FORMAT , "BOOST_TEST_LOG_FORMAT",
+ LOG_LEVEL , "BOOST_TEST_LOG_LEVEL",
+ LOG_SINK , "BOOST_TEST_LOG_SINK",
+ OUTPUT_FORMAT , "BOOST_TEST_OUTPUT_FORMAT",
+ RANDOM_SEED , "BOOST_TEST_RANDOM",
+ REPORT_FORMAT , "BOOST_TEST_REPORT_FORMAT",
+ REPORT_LEVEL , "BOOST_TEST_REPORT_LEVEL",
+ REPORT_SINK , "BOOST_TEST_REPORT_SINK",
+ RESULT_CODE , "BOOST_TEST_RESULT_CODE",
+ TESTS_TO_RUN , "BOOST_TESTS_TO_RUN",
+ SAVE_TEST_PATTERN , "BOOST_TEST_SAVE_PATTERN",
+ SHOW_PROGRESS , "BOOST_TEST_SHOW_PROGRESS",
+ USE_ALT_STACK , "BOOST_TEST_USE_ALT_STACK",
+
+ ""
+);
+
+//____________________________________________________________________________//
+
+// storage for the CLAs
+cla::parser s_cla_parser;
+std::string s_empty;
+
+output_format s_report_format;
+output_format s_log_format;
+
+//____________________________________________________________________________//
+
+template<typename T>
+T
+retrieve_parameter( const_string parameter_name, cla::parser const& s_cla_parser, T const& default_value = T(), T const& optional_value = T() )
+{
+ rt::const_argument_ptr arg = s_cla_parser[parameter_name];
+ if( arg ) {
+ if( rtti::type_id<T>() == rtti::type_id<bool>() ||
+ !static_cast<cla::parameter const&>( arg->p_formal_parameter.get() ).p_optional_value )
+ return s_cla_parser.get<T>( parameter_name );
+
+ optional<T> val = s_cla_parser.get<optional<T> >( parameter_name );
+ if( val )
+ return *val;
+ else
+ return optional_value;
+ }
+
+ ndnboost::optional<T> v;
+
+#ifndef UNDER_CE
+ env::get( parameter_2_env_var[parameter_name], v );
+#endif
+
+ if( v )
+ return *v;
+ else
+ return default_value;
+}
+
+//____________________________________________________________________________//
+
+} // local namespace
+
+void
+init( int& argc, char** argv )
+{
+ using namespace cla;
+
+ try {
+ s_cla_parser - cla::ignore_mismatch
+ << cla::dual_name_parameter<bool>( AUTO_START_DBG + "|d" )
+ - (cla::prefix = "--|-",cla::separator = "=| ",cla::guess_name,cla::optional,
+ cla::description = "Automatically starts debugger if system level error (signal) occurs")
+ << cla::named_parameter<std::string>( BREAK_EXEC_PATH )
+ - (cla::prefix = "--",cla::separator = "=",cla::guess_name,cla::optional,
+ cla::description = "For the exception safety testing allows to break at specific execution path")
+ << cla::dual_name_parameter<bool>( BUILD_INFO + "|i" )
+ - (cla::prefix = "--|-",cla::separator = "=| ",cla::guess_name,cla::optional,
+ cla::description = "Shows library build information" )
+ << cla::dual_name_parameter<bool>( CATCH_SYS_ERRORS + "|s" )
+ - (cla::prefix = "--|-",cla::separator = "=| ",cla::guess_name,cla::optional,
+ cla::description = "Allows to switch between catching and ignoring system errors (signals)")
+ << cla::named_parameter<bool>( DETECT_FP_EXCEPT )
+ - (cla::prefix = "--",cla::separator = "=",cla::guess_name,cla::optional,
+ cla::description = "Allows to switch between catching and ignoring floating point exceptions")
+ << cla::named_parameter<long>( DETECT_MEM_LEAKS )
+ - (cla::prefix = "--",cla::separator = "=",cla::guess_name,cla::optional,
+ cla::description = "Allows to switch between catching and ignoring memory leaks")
+ << cla::dual_name_parameter<unit_test::output_format>( LOG_FORMAT + "|f" )
+ - (cla::prefix = "--|-",cla::separator = "=| ",cla::guess_name,cla::optional,
+ cla::description = "Specifies log format")
+ << cla::dual_name_parameter<unit_test::log_level>( LOG_LEVEL + "|l" )
+ - (cla::prefix = "--|-",cla::separator = "=| ",cla::guess_name,cla::optional,
+ cla::description = "Specifies log level")
+ << cla::dual_name_parameter<std::string>( LOG_SINK + "|k" )
+ - (cla::prefix = "--|-",cla::separator = "=| ",cla::guess_name,cla::optional,
+ cla::description = "Specifies log sink:stdout(default),stderr or file name")
+ << cla::dual_name_parameter<unit_test::output_format>( OUTPUT_FORMAT + "|o" )
+ - (cla::prefix = "--|-",cla::separator = "=| ",cla::guess_name,cla::optional,
+ cla::description = "Specifies output format (both log and report)")
+ << cla::dual_name_parameter<int>( RANDOM_SEED + "|a" )
+ - (cla::prefix = "--|-",cla::separator = "=| ",cla::guess_name,cla::optional,cla::optional_value,
+ cla::description = "Allows to switch between sequential and random order of test units execution.\n"
+ "Optionally allows to specify concrete seed for random number generator")
+ << cla::dual_name_parameter<unit_test::output_format>( REPORT_FORMAT + "|m" )
+ - (cla::prefix = "--|-",cla::separator = "=| ",cla::guess_name,cla::optional,
+ cla::description = "Specifies report format")
+ << cla::dual_name_parameter<unit_test::report_level>(REPORT_LEVEL + "|r")
+ - (cla::prefix = "--|-",cla::separator = "=| ",cla::guess_name,cla::optional,
+ cla::description = "Specifies report level")
+ << cla::dual_name_parameter<std::string>( REPORT_SINK + "|e" )
+ - (cla::prefix = "--|-",cla::separator = "=| ",cla::guess_name,cla::optional,
+ cla::description = "Specifies report sink:stderr(default),stdout or file name")
+ << cla::dual_name_parameter<bool>( RESULT_CODE + "|c" )
+ - (cla::prefix = "--|-",cla::separator = "=| ",cla::guess_name,cla::optional,
+ cla::description = "Allows to disable test modules's result code generation")
+ << cla::dual_name_parameter<std::string>( TESTS_TO_RUN + "|t" )
+ - (cla::prefix = "--|-",cla::separator = "=| ",cla::guess_name,cla::optional,
+ cla::description = "Allows to filter which test units to run")
+ << cla::named_parameter<bool>( SAVE_TEST_PATTERN )
+ - (cla::prefix = "--",cla::separator = "=",cla::guess_name,cla::optional,
+ cla::description = "Allows to switch between saving and matching against test pattern file")
+ << cla::dual_name_parameter<bool>( SHOW_PROGRESS + "|p" )
+ - (cla::prefix = "--|-",cla::separator = "=| ",cla::guess_name,cla::optional,
+ cla::description = "Turns on progress display")
+ << cla::named_parameter<bool>( USE_ALT_STACK )
+ - (cla::prefix = "--",cla::separator = "=",cla::guess_name,cla::optional,
+ cla::description = "Turns on/off usage of an alternative stack for signal handling")
+
+ << cla::dual_name_parameter<bool>( "help|?" )
+ - (cla::prefix = "--|-",cla::separator = "=",cla::guess_name,cla::optional,
+ cla::description = "this help message")
+ ;
+
+ s_cla_parser.parse( argc, argv );
+
+ if( s_cla_parser["help"] ) {
+ s_cla_parser.help( std::cout );
+ throw framework::nothing_to_test();
+ }
+
+ s_report_format = retrieve_parameter( REPORT_FORMAT, s_cla_parser, unit_test::CLF );
+ s_log_format = retrieve_parameter( LOG_FORMAT, s_cla_parser, unit_test::CLF );
+
+ unit_test::output_format of = retrieve_parameter( OUTPUT_FORMAT, s_cla_parser, unit_test::INV_OF );
+
+ if( of != unit_test::INV_OF )
+ s_report_format = s_log_format = of;
+ }
+ catch( rt::logic_error const& ex ) {
+ std::ostringstream err;
+
+ err << "Fail to process runtime parameters: " << ex.msg() << std::endl;
+ s_cla_parser.usage( err );
+
+ throw framework::setup_error( err.str() );
+ }
+}
+
+//____________________________________________________________________________//
+
+unit_test::log_level
+log_level()
+{
+ return retrieve_parameter( LOG_LEVEL, s_cla_parser, unit_test::log_all_errors );
+}
+
+//____________________________________________________________________________//
+
+bool
+no_result_code()
+{
+ return !retrieve_parameter( RESULT_CODE, s_cla_parser, true );
+}
+
+//____________________________________________________________________________//
+
+unit_test::report_level
+report_level()
+{
+ return retrieve_parameter( REPORT_LEVEL, s_cla_parser, unit_test::CONFIRMATION_REPORT );
+}
+
+//____________________________________________________________________________//
+
+const_string
+test_to_run()
+{
+ static std::string s_test_to_run = retrieve_parameter( TESTS_TO_RUN, s_cla_parser, s_empty );
+
+ return s_test_to_run;
+}
+
+//____________________________________________________________________________//
+
+const_string
+break_exec_path()
+{
+ static std::string s_break_exec_path = retrieve_parameter( BREAK_EXEC_PATH, s_cla_parser, s_empty );
+
+ return s_break_exec_path;
+}
+
+//____________________________________________________________________________//
+
+bool
+save_pattern()
+{
+ return retrieve_parameter( SAVE_TEST_PATTERN, s_cla_parser, false );
+}
+
+//____________________________________________________________________________//
+
+bool
+show_progress()
+{
+ return retrieve_parameter( SHOW_PROGRESS, s_cla_parser, false );
+}
+
+//____________________________________________________________________________//
+
+bool
+show_build_info()
+{
+ return retrieve_parameter( BUILD_INFO, s_cla_parser, false );
+}
+
+//____________________________________________________________________________//
+
+bool
+catch_sys_errors()
+{
+ return retrieve_parameter( CATCH_SYS_ERRORS, s_cla_parser,
+#ifdef BOOST_TEST_DEFAULTS_TO_CORE_DUMP
+ false
+#else
+ true
+#endif
+ );
+}
+
+//____________________________________________________________________________//
+
+bool
+auto_start_dbg()
+{
+ // !! set debugger as an option
+ return retrieve_parameter( AUTO_START_DBG, s_cla_parser, false );
+;
+}
+
+//____________________________________________________________________________//
+
+bool
+use_alt_stack()
+{
+ return retrieve_parameter( USE_ALT_STACK, s_cla_parser, true );
+}
+
+//____________________________________________________________________________//
+
+bool
+detect_fp_exceptions()
+{
+ return retrieve_parameter( DETECT_FP_EXCEPT, s_cla_parser, false );
+}
+
+//____________________________________________________________________________//
+
+output_format
+report_format()
+{
+ return s_report_format;
+}
+
+//____________________________________________________________________________//
+
+output_format
+log_format()
+{
+ return s_log_format;
+}
+
+//____________________________________________________________________________//
+
+std::ostream*
+report_sink()
+{
+ std::string sink_name = retrieve_parameter( REPORT_SINK, s_cla_parser, s_empty );
+
+ if( sink_name.empty() || sink_name == "stderr" )
+ return &std::cerr;
+
+ if( sink_name == "stdout" )
+ return &std::cout;
+
+ static std::ofstream log_file( sink_name.c_str() );
+ return &log_file;
+}
+
+//____________________________________________________________________________//
+
+std::ostream*
+log_sink()
+{
+ std::string sink_name = retrieve_parameter( LOG_SINK, s_cla_parser, s_empty );
+
+ if( sink_name.empty() || sink_name == "stdout" )
+ return &std::cout;
+
+ if( sink_name == "stderr" )
+ return &std::cerr;
+
+ static std::ofstream report_file( sink_name.c_str() );
+ return &report_file;
+}
+
+//____________________________________________________________________________//
+
+long
+detect_memory_leaks()
+{
+ return retrieve_parameter( DETECT_MEM_LEAKS, s_cla_parser, static_cast<long>(1) );
+}
+
+//____________________________________________________________________________//
+
+int
+random_seed()
+{
+ return retrieve_parameter( RANDOM_SEED, s_cla_parser, 0, 1 );
+}
+
+//____________________________________________________________________________//
+
+} // namespace runtime_config
+
+} // namespace unit_test
+
+} // namespace ndnboost
+
+//____________________________________________________________________________//
+
+#include <ndnboost/test/detail/enable_warnings.hpp>
+
+#endif // BOOST_TEST_UNIT_TEST_PARAMETERS_IPP_012205GER
diff --git a/ndnboost/test/impl/unit_test_suite.ipp b/ndnboost/test/impl/unit_test_suite.ipp
new file mode 100644
index 0000000..983682d
--- /dev/null
+++ b/ndnboost/test/impl/unit_test_suite.ipp
@@ -0,0 +1,346 @@
+// (C) Copyright Gennadiy Rozental 2005-2008.
+// Distributed under 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)
+
+// See http://www.boost.org/libs/test for the library home page.
+//
+// File : $RCSfile$
+//
+// Version : $Revision: 54633 $
+//
+// Description : privides core implementation for Unit Test Framework.
+// Extensions can be provided in separate files
+// ***************************************************************************
+
+#ifndef BOOST_TEST_UNIT_TEST_SUITE_IPP_012205GER
+#define BOOST_TEST_UNIT_TEST_SUITE_IPP_012205GER
+
+// Boost.Test
+#include <ndnboost/detail/workaround.hpp>
+#include <ndnboost/test/unit_test_suite_impl.hpp>
+#include <ndnboost/test/framework.hpp>
+#include <ndnboost/test/utils/foreach.hpp>
+#include <ndnboost/test/results_collector.hpp>
+#include <ndnboost/test/detail/unit_test_parameters.hpp>
+
+// Boost
+#include <ndnboost/timer.hpp>
+
+// STL
+#include <algorithm>
+#include <vector>
+
+#include <ndnboost/test/detail/suppress_warnings.hpp>
+
+#if BOOST_WORKAROUND(__BORLANDC__, < 0x600) && \
+ BOOST_WORKAROUND(_STLPORT_VERSION, <= 0x450) \
+ /**/
+ using std::rand; // rand is in std and random_shuffle is in _STL
+#endif
+
+//____________________________________________________________________________//
+
+namespace ndnboost {
+
+namespace unit_test {
+
+// ************************************************************************** //
+// ************** test_unit ************** //
+// ************************************************************************** //
+
+test_unit::test_unit( const_string name, test_unit_type t )
+: p_type( t )
+, p_type_name( t == tut_case ? "case" : "suite" )
+, p_id( INV_TEST_UNIT_ID )
+, p_name( std::string( name.begin(), name.size() ) )
+, p_enabled( true )
+{
+}
+
+//____________________________________________________________________________//
+
+test_unit::~test_unit()
+{
+ framework::deregister_test_unit( this );
+}
+
+//____________________________________________________________________________//
+
+void
+test_unit::depends_on( test_unit* tu )
+{
+ m_dependencies.push_back( tu->p_id );
+}
+
+//____________________________________________________________________________//
+
+bool
+test_unit::check_dependencies() const
+{
+ BOOST_TEST_FOREACH( test_unit_id, tu_id, m_dependencies ) {
+ if( !unit_test::results_collector.results( tu_id ).passed() )
+ return false;
+ }
+
+ return true;
+}
+
+//____________________________________________________________________________//
+
+void
+test_unit::increase_exp_fail( unsigned num )
+{
+ p_expected_failures.value += num;
+
+ if( p_parent_id != 0 )
+ framework::get<test_suite>( p_parent_id ).increase_exp_fail( num );
+}
+
+//____________________________________________________________________________//
+
+// ************************************************************************** //
+// ************** test_case ************** //
+// ************************************************************************** //
+
+test_case::test_case( const_string name, callback0<> const& test_func )
+: test_unit( name, static_cast<test_unit_type>(type) )
+, m_test_func( test_func )
+{
+ // !! weirdest MSVC BUG; try to remove this statement; looks like it eats first token of next statement
+#if BOOST_WORKAROUND(BOOST_MSVC,<1300)
+ 0;
+#endif
+ framework::register_test_unit( this );
+}
+
+//____________________________________________________________________________//
+
+// ************************************************************************** //
+// ************** test_suite ************** //
+// ************************************************************************** //
+
+//____________________________________________________________________________//
+
+test_suite::test_suite( const_string name )
+: test_unit( name, static_cast<test_unit_type>(type) )
+{
+ framework::register_test_unit( this );
+}
+
+//____________________________________________________________________________//
+
+void
+test_suite::add( test_unit* tu, counter_t expected_failures, unsigned timeout )
+{
+ if( timeout != 0 )
+ tu->p_timeout.value = timeout;
+
+ m_members.push_back( tu->p_id );
+ tu->p_parent_id.value = p_id;
+
+ if( tu->p_expected_failures )
+ increase_exp_fail( tu->p_expected_failures );
+
+ if( expected_failures )
+ tu->increase_exp_fail( expected_failures );
+}
+
+//____________________________________________________________________________//
+
+void
+test_suite::add( test_unit_generator const& gen, unsigned timeout )
+{
+ test_unit* tu;
+ while((tu = gen.next(), tu))
+ add( tu, 0, timeout );
+}
+
+//____________________________________________________________________________//
+
+void
+test_suite::remove( test_unit_id id )
+{
+ std::vector<test_unit_id>::iterator it = std::find( m_members.begin(), m_members.end(), id );
+
+ if( it != m_members.end() )
+ m_members.erase( it );
+}
+
+//____________________________________________________________________________//
+
+test_unit_id
+test_suite::get( const_string tu_name ) const
+{
+ BOOST_TEST_FOREACH( test_unit_id, id, m_members ) {
+ if( tu_name == framework::get( id, ut_detail::test_id_2_unit_type( id ) ).p_name.get() )
+ return id;
+ }
+
+ return INV_TEST_UNIT_ID;
+}
+
+//____________________________________________________________________________//
+
+// ************************************************************************** //
+// ************** traverse_test_tree ************** //
+// ************************************************************************** //
+
+void
+traverse_test_tree( test_case const& tc, test_tree_visitor& V )
+{
+ if( tc.p_enabled )
+ V.visit( tc );
+}
+
+//____________________________________________________________________________//
+
+void
+traverse_test_tree( test_suite const& suite, test_tree_visitor& V )
+{
+ if( !suite.p_enabled || !V.test_suite_start( suite ) )
+ return;
+
+ try {
+ if( runtime_config::random_seed() == 0 ) {
+ BOOST_TEST_FOREACH( test_unit_id, id, suite.m_members )
+ traverse_test_tree( id, V );
+ }
+ else {
+ std::vector<test_unit_id> members( suite.m_members );
+ std::random_shuffle( members.begin(), members.end() );
+ BOOST_TEST_FOREACH( test_unit_id, id, members )
+ traverse_test_tree( id, V );
+ }
+
+ } catch( test_being_aborted const& ) {
+ V.test_suite_finish( suite );
+ framework::test_unit_aborted( suite );
+
+ throw;
+ }
+
+ V.test_suite_finish( suite );
+}
+
+//____________________________________________________________________________//
+
+void
+traverse_test_tree( test_unit_id id, test_tree_visitor& V )
+{
+ if( ut_detail::test_id_2_unit_type( id ) == tut_case )
+ traverse_test_tree( framework::get<test_case>( id ), V );
+ else
+ traverse_test_tree( framework::get<test_suite>( id ), V );
+}
+
+//____________________________________________________________________________//
+
+// ************************************************************************** //
+// ************** test_case_counter ************** //
+// ************************************************************************** //
+
+void
+test_case_counter::visit( test_case const& tc )
+{
+ if( tc.p_enabled )
+ ++p_count.value;
+}
+
+//____________________________________________________________________________//
+
+// ************************************************************************** //
+// ************** object generators ************** //
+// ************************************************************************** //
+
+namespace ut_detail {
+
+std::string
+normalize_test_case_name( const_string name )
+{
+ return ( name[0] == '&'
+ ? std::string( name.begin()+1, name.size()-1 )
+ : std::string( name.begin(), name.size() ) );
+}
+
+//____________________________________________________________________________//
+
+// ************************************************************************** //
+// ************** auto_test_unit_registrar ************** //
+// ************************************************************************** //
+
+auto_test_unit_registrar::auto_test_unit_registrar( test_case* tc, counter_t exp_fail )
+{
+ curr_ts_store().back()->add( tc, exp_fail );
+}
+
+//____________________________________________________________________________//
+
+auto_test_unit_registrar::auto_test_unit_registrar( const_string ts_name )
+{
+ test_unit_id id = curr_ts_store().back()->get( ts_name );
+
+ test_suite* ts;
+
+ if( id != INV_TEST_UNIT_ID ) {
+ ts = &framework::get<test_suite>( id ); // !! test for invalid tu type
+ BOOST_ASSERT( ts->p_parent_id == curr_ts_store().back()->p_id );
+ }
+ else {
+ ts = new test_suite( ts_name );
+ curr_ts_store().back()->add( ts );
+ }
+
+ curr_ts_store().push_back( ts );
+}
+
+//____________________________________________________________________________//
+
+auto_test_unit_registrar::auto_test_unit_registrar( test_unit_generator const& tc_gen )
+{
+ curr_ts_store().back()->add( tc_gen );
+}
+
+//____________________________________________________________________________//
+
+auto_test_unit_registrar::auto_test_unit_registrar( int )
+{
+ if( curr_ts_store().size() == 0 )
+ return; // report error?
+
+ curr_ts_store().pop_back();
+}
+
+//____________________________________________________________________________//
+
+std::list<test_suite*>&
+auto_test_unit_registrar::curr_ts_store()
+{
+ static std::list<test_suite*> inst( 1, &framework::master_test_suite() );
+ return inst;
+}
+
+//____________________________________________________________________________//
+
+} // namespace ut_detail
+
+// ************************************************************************** //
+// ************** global_fixture ************** //
+// ************************************************************************** //
+
+global_fixture::global_fixture()
+{
+ framework::register_observer( *this );
+}
+
+//____________________________________________________________________________//
+
+} // namespace unit_test
+
+} // namespace ndnboost
+
+//____________________________________________________________________________//
+
+#include <ndnboost/test/detail/enable_warnings.hpp>
+
+#endif // BOOST_TEST_UNIT_TEST_SUITE_IPP_012205GER
diff --git a/ndnboost/test/impl/xml_log_formatter.ipp b/ndnboost/test/impl/xml_log_formatter.ipp
new file mode 100644
index 0000000..0bf6460
--- /dev/null
+++ b/ndnboost/test/impl/xml_log_formatter.ipp
@@ -0,0 +1,180 @@
+// (C) Copyright Gennadiy Rozental 2005-2008.
+// Distributed under 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)
+
+// See http://www.boost.org/libs/test for the library home page.
+//
+// File : $RCSfile$
+//
+// Version : $Revision: 57992 $
+//
+// Description : implements XML Log formatter
+// ***************************************************************************
+
+#ifndef BOOST_TEST_XML_LOG_FORMATTER_IPP_020105GER
+#define BOOST_TEST_XML_LOG_FORMATTER_IPP_020105GER
+
+// Boost.Test
+#include <ndnboost/test/output/xml_log_formatter.hpp>
+#include <ndnboost/test/unit_test_suite_impl.hpp>
+#include <ndnboost/test/framework.hpp>
+#include <ndnboost/test/utils/basic_cstring/io.hpp>
+
+#include <ndnboost/test/utils/xml_printer.hpp>
+
+// Boost
+#include <ndnboost/version.hpp>
+
+// STL
+#include <iostream>
+
+#include <ndnboost/test/detail/suppress_warnings.hpp>
+
+//____________________________________________________________________________//
+
+namespace ndnboost {
+
+namespace unit_test {
+
+namespace output {
+
+static const_string tu_type_name( test_unit const& tu )
+{
+ return tu.p_type == tut_case ? "TestCase" : "TestSuite";
+}
+
+// ************************************************************************** //
+// ************** xml_log_formatter ************** //
+// ************************************************************************** //
+
+void
+xml_log_formatter::log_start( std::ostream& ostr, counter_t )
+{
+ ostr << "<TestLog>";
+}
+
+//____________________________________________________________________________//
+
+void
+xml_log_formatter::log_finish( std::ostream& ostr )
+{
+ ostr << "</TestLog>";
+}
+
+//____________________________________________________________________________//
+
+void
+xml_log_formatter::log_build_info( std::ostream& ostr )
+{
+ ostr << "<BuildInfo"
+ << " platform" << attr_value() << BOOST_PLATFORM
+ << " compiler" << attr_value() << BOOST_COMPILER
+ << " stl" << attr_value() << BOOST_STDLIB
+ << " boost=\"" << BOOST_VERSION/100000 << "."
+ << BOOST_VERSION/100 % 1000 << "."
+ << BOOST_VERSION % 100 << '\"'
+ << "/>";
+}
+
+//____________________________________________________________________________//
+
+void
+xml_log_formatter::test_unit_start( std::ostream& ostr, test_unit const& tu )
+{
+ ostr << "<" << tu_type_name( tu ) << " name" << attr_value() << tu.p_name.get() << ">";
+}
+
+//____________________________________________________________________________//
+
+void
+xml_log_formatter::test_unit_finish( std::ostream& ostr, test_unit const& tu, unsigned long elapsed )
+{
+ if( tu.p_type == tut_case )
+ ostr << "<TestingTime>" << elapsed << "</TestingTime>";
+
+ ostr << "</" << tu_type_name( tu ) << ">";
+}
+
+//____________________________________________________________________________//
+
+void
+xml_log_formatter::test_unit_skipped( std::ostream& ostr, test_unit const& tu )
+{
+ ostr << "<" << tu_type_name( tu )
+ << " name" << attr_value() << tu.p_name.get()
+ << " skipped" << attr_value() << "yes"
+ << "/>";
+}
+
+//____________________________________________________________________________//
+
+void
+xml_log_formatter::log_exception( std::ostream& ostr, log_checkpoint_data const& checkpoint_data, execution_exception const& ex )
+{
+ execution_exception::location const& loc = ex.where();
+
+ ostr << "<Exception file" << attr_value() << loc.m_file_name
+ << " line" << attr_value() << loc.m_line_num;
+
+ if( !loc.m_function.is_empty() )
+ ostr << " function" << attr_value() << loc.m_function;
+
+ ostr << ">" << cdata() << ex.what();
+
+ if( !checkpoint_data.m_file_name.is_empty() ) {
+ ostr << "<LastCheckpoint file" << attr_value() << checkpoint_data.m_file_name
+ << " line" << attr_value() << checkpoint_data.m_line_num
+ << ">"
+ << cdata() << checkpoint_data.m_message
+ << "</LastCheckpoint>";
+ }
+
+ ostr << "</Exception>";
+}
+
+//____________________________________________________________________________//
+
+void
+xml_log_formatter::log_entry_start( std::ostream& ostr, log_entry_data const& entry_data, log_entry_types let )
+{
+ static literal_string xml_tags[] = { "Info", "Message", "Warning", "Error", "FatalError" };
+
+ m_curr_tag = xml_tags[let];
+ ostr << '<' << m_curr_tag
+ << BOOST_TEST_L( " file" ) << attr_value() << entry_data.m_file_name
+ << BOOST_TEST_L( " line" ) << attr_value() << entry_data.m_line_num
+ << BOOST_TEST_L( "><![CDATA[" );
+}
+
+//____________________________________________________________________________//
+
+void
+xml_log_formatter::log_entry_value( std::ostream& ostr, const_string value )
+{
+ ostr << value;
+}
+
+//____________________________________________________________________________//
+
+void
+xml_log_formatter::log_entry_finish( std::ostream& ostr )
+{
+ ostr << BOOST_TEST_L( "]]></" ) << m_curr_tag << BOOST_TEST_L( ">" );
+
+ m_curr_tag.clear();
+}
+
+//____________________________________________________________________________//
+
+} // namespace output
+
+} // namespace unit_test
+
+} // namespace ndnboost
+
+//____________________________________________________________________________//
+
+#include <ndnboost/test/detail/enable_warnings.hpp>
+
+#endif // BOOST_TEST_XML_LOG_FORMATTER_IPP_020105GER
diff --git a/ndnboost/test/impl/xml_report_formatter.ipp b/ndnboost/test/impl/xml_report_formatter.ipp
new file mode 100644
index 0000000..92655ee
--- /dev/null
+++ b/ndnboost/test/impl/xml_report_formatter.ipp
@@ -0,0 +1,115 @@
+// (C) Copyright Gennadiy Rozental 2005-2008.
+// Distributed under 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)
+
+// See http://www.boost.org/libs/test for the library home page.
+//
+// File : $RCSfile$
+//
+// Version : $Revision: 49312 $
+//
+// Description : XML report formatter
+// ***************************************************************************
+
+#ifndef BOOST_TEST_XML_REPORT_FORMATTER_IPP_020105GER
+#define BOOST_TEST_XML_REPORT_FORMATTER_IPP_020105GER
+
+// Boost.Test
+#include <ndnboost/test/results_collector.hpp>
+#include <ndnboost/test/unit_test_suite_impl.hpp>
+#include <ndnboost/test/output/xml_report_formatter.hpp>
+
+#include <ndnboost/test/utils/xml_printer.hpp>
+#include <ndnboost/test/utils/basic_cstring/io.hpp>
+
+#include <ndnboost/test/detail/suppress_warnings.hpp>
+
+//____________________________________________________________________________//
+
+namespace ndnboost {
+
+namespace unit_test {
+
+namespace output {
+
+void
+xml_report_formatter::results_report_start( std::ostream& ostr )
+{
+ ostr << "<TestResult>";
+}
+
+//____________________________________________________________________________//
+
+void
+xml_report_formatter::results_report_finish( std::ostream& ostr )
+{
+ ostr << "</TestResult>";
+}
+
+
+//____________________________________________________________________________//
+
+void
+xml_report_formatter::test_unit_report_start( test_unit const& tu, std::ostream& ostr )
+{
+ test_results const& tr = results_collector.results( tu.p_id );
+
+ const_string descr;
+
+ if( tr.passed() )
+ descr = "passed";
+ else if( tr.p_skipped )
+ descr = "skipped";
+ else if( tr.p_aborted )
+ descr = "aborted";
+ else
+ descr = "failed";
+
+ ostr << '<' << ( tu.p_type == tut_case ? "TestCase" : "TestSuite" )
+ << " name" << attr_value() << tu.p_name.get()
+ << " result" << attr_value() << descr
+ << " assertions_passed" << attr_value() << tr.p_assertions_passed
+ << " assertions_failed" << attr_value() << tr.p_assertions_failed
+ << " expected_failures" << attr_value() << tr.p_expected_failures;
+
+ if( tu.p_type == tut_suite )
+ ostr << " test_cases_passed" << attr_value() << tr.p_test_cases_passed
+ << " test_cases_failed" << attr_value() << tr.p_test_cases_failed
+ << " test_cases_skipped" << attr_value() << tr.p_test_cases_skipped
+ << " test_cases_aborted" << attr_value() << tr.p_test_cases_aborted;
+
+
+ ostr << '>';
+}
+
+//____________________________________________________________________________//
+
+void
+xml_report_formatter::test_unit_report_finish( test_unit const& tu, std::ostream& ostr )
+{
+ ostr << "</" << ( tu.p_type == tut_case ? "TestCase" : "TestSuite" ) << '>';
+}
+
+//____________________________________________________________________________//
+
+void
+xml_report_formatter::do_confirmation_report( test_unit const& tu, std::ostream& ostr )
+{
+ test_unit_report_start( tu, ostr );
+ test_unit_report_finish( tu, ostr );
+}
+
+//____________________________________________________________________________//
+
+} // namespace output
+
+} // namespace unit_test
+
+} // namespace ndnboost
+
+//____________________________________________________________________________//
+
+#include <ndnboost/test/detail/enable_warnings.hpp>
+
+#endif // BOOST_TEST_XML_REPORT_FORMATTER_IPP_020105GER
diff --git a/ndnboost/test/interaction_based.hpp b/ndnboost/test/interaction_based.hpp
new file mode 100644
index 0000000..bb38d21
--- /dev/null
+++ b/ndnboost/test/interaction_based.hpp
@@ -0,0 +1,262 @@
+// (C) Copyright Gennadiy Rozental 2005-2008.
+// Distributed under 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)
+
+// See http://www.boost.org/libs/test for the library home page.
+//
+// File : $RCSfile$
+//
+// Version : $Revision: 49312 $
+//
+// Description : Facilities to perform interaction-based testing
+// ***************************************************************************
+
+#ifndef BOOST_TEST_INTERACTION_BASED_HPP_112105GER
+#define BOOST_TEST_INTERACTION_BASED_HPP_112105GER
+
+// Boost.Test
+#include <ndnboost/test/detail/config.hpp>
+#include <ndnboost/test/detail/global_typedef.hpp>
+
+#include <ndnboost/test/utils/wrap_stringstream.hpp>
+
+#include <ndnboost/test/detail/suppress_warnings.hpp>
+
+// Boost
+#include <ndnboost/lexical_cast.hpp>
+
+//____________________________________________________________________________//
+
+// ************************************************************************** //
+// ************** BOOST_ITEST_EPOINT ************** //
+// ************************************************************************** //
+
+#define BOOST_ITEST_EPOINT( description ) \
+ ::ndnboost::itest::manager::instance().exception_point( BOOST_TEST_L(__FILE__), __LINE__, description )
+/**/
+
+// ************************************************************************** //
+// ************** BOOST_ITEST_DPOINT ************** //
+// ************************************************************************** //
+
+#define BOOST_ITEST_DPOINT() \
+ ::ndnboost::itest::manager::instance().decision_point( BOOST_TEST_L(__FILE__), __LINE__ )
+/**/
+
+// ************************************************************************** //
+// ************** BOOST_ITEST_SCOPE ************** //
+// ************************************************************************** //
+
+#define BOOST_ITEST_SCOPE( scope_name ) \
+ ::ndnboost::itest::scope_guard itest_scope_guard ## __LINE__( BOOST_TEST_L(__FILE__), __LINE__, BOOST_STRINGIZE(scope_name) )
+/**/
+
+// ************************************************************************** //
+// ************** BOOST_ITEST_NEW ************** //
+// ************************************************************************** //
+
+#define BOOST_ITEST_NEW( type_name ) \
+ new ( ::ndnboost::itest::location( BOOST_TEST_L(__FILE__), __LINE__ ) ) type_name
+/**/
+
+// ************************************************************************** //
+// ************** BOOST_ITEST_DATA_FLOW ************** //
+// ************************************************************************** //
+
+#define BOOST_ITEST_DATA_FLOW( v ) \
+ ::ndnboost::itest::manager::instance().generic_data_flow( v )
+/**/
+
+// ************************************************************************** //
+// ************** BOOST_ITEST_RETURN ************** //
+// ************************************************************************** //
+
+#define BOOST_ITEST_RETURN( type, default_value ) \
+ ::ndnboost::itest::manager::instance().generic_return<type>( default_value )
+/**/
+
+// ************************************************************************** //
+// ************** BOOST_ITEST_MOCK_FUNC ************** //
+// ************************************************************************** //
+
+#define BOOST_ITEST_MOCK_FUNC( function_name ) \
+ BOOST_ITEST_SCOPE( function_name ); \
+ BOOST_ITEST_EPOINT( 0 ); \
+ return ::ndnboost::itest::mock_object<>::prototype(); \
+/**/
+
+namespace ndnboost {
+
+namespace itest { // interaction-based testing
+
+using unit_test::const_string;
+
+// ************************************************************************** //
+// ************** manager ************** //
+// ************************************************************************** //
+
+class BOOST_TEST_DECL manager {
+public:
+ // instance access
+ static manager& instance() { return *instance_ptr(); }
+
+ // Mock objects interface hooks
+ virtual void exception_point( const_string /*file*/,
+ std::size_t /*line_num*/,
+ const_string /*descr*/ ){}
+ virtual bool decision_point( const_string /*file*/,
+ std::size_t /*line_num*/ ) { return true; }
+ virtual unsigned enter_scope( const_string /*file*/,
+ std::size_t /*line_num*/,
+ const_string /*scope_name*/){ return 0; }
+ virtual void leave_scope( unsigned ) {}
+ virtual void allocated( const_string /*file*/,
+ std::size_t /*line_num*/,
+ void* /*p*/, std::size_t /*s*/ ) {}
+ virtual void freed( void* /*p*/ ) {}
+ virtual void data_flow( const_string /*d*/ ) {}
+ virtual std::string return_value( const_string /*default_value */ ) { return ""; }
+
+ template<typename T>
+ void generic_data_flow( T const& t )
+ {
+ wrap_stringstream ws;
+
+ data_flow( (ws << t).str() );
+ }
+ template<typename T, typename DefaultValueType>
+ T generic_return( DefaultValueType const& dv )
+ {
+ wrap_stringstream ws;
+
+ std::string const& res = return_value( (ws << dv).str() );
+
+ if( res.empty() )
+ return dv;
+
+ return lexical_cast<T>( res );
+ }
+
+protected:
+ manager();
+#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
+public:
+#endif
+ BOOST_TEST_PROTECTED_VIRTUAL ~manager();
+
+private:
+ struct dummy_constr{};
+ explicit manager( dummy_constr* ) {}
+
+ static manager* instance_ptr( bool reset = false, manager* ptr = 0 );
+}; // manager
+
+// ************************************************************************** //
+// ************** scope_guard ************** //
+// ************************************************************************** //
+
+class scope_guard {
+public:
+ // Constructor
+ scope_guard( const_string file, std::size_t line_num, const_string scope_name )
+ {
+ m_scope_index = manager::instance().enter_scope( file, line_num, scope_name );
+ }
+ ~scope_guard()
+ {
+ manager::instance().leave_scope( m_scope_index );
+ }
+
+ unsigned m_scope_index;
+};
+
+// ************************************************************************** //
+// ************** location ************** //
+// ************************************************************************** //
+
+struct location {
+ location( const_string file, std::size_t line )
+ : m_file_name( file )
+ , m_line_num( line )
+ {}
+
+ const_string m_file_name;
+ std::size_t m_line_num;
+};
+
+} // namespace itest
+
+} // namespace ndnboost
+
+// ************************************************************************** //
+// ************** operator new overload ************** //
+// ************************************************************************** //
+
+#if !defined(BOOST_ITEST_NO_NEW_OVERLOADS)
+
+// STL
+#include <cstdlib>
+
+# ifdef BOOST_NO_STDC_NAMESPACE
+namespace std { using ::malloc; using ::free; }
+# endif
+# ifdef _CRTDBG_MAP_ALLOC
+namespace std { using ::_malloc_dbg; using ::_free_dbg; }
+# endif
+
+inline void*
+operator new( std::size_t s, ::ndnboost::itest::location const& l )
+{
+ void* res = std::malloc(s ? s : 1);
+
+ if( res )
+ ::ndnboost::itest::manager::instance().allocated( l.m_file_name, l.m_line_num, res, s );
+ else
+ throw std::bad_alloc();
+
+ return res;
+}
+
+//____________________________________________________________________________//
+
+inline void*
+operator new[]( std::size_t s, ::ndnboost::itest::location const& l )
+{
+ void* res = std::malloc(s ? s : 1);
+
+ if( res )
+ ::ndnboost::itest::manager::instance().allocated( l.m_file_name, l.m_line_num, res, s );
+ else
+ throw std::bad_alloc();
+
+ return res;
+}
+
+//____________________________________________________________________________//
+
+inline void
+operator delete( void* p, ::ndnboost::itest::location const& )
+{
+ ::ndnboost::itest::manager::instance().freed( p );
+
+ std::free( p );
+}
+
+//____________________________________________________________________________//
+
+inline void
+operator delete[]( void* p, ::ndnboost::itest::location const& )
+{
+ ::ndnboost::itest::manager::instance().freed( p );
+
+ std::free( p );
+}
+
+//____________________________________________________________________________//
+
+#endif
+
+#include <ndnboost/test/detail/enable_warnings.hpp>
+
+#endif // BOOST_TEST_INTERACTION_BASED_HPP_112105GER
diff --git a/ndnboost/test/minimal.hpp b/ndnboost/test/minimal.hpp
new file mode 100644
index 0000000..9f4ca44
--- /dev/null
+++ b/ndnboost/test/minimal.hpp
@@ -0,0 +1,143 @@
+// (C) Copyright Gennadiy Rozental 2002-2008.
+// Distributed under 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)
+
+// See http://www.boost.org/libs/test for the library home page.
+//
+// File : $RCSfile$
+//
+// Version : $Revision: 49312 $
+//
+// Description : simple minimal testing definitions and implementation
+// ***************************************************************************
+
+#ifndef BOOST_TEST_MINIMAL_HPP_071894GER
+#define BOOST_TEST_MINIMAL_HPP_071894GER
+
+#define BOOST_CHECK(exp) \
+ ( (exp) \
+ ? static_cast<void>(0) \
+ : ndnboost::minimal_test::report_error(#exp,__FILE__,__LINE__, BOOST_CURRENT_FUNCTION) )
+
+#define BOOST_REQUIRE(exp) \
+ ( (exp) \
+ ? static_cast<void>(0) \
+ : ndnboost::minimal_test::report_critical_error(#exp,__FILE__,__LINE__,BOOST_CURRENT_FUNCTION))
+
+#define BOOST_ERROR( msg_ ) \
+ ndnboost::minimal_test::report_error( (msg_),__FILE__,__LINE__, BOOST_CURRENT_FUNCTION, true )
+#define BOOST_FAIL( msg_ ) \
+ ndnboost::minimal_test::report_critical_error( (msg_),__FILE__,__LINE__, BOOST_CURRENT_FUNCTION, true )
+
+//____________________________________________________________________________//
+
+// Boost.Test
+#include <ndnboost/test/detail/global_typedef.hpp>
+#include <ndnboost/test/impl/execution_monitor.ipp>
+#include <ndnboost/test/impl/debug.ipp>
+#include <ndnboost/test/utils/class_properties.hpp>
+#include <ndnboost/test/utils/basic_cstring/io.hpp>
+
+// Boost
+#include <ndnboost/cstdlib.hpp> // for exit codes#include <ndnboost/cstdlib.hpp> // for exit codes
+#include <ndnboost/current_function.hpp> // for BOOST_CURRENT_FUNCTION
+
+// STL
+#include <iostream> // std::cerr, std::endl
+#include <string> // std::string
+
+#include <ndnboost/test/detail/suppress_warnings.hpp>
+
+//____________________________________________________________________________//
+
+int test_main( int argc, char* argv[] ); // prototype for users test_main()
+
+namespace ndnboost {
+namespace minimal_test {
+
+typedef ndnboost::unit_test::const_string const_string;
+
+inline unit_test::counter_t& errors_counter() { static unit_test::counter_t ec = 0; return ec; }
+
+inline void
+report_error( const char* msg, const char* file, int line, const_string func_name, bool is_msg = false )
+{
+ ++errors_counter();
+ std::cerr << file << "(" << line << "): ";
+
+ if( is_msg )
+ std::cerr << msg;
+ else
+ std::cerr << "test " << msg << " failed";
+
+ if( func_name != "(unknown)" )
+ std::cerr << " in function: '" << func_name << "'";
+
+ std::cerr << std::endl;
+}
+
+inline void
+report_critical_error( const char* msg, const char* file, int line, const_string func_name, bool is_msg = false )
+{
+ report_error( msg, file, line, func_name, is_msg );
+
+ throw ndnboost::execution_aborted();
+}
+
+class caller {
+public:
+ // constructor
+ caller( int argc, char** argv )
+ : m_argc( argc ), m_argv( argv ) {}
+
+ // execution monitor hook implementation
+ int operator()() { return test_main( m_argc, m_argv ); }
+
+private:
+ // Data members
+ int m_argc;
+ char** m_argv;
+}; // monitor
+
+} // namespace minimal_test
+
+} // namespace ndnboost
+
+//____________________________________________________________________________//
+
+int BOOST_TEST_CALL_DECL main( int argc, char* argv[] )
+{
+ using namespace ndnboost::minimal_test;
+
+ try {
+ ::ndnboost::execution_monitor ex_mon;
+ int run_result = ex_mon.execute( caller( argc, argv ) );
+
+ BOOST_CHECK( run_result == 0 || run_result == ndnboost::exit_success );
+ }
+ catch( ndnboost::execution_exception const& exex ) {
+ if( exex.code() != ndnboost::execution_exception::no_error )
+ BOOST_ERROR( (std::string( "exception \"" ).
+ append( exex.what().begin(), exex.what().end() ).
+ append( "\" caught" ) ).c_str() );
+ std::cerr << "\n**** Testing aborted.";
+ }
+
+ if( ndnboost::minimal_test::errors_counter() != 0 ) {
+ std::cerr << "\n**** " << errors_counter()
+ << " error" << (errors_counter() > 1 ? "s" : "" ) << " detected\n";
+
+ return ndnboost::exit_test_failure;
+ }
+
+ std::cout << "\n**** no errors detected\n";
+
+ return ndnboost::exit_success;
+}
+
+//____________________________________________________________________________//
+
+#include <ndnboost/test/detail/enable_warnings.hpp>
+
+#endif // BOOST_TEST_MINIMAL_HPP_071894GER
diff --git a/ndnboost/test/mock_object.hpp b/ndnboost/test/mock_object.hpp
new file mode 100644
index 0000000..f2ad7d0
--- /dev/null
+++ b/ndnboost/test/mock_object.hpp
@@ -0,0 +1,328 @@
+// (C) Copyright Gennadiy Rozental 2005-2008.
+// Distributed under 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)
+
+// See http://www.boost.org/libs/test for the library home page.
+//
+// File : $RCSfile$
+//
+// Version : $Revision: 54633 $
+//
+// Description : Facilities to perform exception safety_tests
+// ***************************************************************************
+
+#ifndef BOOST_TEST_MOCK_OBJECT_HPP_112205GER
+#define BOOST_TEST_MOCK_OBJECT_HPP_112205GER
+
+// Boost.Test
+#include <ndnboost/test/detail/config.hpp>
+#include <ndnboost/test/interaction_based.hpp>
+
+// Boost
+#include <ndnboost/preprocessor/punctuation/comma.hpp>
+
+#include <ndnboost/test/detail/suppress_warnings.hpp>
+
+//____________________________________________________________________________//
+
+namespace ndnboost {
+
+namespace itest {
+
+// ************************************************************************** //
+// ************** mock_object_base ************** //
+// ************************************************************************** //
+
+class mock_object_base {
+public:
+ mock_object_base() {}
+
+ template<typename T1>
+ mock_object_base( T1 const& ) {}
+
+ template<typename T1, typename T2>
+ mock_object_base( T1 const&, T2 const& ) {}
+
+ template<typename T1, typename T2, typename T3>
+ mock_object_base( T1 const&, T2 const&, T3 const& ) {}
+
+ template<typename T1, typename T2, typename T3, typename T4>
+ mock_object_base( T1 const&, T2 const&, T3 const&, T4 const& ) {}
+
+ template<typename T1, typename T2, typename T3, typename T4, typename T5>
+ mock_object_base( T1 const&, T2 const&, T3 const&, T4 const&, T5 const& ) {}
+};
+
+// ************************************************************************** //
+// ************** mock_object implementation helpers ************** //
+// ************************************************************************** //
+
+#define MO_OP_IMPL( op, descr, ret ) \
+ BOOST_ITEST_SCOPE( mock_object::operator op ); \
+ BOOST_ITEST_EPOINT( descr ); \
+ return ret \
+/**/
+
+#define MO_UNARY_OP( op, descr ) \
+self_type const& operator op() const \
+{ \
+ MO_OP_IMPL( op, descr, prototype() ); \
+} \
+/**/
+
+#define MO_UNARY_BOOL_OP( op, descr ) \
+bool operator op() const \
+{ \
+ MO_OP_IMPL( op, descr, (!!BOOST_ITEST_DPOINT()) ); \
+} \
+/**/
+
+#define MO_BINARY_OP( op, descr ) \
+template<int i1, typename Base1,int i2, typename Base2> \
+inline mock_object<i1,Base1> const& \
+operator op( mock_object<i1,Base1> const& mo, \
+ mock_object<i2,Base2> const& ) \
+{ \
+ MO_OP_IMPL( op, descr, mo ); \
+} \
+ \
+template<int i, typename Base, typename T> \
+inline mock_object<i,Base> const& \
+operator op( mock_object<i,Base> const& mo, T const& ) \
+{ \
+ MO_OP_IMPL( op, descr, mo ); \
+} \
+ \
+template<int i, typename Base, typename T> \
+inline mock_object<i,Base> const& \
+operator op( T const&, mock_object<i,Base> const& mo ) \
+{ \
+ MO_OP_IMPL( op, descr, mo ); \
+} \
+/**/
+
+#define MO_BINARY_BOOL_OP( op, descr ) \
+template<int i1, typename Base1,int i2, typename Base2> \
+inline bool \
+operator op( mock_object<i1,Base1> const&, \
+ mock_object<i2,Base2> const& ) \
+{ \
+ MO_OP_IMPL( op, descr, BOOST_ITEST_DPOINT() ); \
+} \
+ \
+template<int i, typename Base, typename T> \
+inline bool \
+operator op( mock_object<i,Base> const&, T const& ) \
+{ \
+ MO_OP_IMPL( op, descr, BOOST_ITEST_DPOINT() ); \
+} \
+ \
+template<int i, typename Base, typename T> \
+inline bool \
+operator op( T const&, mock_object<i,Base> const& ) \
+{ \
+ MO_OP_IMPL( op, descr, BOOST_ITEST_DPOINT() ); \
+} \
+/**/
+
+// ************************************************************************** //
+// ************** mock_object ************** //
+// ************************************************************************** //
+
+template<int i = 0, typename Base=mock_object_base>
+class mock_object;
+
+template<int i, typename Base>
+class mock_object : public Base {
+ // Private typeefs
+ typedef mock_object<i,Base> self_type;
+ struct dummy { void nonnull() {}; };
+ typedef void (dummy::*safe_bool)();
+
+ // prototype constructor
+ mock_object( dummy* ) {}
+
+public:
+ static mock_object& prototype()
+ {
+ static mock_object p( reinterpret_cast<dummy*>(0) );
+ return p;
+ }
+
+ // Constructors
+ mock_object()
+ {
+ BOOST_ITEST_SCOPE( mock_object::mock_object );
+ BOOST_ITEST_EPOINT( "Mock object default constructor" );
+ }
+
+ template<typename T1>
+ mock_object( T1 const& arg1 )
+ : mock_object_base( arg1 )
+ {
+ BOOST_ITEST_SCOPE( mock_object::mock_object );
+ BOOST_ITEST_EPOINT( "Mock object constructor" );
+ }
+
+ template<typename T1, typename T2>
+ mock_object( T1 const& arg1, T2 const& arg2 )
+ : mock_object_base( arg1, arg2 )
+ {
+ BOOST_ITEST_SCOPE( mock_object::mock_object );
+ BOOST_ITEST_EPOINT( "Mock object constructor" );
+ }
+
+ template<typename T1, typename T2, typename T3>
+ mock_object( T1 const& arg1, T2 const& arg2, T3 const& arg3 )
+ : mock_object_base( arg1, arg2, arg3 )
+ {
+ BOOST_ITEST_SCOPE( mock_object::mock_object );
+ BOOST_ITEST_EPOINT( "Mock object constructor" );
+ }
+
+ template<typename T1, typename T2, typename T3, typename T4>
+ mock_object( T1 const& arg1, T2 const& arg2, T3 const& arg3, T4 const& arg4 )
+ : mock_object_base( arg1, arg2, arg3, arg4 )
+ {
+ BOOST_ITEST_SCOPE( mock_object::mock_object );
+ BOOST_ITEST_EPOINT( "Mock object constructor" );
+ }
+
+ template<typename T1, typename T2, typename T3, typename T4, typename T5>
+ mock_object( T1 const& arg1, T2 const& arg2, T3 const& arg3, T4 const& arg4, T5 const& arg5 )
+ : mock_object_base( arg1, arg2, arg3, arg4, arg5 )
+ {
+ BOOST_ITEST_SCOPE( mock_object::mock_object );
+ BOOST_ITEST_EPOINT( "Mock object constructor" );
+ }
+
+ mock_object( mock_object const& )
+ {
+ BOOST_ITEST_SCOPE( mock_object::mock_object );
+ BOOST_ITEST_EPOINT( "Mock object copy constructor" );
+ }
+
+ // assignment
+ self_type const& operator =( mock_object const& ) const
+ {
+ MO_OP_IMPL( =, "Copy assignment", prototype() );
+ }
+
+ template <typename T>
+ self_type const& operator =( T const& ) const
+ {
+ MO_OP_IMPL( =, "Copy assignment", prototype() );
+ }
+
+ // Unary operators
+ MO_UNARY_BOOL_OP( !, "Logical NOT operator" )
+ MO_UNARY_OP( &, "Address-of operator" )
+ MO_UNARY_OP( ~, "One's complement operator" )
+ MO_UNARY_OP( *, "Pointer dereference" )
+ MO_UNARY_OP( +, "Unary plus" )
+
+ // Increment and Decrement
+ MO_UNARY_OP( ++, "Prefix increment" )
+ MO_UNARY_OP( --, "Prefix decrement" )
+ self_type const& operator ++(int) const
+ {
+ MO_OP_IMPL( ++, "Postfix increment", prototype() );
+ }
+ self_type const& operator --(int) const
+ {
+ MO_OP_IMPL( --, "Postfix decrement", prototype() );
+ }
+
+ // Bool context convertion
+ operator safe_bool() const
+ {
+ MO_OP_IMPL( safe_bool, "Bool context conversion",
+ (BOOST_ITEST_DPOINT() ? 0 : &dummy::nonnull) );
+ }
+
+ // Function-call operators
+ self_type const& operator ()() const
+ {
+ MO_OP_IMPL( (), "0-arity function-call", prototype() );
+ }
+ template<typename T1>
+ self_type const& operator ()( T1 const& arg1 ) const
+ {
+ MO_OP_IMPL( (), "1-arity function-call", prototype() );
+ }
+ template<typename T1, typename T2>
+ self_type const& operator ()( T1 const&, T2 const& ) const
+ {
+ MO_OP_IMPL( (), "2-arity function-call", prototype() );
+ }
+ template<typename T1, typename T2, typename T3>
+ self_type const& operator ()( T1 const&, T2 const&, T3 const& ) const
+ {
+ MO_OP_IMPL( (), "3-arity function-call", prototype() );
+ }
+ template<typename T1, typename T2, typename T3, typename T4>
+ self_type const& operator ()( T1 const&, T2 const&, T3 const&, T4 const& ) const
+ {
+ MO_OP_IMPL( (), "4-arity function-call", prototype() );
+ }
+ template<typename T1, typename T2, typename T3, typename T4, typename T5>
+ self_type const& operator ()( T1 const&, T2 const&, T3 const&, T4 const&, T5 const& ) const
+ {
+ MO_OP_IMPL( (), "5-arity function-call", prototype() );
+ }
+
+ // Substripting
+ template<typename T>
+ self_type const& operator []( T const& ) const
+ {
+ MO_OP_IMPL( [], "Substripting", prototype() );
+ }
+
+ // Class member access
+ self_type const* operator->() const
+ {
+ MO_OP_IMPL( ->, "Class member access", this );
+ }
+};
+
+// !! MO_BINARY_OP( BOOST_PP_COMMA(), "Comma operator" )
+
+MO_BINARY_BOOL_OP( !=, "Inequality" )
+MO_BINARY_OP( %, "Modulus" )
+MO_BINARY_OP( %=, "Modulus/assignment" )
+MO_BINARY_OP( &, "Bitwise AND" )
+MO_BINARY_BOOL_OP( &&, "Logical AND" )
+MO_BINARY_OP( &=, "Bitwise AND/assignment" )
+MO_BINARY_OP( *, "Multiplication" )
+MO_BINARY_OP( *=, "Multiplication/assignment" )
+MO_BINARY_OP( +, "Addition" )
+MO_BINARY_OP( +=, "Addition/assignment" )
+//MO_BINARY_OP( -, "Subtraction" )
+MO_BINARY_OP( -=, "Subtraction/assignment" )
+MO_BINARY_OP( ->*, "Pointer-to-member selection" )
+MO_BINARY_OP( /, "Division" )
+MO_BINARY_OP( /=, "Division/assignment" )
+MO_BINARY_BOOL_OP( <, "Less than" )
+MO_BINARY_OP( <<=, "Left shift/assignment" )
+MO_BINARY_BOOL_OP( <=, "Less than or equal to" )
+MO_BINARY_BOOL_OP( ==, "Equality" )
+MO_BINARY_BOOL_OP( >, "Greater than" )
+MO_BINARY_BOOL_OP( >=, "Greater than or equal to" )
+MO_BINARY_OP( >>=, "Right shift/assignment" )
+MO_BINARY_OP( ^, "Exclusive OR" )
+MO_BINARY_OP( ^=, "Exclusive OR/assignment" )
+MO_BINARY_OP( |, "Bitwise inclusive OR" )
+MO_BINARY_OP( |=, "Bitwise inclusive OR/assignment" )
+MO_BINARY_BOOL_OP( ||, "Logical OR" )
+
+MO_BINARY_OP( <<, "Left shift" )
+MO_BINARY_OP( >>, "Right shift" )
+
+} // namespace itest
+
+} // namespace ndnboost
+
+#include <ndnboost/test/detail/enable_warnings.hpp>
+
+#endif // BOOST_TEST_MOCK_OBJECT_HPP_112205GER
diff --git a/ndnboost/test/output/compiler_log_formatter.hpp b/ndnboost/test/output/compiler_log_formatter.hpp
new file mode 100644
index 0000000..acef150
--- /dev/null
+++ b/ndnboost/test/output/compiler_log_formatter.hpp
@@ -0,0 +1,68 @@
+// (C) Copyright Gennadiy Rozental 2005-2008.
+// Distributed under 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)
+
+// See http://www.boost.org/libs/test for the library home page.
+//
+// File : $RCSfile$
+//
+// Version : $Revision: 57992 $
+//
+// Description : contains compiler like Log formatter definition
+// ***************************************************************************
+
+#ifndef BOOST_TEST_COMPILER_LOG_FORMATTER_HPP_020105GER
+#define BOOST_TEST_COMPILER_LOG_FORMATTER_HPP_020105GER
+
+// Boost.Test
+#include <ndnboost/test/detail/global_typedef.hpp>
+#include <ndnboost/test/unit_test_log_formatter.hpp>
+
+#include <ndnboost/test/detail/suppress_warnings.hpp>
+
+//____________________________________________________________________________//
+
+namespace ndnboost {
+
+namespace unit_test {
+
+namespace output {
+
+// ************************************************************************** //
+// ************** compiler_log_formatter ************** //
+// ************************************************************************** //
+
+class BOOST_TEST_DECL compiler_log_formatter : public unit_test_log_formatter {
+public:
+ // Formatter interface
+ void log_start( std::ostream&, counter_t test_cases_amount );
+ void log_finish( std::ostream& );
+ void log_build_info( std::ostream& );
+
+ void test_unit_start( std::ostream&, test_unit const& tu );
+ void test_unit_finish( std::ostream&, test_unit const& tu, unsigned long elapsed );
+ void test_unit_skipped( std::ostream&, test_unit const& tu );
+
+ void log_exception( std::ostream&, log_checkpoint_data const&, execution_exception const& ex );
+
+ void log_entry_start( std::ostream&, log_entry_data const&, log_entry_types let );
+ void log_entry_value( std::ostream&, const_string value );
+ void log_entry_value( std::ostream&, lazy_ostream const& value );
+ void log_entry_finish( std::ostream& );
+
+protected:
+ virtual void print_prefix( std::ostream&, const_string file, std::size_t line );
+};
+
+} // namespace output
+
+} // namespace unit_test
+
+} // namespace ndnboost
+
+//____________________________________________________________________________//
+
+#include <ndnboost/test/detail/enable_warnings.hpp>
+
+#endif // BOOST_TEST_COMPILER_LOG_FORMATTER_HPP_020105GER
diff --git a/ndnboost/test/output/plain_report_formatter.hpp b/ndnboost/test/output/plain_report_formatter.hpp
new file mode 100644
index 0000000..a9bd022
--- /dev/null
+++ b/ndnboost/test/output/plain_report_formatter.hpp
@@ -0,0 +1,62 @@
+// (C) Copyright Gennadiy Rozental 2005-2008.
+// Distributed under 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)
+
+// See http://www.boost.org/libs/test for the library home page.
+//
+// File : $RCSfile$
+//
+// Version : $Revision: 49312 $
+//
+// Description : plain report formatter implementation
+// ***************************************************************************
+
+#ifndef BOOST_TEST_PLAIN_REPORT_FORMATTER_HPP_020105GER
+#define BOOST_TEST_PLAIN_REPORT_FORMATTER_HPP_020105GER
+
+// Boost.Test
+#include <ndnboost/test/detail/global_typedef.hpp>
+#include <ndnboost/test/results_reporter.hpp>
+
+#include <ndnboost/test/detail/suppress_warnings.hpp>
+
+//____________________________________________________________________________//
+
+namespace ndnboost {
+
+namespace unit_test {
+
+namespace output {
+
+// ************************************************************************** //
+// ************** plain_report_formatter ************** //
+// ************************************************************************** //
+
+class plain_report_formatter : public results_reporter::format {
+public:
+ // Formatter interface
+ void results_report_start( std::ostream& ostr );
+ void results_report_finish( std::ostream& ostr );
+
+ void test_unit_report_start( test_unit const&, std::ostream& ostr );
+ void test_unit_report_finish( test_unit const&, std::ostream& ostr );
+
+ void do_confirmation_report( test_unit const&, std::ostream& ostr );
+
+private:
+ // Data members
+ counter_t m_indent;
+};
+
+} // namespace output
+
+} // namespace unit_test
+
+} // namespace ndnboost
+
+//____________________________________________________________________________//
+
+#include <ndnboost/test/detail/enable_warnings.hpp>
+
+#endif // BOOST_TEST_PLAIN_REPORT_FORMATTER_HPP_020105GER
diff --git a/ndnboost/test/output/xml_log_formatter.hpp b/ndnboost/test/output/xml_log_formatter.hpp
new file mode 100644
index 0000000..59ffdcc
--- /dev/null
+++ b/ndnboost/test/output/xml_log_formatter.hpp
@@ -0,0 +1,72 @@
+// (C) Copyright Gennadiy Rozental 2005-2008.
+// Distributed under 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)
+
+// See http://www.boost.org/libs/test for the library home page.
+//
+// File : $RCSfile$
+//
+// Version : $Revision: 57992 $
+//
+// Description : contains XML Log formatter definition
+// ***************************************************************************
+
+#ifndef BOOST_TEST_XML_LOG_FORMATTER_020105GER
+#define BOOST_TEST_XML_LOG_FORMATTER_020105GER
+
+// Boost.Test
+#include <ndnboost/test/detail/global_typedef.hpp>
+#include <ndnboost/test/unit_test_log_formatter.hpp>
+
+// STL
+#include <cstddef> // std::size_t
+
+#include <ndnboost/test/detail/suppress_warnings.hpp>
+
+//____________________________________________________________________________//
+
+namespace ndnboost {
+
+namespace unit_test {
+
+namespace output {
+
+// ************************************************************************** //
+// ************** xml_log_formatter ************** //
+// ************************************************************************** //
+
+class xml_log_formatter : public unit_test_log_formatter {
+public:
+ // Formatter interface
+ void log_start( std::ostream&, counter_t test_cases_amount );
+ void log_finish( std::ostream& );
+ void log_build_info( std::ostream& );
+
+ void test_unit_start( std::ostream&, test_unit const& tu );
+ void test_unit_finish( std::ostream&, test_unit const& tu, unsigned long elapsed );
+ void test_unit_skipped( std::ostream&, test_unit const& tu );
+
+ void log_exception( std::ostream&, log_checkpoint_data const&, execution_exception const& ex );
+
+ void log_entry_start( std::ostream&, log_entry_data const&, log_entry_types let );
+ using unit_test_log_formatter::log_entry_value; // bring base class functions into overload set
+ void log_entry_value( std::ostream&, const_string value );
+ void log_entry_finish( std::ostream& );
+
+private:
+ // Data members
+ const_string m_curr_tag;
+};
+
+} // namespace output
+
+} // namespace unit_test
+
+} // namespace ndnboost
+
+//____________________________________________________________________________//
+
+#include <ndnboost/test/detail/enable_warnings.hpp>
+
+#endif // BOOST_TEST_XML_LOG_FORMATTER_020105GER
diff --git a/ndnboost/test/output/xml_report_formatter.hpp b/ndnboost/test/output/xml_report_formatter.hpp
new file mode 100644
index 0000000..17fbe8d
--- /dev/null
+++ b/ndnboost/test/output/xml_report_formatter.hpp
@@ -0,0 +1,58 @@
+// (C) Copyright Gennadiy Rozental 2005-2008.
+// Distributed under 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)
+
+// See http://www.boost.org/libs/test for the library home page.
+//
+// File : $RCSfile$
+//
+// Version : $Revision: 49312 $
+//
+// Description : XML report formatter implementation
+// ***************************************************************************
+
+#ifndef BOOST_TEST_XML_REPORT_FORMATTER_HPP_020105GER
+#define BOOST_TEST_XML_REPORT_FORMATTER_HPP_020105GER
+
+// Boost.Test
+#include <ndnboost/test/detail/global_typedef.hpp>
+#include <ndnboost/test/results_reporter.hpp>
+
+#include <ndnboost/test/detail/suppress_warnings.hpp>
+
+//____________________________________________________________________________//
+
+namespace ndnboost {
+
+namespace unit_test {
+
+namespace output {
+
+// ************************************************************************** //
+// ************** xml_report_formatter ************** //
+// ************************************************************************** //
+
+class xml_report_formatter : public results_reporter::format {
+public:
+ // Formatter interface
+ void results_report_start( std::ostream& ostr );
+ void results_report_finish( std::ostream& ostr );
+
+ void test_unit_report_start( test_unit const&, std::ostream& ostr );
+ void test_unit_report_finish( test_unit const&, std::ostream& ostr );
+
+ void do_confirmation_report( test_unit const&, std::ostream& ostr );
+};
+
+} // namespace output
+
+} // namespace unit_test
+
+} // namespace ndnboost
+
+//____________________________________________________________________________//
+
+#include <ndnboost/test/detail/enable_warnings.hpp>
+
+#endif // BOOST_TEST_XML_REPORT_FORMATTER_HPP_020105GER
diff --git a/ndnboost/test/output_test_stream.hpp b/ndnboost/test/output_test_stream.hpp
new file mode 100644
index 0000000..a62aaef
--- /dev/null
+++ b/ndnboost/test/output_test_stream.hpp
@@ -0,0 +1,78 @@
+// (C) Copyright Gennadiy Rozental 2001-2008.
+// Distributed under 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)
+
+// See http://www.boost.org/libs/test for the library home page.
+//
+// File : $RCSfile$
+//
+// Version : $Revision: 49312 $
+//
+// Description : output_test_stream class definition
+// ***************************************************************************
+
+#ifndef BOOST_TEST_OUTPUT_TEST_STREAM_HPP_012705GER
+#define BOOST_TEST_OUTPUT_TEST_STREAM_HPP_012705GER
+
+// Boost.Test
+#include <ndnboost/test/detail/global_typedef.hpp>
+#include <ndnboost/test/utils/wrap_stringstream.hpp>
+#include <ndnboost/test/predicate_result.hpp>
+
+// STL
+#include <cstddef> // for std::size_t
+
+#include <ndnboost/test/detail/suppress_warnings.hpp>
+
+//____________________________________________________________________________//
+
+// ************************************************************************** //
+// ************** output_test_stream ************** //
+// ************************************************************************** //
+
+// class to be used to simplify testing of ostream-based output operations
+
+namespace ndnboost {
+
+namespace test_tools {
+
+class BOOST_TEST_DECL output_test_stream : public wrap_stringstream::wrapped_stream {
+ typedef unit_test::const_string const_string;
+ typedef predicate_result result_type;
+public:
+ // Constructor
+ explicit output_test_stream( const_string pattern_file_name = const_string(),
+ bool match_or_save = true,
+ bool text_or_binary = true );
+
+ // Destructor
+ ~output_test_stream();
+
+ // checking function
+ result_type is_empty( bool flush_stream = true );
+ result_type check_length( std::size_t length, bool flush_stream = true );
+ result_type is_equal( const_string arg_, bool flush_stream = true );
+ result_type match_pattern( bool flush_stream = true );
+
+ // explicit flush
+ void flush();
+
+private:
+ // helper functions
+ std::size_t length();
+ void sync();
+
+ struct Impl;
+ Impl* m_pimpl;
+};
+
+} // namespace test_tools
+
+} // namespace ndnboost
+
+//____________________________________________________________________________//
+
+#include <ndnboost/test/detail/enable_warnings.hpp>
+
+#endif // BOOST_TEST_OUTPUT_TEST_STREAM_HPP_012705GER
diff --git a/ndnboost/test/predicate_result.hpp b/ndnboost/test/predicate_result.hpp
new file mode 100644
index 0000000..13dc668
--- /dev/null
+++ b/ndnboost/test/predicate_result.hpp
@@ -0,0 +1,88 @@
+// (C) Copyright Gennadiy Rozental 2001-2008.
+// Distributed under 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)
+
+// See http://www.boost.org/libs/test for the library home page.
+//
+// File : $RCSfile$
+//
+// Version : $Revision: 54633 $
+//
+// Description : enhanced result for test predicate that include message explaining failure
+// ***************************************************************************
+
+#ifndef BOOST_TEST_PREDICATE_RESULT_HPP_012705GER
+#define BOOST_TEST_PREDICATE_RESULT_HPP_012705GER
+
+// Boost.Test
+#include <ndnboost/test/utils/class_properties.hpp>
+#include <ndnboost/test/utils/wrap_stringstream.hpp>
+#include <ndnboost/test/utils/basic_cstring/basic_cstring.hpp>
+
+// Boost
+#include <ndnboost/shared_ptr.hpp>
+#include <ndnboost/detail/workaround.hpp>
+
+// STL
+#include <cstddef> // for std::size_t
+
+#include <ndnboost/test/detail/suppress_warnings.hpp>
+
+//____________________________________________________________________________//
+
+namespace ndnboost {
+
+namespace test_tools {
+
+// ************************************************************************** //
+// ************** predicate_result ************** //
+// ************************************************************************** //
+
+class BOOST_TEST_DECL predicate_result {
+ typedef unit_test::const_string const_string;
+ struct dummy { void nonnull() {}; };
+ typedef void (dummy::*safe_bool)();
+
+public:
+ // Constructor
+ predicate_result( bool pv_ )
+ : p_predicate_value( pv_ )
+ {}
+
+ template<typename BoolConvertable>
+ predicate_result( BoolConvertable const& pv_ ) : p_predicate_value( !!pv_ ) {}
+
+ // Access methods
+ bool operator!() const { return !p_predicate_value; }
+ void operator=( bool pv_ ) { p_predicate_value.value = pv_; }
+ operator safe_bool() const { return !!p_predicate_value ? &dummy::nonnull : 0; }
+
+ // Public properties
+ BOOST_READONLY_PROPERTY( bool, (predicate_result) ) p_predicate_value;
+
+ // Access methods
+ bool has_empty_message() const { return !m_message; }
+ wrap_stringstream& message()
+ {
+ if( !m_message )
+ m_message.reset( new wrap_stringstream );
+
+ return *m_message;
+ }
+ const_string message() const { return !m_message ? const_string() : const_string( m_message->str() ); }
+
+private:
+ // Data members
+ shared_ptr<wrap_stringstream> m_message;
+};
+
+} // namespace test_tools
+
+} // namespace ndnboost
+
+//____________________________________________________________________________//
+
+#include <ndnboost/test/detail/enable_warnings.hpp>
+
+#endif // BOOST_TEST_PREDICATE_RESULT_HPP_012705GER
diff --git a/ndnboost/test/progress_monitor.hpp b/ndnboost/test/progress_monitor.hpp
new file mode 100644
index 0000000..bca78ad
--- /dev/null
+++ b/ndnboost/test/progress_monitor.hpp
@@ -0,0 +1,70 @@
+// (C) Copyright Gennadiy Rozental 2005-2008.
+// Distributed under 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)
+
+// See http://www.boost.org/libs/test for the library home page.
+//
+// File : $RCSfile$
+//
+// Version : $Revision: 49312 $
+//
+// Description : defines simple text based progress monitor
+// ***************************************************************************
+
+#ifndef BOOST_TEST_PROGRESS_MONITOR_HPP_020105GER
+#define BOOST_TEST_PROGRESS_MONITOR_HPP_020105GER
+
+// Boost.Test
+#include <ndnboost/test/test_observer.hpp>
+#include <ndnboost/test/utils/trivial_singleton.hpp>
+
+// STL
+#include <iosfwd> // for std::ostream&
+
+#include <ndnboost/test/detail/suppress_warnings.hpp>
+
+//____________________________________________________________________________//
+
+namespace ndnboost {
+
+namespace unit_test {
+
+// ************************************************************************** //
+// ************** progress_monitor ************** //
+// ************************************************************************** //
+
+class BOOST_TEST_DECL progress_monitor_t : public test_observer, public singleton<progress_monitor_t> {
+public:
+ // test observer interface
+ void test_start( counter_t test_cases_amount );
+ void test_finish() {}
+ void test_aborted();
+
+ void test_unit_start( test_unit const& ) {}
+ void test_unit_finish( test_unit const&, unsigned long );
+ void test_unit_skipped( test_unit const& );
+ void test_unit_aborted( test_unit const& ) {}
+
+ void assertion_result( bool ) {}
+ void exception_caught( execution_exception const& ) {}
+
+ // configuration
+ void set_stream( std::ostream& );
+
+private:
+ BOOST_TEST_SINGLETON_CONS( progress_monitor_t );
+}; // progress_monitor_t
+
+BOOST_TEST_SINGLETON_INST( progress_monitor )
+
+} // namespace unit_test
+
+} // namespace ndnboost
+
+//____________________________________________________________________________//
+
+#include <ndnboost/test/detail/enable_warnings.hpp>
+
+#endif // BOOST_TEST_PROGRESS_MONITOR_HPP_020105GER
+
diff --git a/ndnboost/test/results_collector.hpp b/ndnboost/test/results_collector.hpp
new file mode 100644
index 0000000..858bc51
--- /dev/null
+++ b/ndnboost/test/results_collector.hpp
@@ -0,0 +1,112 @@
+// (C) Copyright Gennadiy Rozental 2001-2008.
+// Distributed under 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)
+
+// See http://www.boost.org/libs/test for the library home page.
+//
+// File : $RCSfile$
+//
+// Version : $Revision: 49312 $
+//
+// Description : defines class unit_test_result that is responsible for
+// gathering test results and presenting this information to end-user
+// ***************************************************************************
+
+#ifndef BOOST_TEST_RESULTS_COLLECTOR_HPP_071894GER
+#define BOOST_TEST_RESULTS_COLLECTOR_HPP_071894GER
+
+// Boost.Test
+#include <ndnboost/test/test_observer.hpp>
+
+#include <ndnboost/test/detail/global_typedef.hpp>
+#include <ndnboost/test/detail/fwd_decl.hpp>
+
+#include <ndnboost/test/utils/trivial_singleton.hpp>
+#include <ndnboost/test/utils/class_properties.hpp>
+
+#include <ndnboost/test/detail/suppress_warnings.hpp>
+
+//____________________________________________________________________________//
+
+namespace ndnboost {
+
+namespace unit_test {
+
+// ************************************************************************** //
+// ************** first failed assertion debugger hook ************** //
+// ************************************************************************** //
+
+namespace {
+inline void first_failed_assertion() {}
+}
+
+// ************************************************************************** //
+// ************** test_results ************** //
+// ************************************************************************** //
+
+class BOOST_TEST_DECL test_results {
+public:
+ test_results();
+
+ typedef BOOST_READONLY_PROPERTY( counter_t, (results_collector_t)(test_results)(results_collect_helper) ) counter_prop;
+ typedef BOOST_READONLY_PROPERTY( bool, (results_collector_t)(test_results)(results_collect_helper) ) bool_prop;
+
+ counter_prop p_assertions_passed;
+ counter_prop p_assertions_failed;
+ counter_prop p_expected_failures;
+ counter_prop p_test_cases_passed;
+ counter_prop p_test_cases_failed;
+ counter_prop p_test_cases_skipped;
+ counter_prop p_test_cases_aborted;
+ bool_prop p_aborted;
+ bool_prop p_skipped;
+
+ // "conclusion" methods
+ bool passed() const;
+ int result_code() const;
+
+ // collection helper
+ void operator+=( test_results const& );
+
+ void clear();
+};
+
+// ************************************************************************** //
+// ************** results_collector ************** //
+// ************************************************************************** //
+
+class BOOST_TEST_DECL results_collector_t : public test_observer, public singleton<results_collector_t> {
+public:
+ // test_observer interface implementation
+ void test_start( counter_t test_cases_amount );
+ void test_finish();
+ void test_aborted();
+
+ void test_unit_start( test_unit const& );
+ void test_unit_finish( test_unit const&, unsigned long elapsed );
+ void test_unit_skipped( test_unit const& );
+ void test_unit_aborted( test_unit const& );
+
+ void assertion_result( bool passed );
+ void exception_caught( execution_exception const& );
+
+ // results access
+ test_results const& results( test_unit_id ) const;
+
+private:
+ BOOST_TEST_SINGLETON_CONS( results_collector_t );
+};
+
+BOOST_TEST_SINGLETON_INST( results_collector )
+
+} // namespace unit_test
+
+} // namespace ndnboost
+
+//____________________________________________________________________________//
+
+#include <ndnboost/test/detail/enable_warnings.hpp>
+
+#endif // BOOST_TEST_RESULTS_COLLECTOR_HPP_071894GER
+
diff --git a/ndnboost/test/results_reporter.hpp b/ndnboost/test/results_reporter.hpp
new file mode 100644
index 0000000..013523c
--- /dev/null
+++ b/ndnboost/test/results_reporter.hpp
@@ -0,0 +1,88 @@
+// (C) Copyright Gennadiy Rozental 2001-2008.
+// Distributed under 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)
+
+// See http://www.boost.org/libs/test for the library home page.
+//
+// File : $RCSfile$
+//
+// Version : $Revision: 49312 $
+//
+// Description : defines class unit_test_result that is responsible for
+// gathering test results and presenting this information to end-user
+// ***************************************************************************
+
+#ifndef BOOST_TEST_RESULTS_REPORTER_HPP_021205GER
+#define BOOST_TEST_RESULTS_REPORTER_HPP_021205GER
+
+// Boost.Test
+#include <ndnboost/test/detail/global_typedef.hpp>
+#include <ndnboost/test/detail/fwd_decl.hpp>
+
+// STL
+#include <iosfwd> // for std::ostream&
+
+#include <ndnboost/test/detail/suppress_warnings.hpp>
+
+//____________________________________________________________________________//
+
+namespace ndnboost {
+
+namespace unit_test {
+
+namespace results_reporter {
+
+// ************************************************************************** //
+// ************** formatter interface ************** //
+// ************************************************************************** //
+
+class BOOST_TEST_DECL format {
+public:
+ // Destructor
+ virtual ~format() {}
+
+ virtual void results_report_start( std::ostream& ostr ) = 0;
+ virtual void results_report_finish( std::ostream& ostr ) = 0;
+
+ virtual void test_unit_report_start( test_unit const&, std::ostream& ostr ) = 0;
+ virtual void test_unit_report_finish( test_unit const&, std::ostream& ostr ) = 0;
+
+ virtual void do_confirmation_report( test_unit const&, std::ostream& ostr ) = 0;
+};
+
+// ************************************************************************** //
+// ************** report configuration ************** //
+// ************************************************************************** //
+
+BOOST_TEST_DECL void set_level( report_level );
+BOOST_TEST_DECL void set_stream( std::ostream& );
+BOOST_TEST_DECL void set_format( output_format );
+BOOST_TEST_DECL void set_format( results_reporter::format* );
+
+BOOST_TEST_DECL std::ostream& get_stream();
+
+// ************************************************************************** //
+// ************** report initiation ************** //
+// ************************************************************************** //
+
+BOOST_TEST_DECL void make_report( report_level l = INV_REPORT_LEVEL, test_unit_id = INV_TEST_UNIT_ID );
+inline void confirmation_report( test_unit_id id = INV_TEST_UNIT_ID )
+{ make_report( CONFIRMATION_REPORT, id ); }
+inline void short_report( test_unit_id id = INV_TEST_UNIT_ID )
+{ make_report( SHORT_REPORT, id ); }
+inline void detailed_report( test_unit_id id = INV_TEST_UNIT_ID )
+{ make_report( DETAILED_REPORT, id ); }
+
+} // namespace results_reporter
+
+} // namespace unit_test
+
+} // namespace ndnboost
+
+//____________________________________________________________________________//
+
+#include <ndnboost/test/detail/enable_warnings.hpp>
+
+#endif // BOOST_TEST_RESULTS_REPORTER_HPP_021205GER
+
diff --git a/ndnboost/test/test_observer.hpp b/ndnboost/test/test_observer.hpp
new file mode 100644
index 0000000..21a0846
--- /dev/null
+++ b/ndnboost/test/test_observer.hpp
@@ -0,0 +1,65 @@
+// (C) Copyright Gennadiy Rozental 2005-2008.
+// Distributed under 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)
+
+// See http://www.boost.org/libs/test for the library home page.
+//
+// File : $RCSfile$
+//
+// Version : $Revision: 49312 $
+//
+// Description : defines abstract interface for test observer
+// ***************************************************************************
+
+#ifndef BOOST_TEST_TEST_OBSERVER_HPP_021005GER
+#define BOOST_TEST_TEST_OBSERVER_HPP_021005GER
+
+// Boost.Test
+#include <ndnboost/test/detail/fwd_decl.hpp>
+#include <ndnboost/test/detail/global_typedef.hpp>
+#include <ndnboost/test/detail/config.hpp>
+
+#include <ndnboost/test/detail/suppress_warnings.hpp>
+
+//____________________________________________________________________________//
+
+namespace ndnboost {
+
+namespace unit_test {
+
+// ************************************************************************** //
+// ************** test_observer ************** //
+// ************************************************************************** //
+
+class BOOST_TEST_DECL test_observer {
+public:
+ // test observer interface
+ virtual void test_start( counter_t /* test_cases_amount */ ) {}
+ virtual void test_finish() {}
+ virtual void test_aborted() {}
+
+ virtual void test_unit_start( test_unit const& ) {}
+ virtual void test_unit_finish( test_unit const&, unsigned long /* elapsed */ ) {}
+ virtual void test_unit_skipped( test_unit const& ) {}
+ virtual void test_unit_aborted( test_unit const& ) {}
+
+ virtual void assertion_result( bool /* passed */ ) {}
+ virtual void exception_caught( execution_exception const& ) {}
+
+ virtual int priority() { return 0; }
+
+protected:
+ BOOST_TEST_PROTECTED_VIRTUAL ~test_observer() {}
+};
+
+} // unit_test
+
+} // namespace ndnboost
+
+//____________________________________________________________________________//
+
+#include <ndnboost/test/detail/enable_warnings.hpp>
+
+#endif // BOOST_TEST_TEST_OBSERVER_HPP_021005GER
+
diff --git a/ndnboost/test/test_tools.hpp b/ndnboost/test/test_tools.hpp
new file mode 100644
index 0000000..49a0f73
--- /dev/null
+++ b/ndnboost/test/test_tools.hpp
@@ -0,0 +1,719 @@
+// (C) Copyright Gennadiy Rozental 2001-2008.
+// Distributed under 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)
+
+// See http://www.boost.org/libs/test for the library home page.
+//
+// File : $RCSfile$
+//
+// Version : $Revision: 54633 $
+//
+// Description : contains definition for all test tools in test toolbox
+// ***************************************************************************
+
+#ifndef BOOST_TEST_TEST_TOOLS_HPP_012705GER
+#define BOOST_TEST_TEST_TOOLS_HPP_012705GER
+
+// Boost.Test
+#include <ndnboost/test/predicate_result.hpp>
+#include <ndnboost/test/unit_test_log.hpp>
+#include <ndnboost/test/floating_point_comparison.hpp>
+
+#include <ndnboost/test/detail/config.hpp>
+#include <ndnboost/test/detail/global_typedef.hpp>
+#include <ndnboost/test/detail/workaround.hpp>
+
+#include <ndnboost/test/utils/wrap_stringstream.hpp>
+#include <ndnboost/test/utils/basic_cstring/io.hpp>
+#include <ndnboost/test/utils/lazy_ostream.hpp>
+
+// Boost
+#include <ndnboost/preprocessor/seq/for_each.hpp>
+#include <ndnboost/preprocessor/seq/size.hpp>
+#include <ndnboost/preprocessor/seq/enum.hpp>
+#include <ndnboost/preprocessor/repetition/repeat.hpp>
+#include <ndnboost/preprocessor/punctuation/comma_if.hpp>
+#include <ndnboost/preprocessor/arithmetic/add.hpp>
+
+#include <ndnboost/limits.hpp>
+
+#include <ndnboost/type_traits/is_array.hpp>
+#include <ndnboost/type_traits/is_function.hpp>
+#include <ndnboost/type_traits/is_abstract.hpp>
+
+#include <ndnboost/mpl/or.hpp>
+
+// STL
+#include <cstddef> // for std::size_t
+#include <iosfwd>
+#include <ios> // for std::boolalpha
+#include <climits> // for CHAR_BIT
+
+#ifdef BOOST_MSVC
+# pragma warning(disable: 4127) // conditional expression is constant
+#endif
+
+#include <ndnboost/test/detail/suppress_warnings.hpp>
+
+//____________________________________________________________________________//
+
+// ************************************************************************** //
+// ************** TOOL BOX ************** //
+// ************************************************************************** //
+
+// In macros below following argument abbreviations are used:
+// P - predicate
+// M - message
+// S - statement
+// E - exception
+// L - left argument
+// R - right argument
+// TL - tool level
+// CT - check type
+// ARGS - arguments list
+
+#define BOOST_TEST_TOOL_IMPL( func, P, check_descr, TL, CT ) \
+ ::ndnboost::test_tools::tt_detail::func( \
+ P, \
+ ::ndnboost::unit_test::lazy_ostream::instance() << check_descr, \
+ BOOST_TEST_L(__FILE__), \
+ static_cast<std::size_t>(__LINE__), \
+ ::ndnboost::test_tools::tt_detail::TL, \
+ ::ndnboost::test_tools::tt_detail::CT \
+/**/
+
+//____________________________________________________________________________//
+
+#define BOOST_CHECK_IMPL( P, check_descr, TL, CT ) \
+do { \
+ BOOST_TEST_PASSPOINT(); \
+ BOOST_TEST_TOOL_IMPL( check_impl, P, check_descr, TL, CT ), 0 );\
+} while( ::ndnboost::test_tools::dummy_cond ) \
+/**/
+
+//____________________________________________________________________________//
+
+#define BOOST_TEST_PASS_ARG_INFO( r, data, arg ) , arg, BOOST_STRINGIZE( arg )
+
+#define BOOST_CHECK_WITH_ARGS_IMPL( P, check_descr, TL, CT, ARGS ) \
+do { \
+ BOOST_TEST_PASSPOINT(); \
+ BOOST_TEST_TOOL_IMPL( check_frwd, P, check_descr, TL, CT ) \
+ BOOST_PP_SEQ_FOR_EACH( BOOST_TEST_PASS_ARG_INFO, '_', ARGS ) ); \
+} while( ::ndnboost::test_tools::dummy_cond ) \
+/**/
+
+//____________________________________________________________________________//
+
+#define BOOST_WARN( P ) BOOST_CHECK_IMPL( (P), BOOST_TEST_STRINGIZE( P ), WARN, CHECK_PRED )
+#define BOOST_CHECK( P ) BOOST_CHECK_IMPL( (P), BOOST_TEST_STRINGIZE( P ), CHECK, CHECK_PRED )
+#define BOOST_REQUIRE( P ) BOOST_CHECK_IMPL( (P), BOOST_TEST_STRINGIZE( P ), REQUIRE, CHECK_PRED )
+
+//____________________________________________________________________________//
+
+#define BOOST_WARN_MESSAGE( P, M ) BOOST_CHECK_IMPL( (P), M, WARN, CHECK_MSG )
+#define BOOST_CHECK_MESSAGE( P, M ) BOOST_CHECK_IMPL( (P), M, CHECK, CHECK_MSG )
+#define BOOST_REQUIRE_MESSAGE( P, M ) BOOST_CHECK_IMPL( (P), M, REQUIRE, CHECK_MSG )
+
+//____________________________________________________________________________//
+
+#define BOOST_ERROR( M ) BOOST_CHECK_MESSAGE( false, M )
+#define BOOST_FAIL( M ) BOOST_REQUIRE_MESSAGE( false, M )
+
+//____________________________________________________________________________//
+
+#define BOOST_CHECK_THROW_IMPL( S, E, P, prefix, TL ) \
+ try { \
+ BOOST_TEST_PASSPOINT(); \
+ S; \
+ BOOST_CHECK_IMPL( false, "exception " BOOST_STRINGIZE( E ) " is expected", TL, CHECK_MSG ); } \
+ catch( E const& ex ) { \
+ ::ndnboost::unit_test::ut_detail::ignore_unused_variable_warning( ex ); \
+ BOOST_CHECK_IMPL( P, prefix BOOST_STRINGIZE( E ) " is caught", TL, CHECK_MSG ); \
+ } \
+/**/
+
+//____________________________________________________________________________//
+
+#define BOOST_WARN_THROW( S, E ) BOOST_CHECK_THROW_IMPL( S, E, true, "exception ", WARN )
+#define BOOST_CHECK_THROW( S, E ) BOOST_CHECK_THROW_IMPL( S, E, true, "exception ", CHECK )
+#define BOOST_REQUIRE_THROW( S, E ) BOOST_CHECK_THROW_IMPL( S, E, true, "exception ", REQUIRE )
+
+//____________________________________________________________________________//
+
+#define BOOST_WARN_EXCEPTION( S, E, P ) BOOST_CHECK_THROW_IMPL( S, E, P( ex ), "incorrect exception ", WARN )
+#define BOOST_CHECK_EXCEPTION( S, E, P ) BOOST_CHECK_THROW_IMPL( S, E, P( ex ), "incorrect exception ", CHECK )
+#define BOOST_REQUIRE_EXCEPTION( S, E, P ) BOOST_CHECK_THROW_IMPL( S, E, P( ex ), "incorrect exception ", REQUIRE )
+
+//____________________________________________________________________________//
+
+#define BOOST_CHECK_NO_THROW_IMPL( S, TL ) \
+ try { \
+ S; \
+ BOOST_CHECK_IMPL( true, "no exceptions thrown by " BOOST_STRINGIZE( S ), TL, CHECK_MSG ); } \
+ catch( ... ) { \
+ BOOST_CHECK_IMPL( false, "exception thrown by " BOOST_STRINGIZE( S ), TL, CHECK_MSG ); \
+ } \
+/**/
+
+#define BOOST_WARN_NO_THROW( S ) BOOST_CHECK_NO_THROW_IMPL( S, WARN )
+#define BOOST_CHECK_NO_THROW( S ) BOOST_CHECK_NO_THROW_IMPL( S, CHECK )
+#define BOOST_REQUIRE_NO_THROW( S ) BOOST_CHECK_NO_THROW_IMPL( S, REQUIRE )
+
+//____________________________________________________________________________//
+
+#define BOOST_WARN_EQUAL( L, R ) \
+ BOOST_CHECK_WITH_ARGS_IMPL( ::ndnboost::test_tools::tt_detail::equal_impl_frwd(), "", WARN, CHECK_EQUAL, (L)(R) )
+#define BOOST_CHECK_EQUAL( L, R ) \
+ BOOST_CHECK_WITH_ARGS_IMPL( ::ndnboost::test_tools::tt_detail::equal_impl_frwd(), "", CHECK, CHECK_EQUAL, (L)(R) )
+#define BOOST_REQUIRE_EQUAL( L, R ) \
+ BOOST_CHECK_WITH_ARGS_IMPL( ::ndnboost::test_tools::tt_detail::equal_impl_frwd(), "", REQUIRE, CHECK_EQUAL, (L)(R) )
+
+//____________________________________________________________________________//
+
+#define BOOST_WARN_NE( L, R ) \
+ BOOST_CHECK_WITH_ARGS_IMPL( ::ndnboost::test_tools::tt_detail::ne_impl(), "", WARN, CHECK_NE, (L)(R) )
+#define BOOST_CHECK_NE( L, R ) \
+ BOOST_CHECK_WITH_ARGS_IMPL( ::ndnboost::test_tools::tt_detail::ne_impl(), "", CHECK, CHECK_NE, (L)(R) )
+#define BOOST_REQUIRE_NE( L, R ) \
+ BOOST_CHECK_WITH_ARGS_IMPL( ::ndnboost::test_tools::tt_detail::ne_impl(), "", REQUIRE, CHECK_NE, (L)(R) )
+
+//____________________________________________________________________________//
+
+#define BOOST_WARN_LT( L, R ) \
+ BOOST_CHECK_WITH_ARGS_IMPL( ::ndnboost::test_tools::tt_detail::lt_impl(), "", WARN, CHECK_LT, (L)(R) )
+#define BOOST_CHECK_LT( L, R ) \
+ BOOST_CHECK_WITH_ARGS_IMPL( ::ndnboost::test_tools::tt_detail::lt_impl(), "", CHECK, CHECK_LT, (L)(R) )
+#define BOOST_REQUIRE_LT( L, R ) \
+ BOOST_CHECK_WITH_ARGS_IMPL( ::ndnboost::test_tools::tt_detail::lt_impl(), "", REQUIRE, CHECK_LT, (L)(R) )
+
+//____________________________________________________________________________//
+
+#define BOOST_WARN_LE( L, R ) \
+ BOOST_CHECK_WITH_ARGS_IMPL( ::ndnboost::test_tools::tt_detail::le_impl(), "", WARN, CHECK_LE, (L)(R) )
+#define BOOST_CHECK_LE( L, R ) \
+ BOOST_CHECK_WITH_ARGS_IMPL( ::ndnboost::test_tools::tt_detail::le_impl(), "", CHECK, CHECK_LE, (L)(R) )
+#define BOOST_REQUIRE_LE( L, R ) \
+ BOOST_CHECK_WITH_ARGS_IMPL( ::ndnboost::test_tools::tt_detail::le_impl(), "", REQUIRE, CHECK_LE, (L)(R) )
+
+//____________________________________________________________________________//
+
+#define BOOST_WARN_GT( L, R ) \
+ BOOST_CHECK_WITH_ARGS_IMPL( ::ndnboost::test_tools::tt_detail::gt_impl(), "", WARN, CHECK_GT, (L)(R) )
+#define BOOST_CHECK_GT( L, R ) \
+ BOOST_CHECK_WITH_ARGS_IMPL( ::ndnboost::test_tools::tt_detail::gt_impl(), "", CHECK, CHECK_GT, (L)(R) )
+#define BOOST_REQUIRE_GT( L, R ) \
+ BOOST_CHECK_WITH_ARGS_IMPL( ::ndnboost::test_tools::tt_detail::gt_impl(), "", REQUIRE, CHECK_GT, (L)(R) )
+
+//____________________________________________________________________________//
+
+#define BOOST_WARN_GE( L, R ) \
+ BOOST_CHECK_WITH_ARGS_IMPL( ::ndnboost::test_tools::tt_detail::ge_impl(), "", WARN, CHECK_GE, (L)(R) )
+#define BOOST_CHECK_GE( L, R ) \
+ BOOST_CHECK_WITH_ARGS_IMPL( ::ndnboost::test_tools::tt_detail::ge_impl(), "", CHECK, CHECK_GE, (L)(R) )
+#define BOOST_REQUIRE_GE( L, R ) \
+ BOOST_CHECK_WITH_ARGS_IMPL( ::ndnboost::test_tools::tt_detail::ge_impl(), "", REQUIRE, CHECK_GE, (L)(R) )
+
+//____________________________________________________________________________//
+
+#define BOOST_WARN_CLOSE( L, R, T ) \
+ BOOST_CHECK_WITH_ARGS_IMPL( ::ndnboost::test_tools::check_is_close, "", WARN, CHECK_CLOSE, \
+ (L)(R)(::ndnboost::test_tools::percent_tolerance(T)) )
+#define BOOST_CHECK_CLOSE( L, R, T ) \
+ BOOST_CHECK_WITH_ARGS_IMPL( ::ndnboost::test_tools::check_is_close, "", CHECK, CHECK_CLOSE, \
+ (L)(R)(::ndnboost::test_tools::percent_tolerance(T)) )
+#define BOOST_REQUIRE_CLOSE( L, R, T ) \
+ BOOST_CHECK_WITH_ARGS_IMPL( ::ndnboost::test_tools::check_is_close, "", REQUIRE, CHECK_CLOSE, \
+ (L)(R)(::ndnboost::test_tools::percent_tolerance(T)) )
+
+//____________________________________________________________________________//
+
+#define BOOST_WARN_CLOSE_FRACTION( L, R, T ) \
+ BOOST_CHECK_WITH_ARGS_IMPL( ::ndnboost::test_tools::check_is_close, "", WARN, CHECK_CLOSE_FRACTION, \
+ (L)(R)(::ndnboost::test_tools::fraction_tolerance(T)) )
+#define BOOST_CHECK_CLOSE_FRACTION( L, R, T ) \
+ BOOST_CHECK_WITH_ARGS_IMPL( ::ndnboost::test_tools::check_is_close, "", CHECK, CHECK_CLOSE_FRACTION, \
+ (L)(R)(::ndnboost::test_tools::fraction_tolerance(T)) )
+#define BOOST_REQUIRE_CLOSE_FRACTION( L, R, T ) \
+ BOOST_CHECK_WITH_ARGS_IMPL( ::ndnboost::test_tools::check_is_close, "", REQUIRE, CHECK_CLOSE_FRACTION, \
+ (L)(R)(::ndnboost::test_tools::fraction_tolerance(T)) )
+
+//____________________________________________________________________________//
+
+#define BOOST_WARN_SMALL( FPV, T ) \
+ BOOST_CHECK_WITH_ARGS_IMPL( ::ndnboost::test_tools::check_is_small, "", WARN, CHECK_SMALL, (FPV)(T) )
+#define BOOST_CHECK_SMALL( FPV, T ) \
+ BOOST_CHECK_WITH_ARGS_IMPL( ::ndnboost::test_tools::check_is_small, "", CHECK, CHECK_SMALL, (FPV)(T) )
+#define BOOST_REQUIRE_SMALL( FPV, T ) \
+ BOOST_CHECK_WITH_ARGS_IMPL( ::ndnboost::test_tools::check_is_small, "", REQUIRE, CHECK_SMALL, (FPV)(T) )
+
+//____________________________________________________________________________//
+
+#define BOOST_WARN_PREDICATE( P, ARGS ) \
+ BOOST_CHECK_WITH_ARGS_IMPL( P, BOOST_TEST_STRINGIZE( P ), WARN, CHECK_PRED_WITH_ARGS, ARGS )
+#define BOOST_CHECK_PREDICATE( P, ARGS ) \
+ BOOST_CHECK_WITH_ARGS_IMPL( P, BOOST_TEST_STRINGIZE( P ), CHECK, CHECK_PRED_WITH_ARGS, ARGS )
+#define BOOST_REQUIRE_PREDICATE( P, ARGS ) \
+ BOOST_CHECK_WITH_ARGS_IMPL( P, BOOST_TEST_STRINGIZE( P ), REQUIRE, CHECK_PRED_WITH_ARGS, ARGS )
+
+//____________________________________________________________________________//
+
+#define BOOST_EQUAL_COLLECTIONS_IMPL( L_begin, L_end, R_begin, R_end, TL ) \
+ BOOST_TEST_TOOL_IMPL( check_impl, ::ndnboost::test_tools::tt_detail::equal_coll_impl( \
+ (L_begin), (L_end), (R_begin), (R_end) ), "", TL, CHECK_EQUAL_COLL ), \
+ 4, \
+ BOOST_STRINGIZE( L_begin ), BOOST_STRINGIZE( L_end ), \
+ BOOST_STRINGIZE( R_begin ), BOOST_STRINGIZE( R_end ) ) \
+/**/
+
+#define BOOST_WARN_EQUAL_COLLECTIONS( L_begin, L_end, R_begin, R_end ) \
+ BOOST_EQUAL_COLLECTIONS_IMPL( L_begin, L_end, R_begin, R_end, WARN )
+#define BOOST_CHECK_EQUAL_COLLECTIONS( L_begin, L_end, R_begin, R_end ) \
+ BOOST_EQUAL_COLLECTIONS_IMPL( L_begin, L_end, R_begin, R_end, CHECK )
+#define BOOST_REQUIRE_EQUAL_COLLECTIONS( L_begin, L_end, R_begin, R_end ) \
+ BOOST_EQUAL_COLLECTIONS_IMPL( L_begin, L_end, R_begin, R_end, REQUIRE )
+
+//____________________________________________________________________________//
+
+#define BOOST_BITWISE_EQUAL_IMPL( L, R, TL ) \
+ BOOST_TEST_TOOL_IMPL( check_impl, \
+ ::ndnboost::test_tools::tt_detail::bitwise_equal_impl( (L), (R) ), \
+ "", TL, CHECK_BITWISE_EQUAL ), \
+ 2, BOOST_STRINGIZE( L ), BOOST_STRINGIZE( R ) ) \
+/**/
+
+#define BOOST_WARN_BITWISE_EQUAL( L, R ) BOOST_BITWISE_EQUAL_IMPL( L, R, WARN )
+#define BOOST_CHECK_BITWISE_EQUAL( L, R ) BOOST_BITWISE_EQUAL_IMPL( L, R, CHECK )
+#define BOOST_REQUIRE_BITWISE_EQUAL( L, R ) BOOST_BITWISE_EQUAL_IMPL( L, R, REQUIRE )
+
+//____________________________________________________________________________//
+
+#define BOOST_IS_DEFINED( symb ) ::ndnboost::test_tools::tt_detail::is_defined_impl( #symb, BOOST_STRINGIZE(= symb) )
+
+//____________________________________________________________________________//
+
+// ***************************** //
+// deprecated interface
+
+#define BOOST_BITWISE_EQUAL( L, R ) BOOST_CHECK_BITWISE_EQUAL( L, R )
+#define BOOST_MESSAGE( M ) BOOST_TEST_MESSAGE( M )
+#define BOOST_CHECKPOINT( M ) BOOST_TEST_CHECKPOINT( M )
+
+namespace ndnboost {
+
+namespace test_tools {
+
+typedef unit_test::const_string const_string;
+
+namespace { bool dummy_cond = false; }
+
+// ************************************************************************** //
+// ************** print_log_value ************** //
+// ************************************************************************** //
+
+template<typename T>
+struct print_log_value {
+ void operator()( std::ostream& ostr, T const& t )
+ {
+ // avoid warning: 'ndnboost::test_tools::<unnamed>::dummy_cond' defined but not used
+ if (::ndnboost::test_tools::dummy_cond) {}
+
+ typedef typename mpl::or_<is_array<T>,is_function<T>,is_abstract<T> >::type cant_use_nl;
+
+ set_precision( ostr, cant_use_nl() );
+
+ ostr << t; // by default print the value
+ }
+
+ void set_precision( std::ostream& ostr, mpl::false_ )
+ {
+ if( std::numeric_limits<T>::is_specialized && std::numeric_limits<T>::radix == 2 )
+ ostr.precision( 2 + std::numeric_limits<T>::digits * 301/1000 );
+ }
+
+ void set_precision( std::ostream&, mpl::true_ ) {}
+};
+
+//____________________________________________________________________________//
+
+#define BOOST_TEST_DONT_PRINT_LOG_VALUE( the_type ) \
+namespace ndnboost { namespace test_tools { \
+template<> \
+struct print_log_value<the_type > { \
+ void operator()( std::ostream&, the_type const& ) {} \
+}; \
+}} \
+/**/
+
+//____________________________________________________________________________//
+
+#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
+template<typename T, std::size_t N >
+struct print_log_value< T[N] > {
+ void operator()( std::ostream& ostr, T const* t )
+ {
+ ostr << t;
+ }
+};
+#endif
+
+//____________________________________________________________________________//
+
+template<>
+struct BOOST_TEST_DECL print_log_value<bool> {
+ void operator()( std::ostream& ostr, bool t )
+ {
+ ostr << std::boolalpha << t;
+ }
+};
+
+//____________________________________________________________________________//
+
+template<>
+struct BOOST_TEST_DECL print_log_value<char> {
+ void operator()( std::ostream& ostr, char t );
+};
+
+//____________________________________________________________________________//
+
+template<>
+struct BOOST_TEST_DECL print_log_value<unsigned char> {
+ void operator()( std::ostream& ostr, unsigned char t );
+};
+
+//____________________________________________________________________________//
+
+template<>
+struct BOOST_TEST_DECL print_log_value<char const*> {
+ void operator()( std::ostream& ostr, char const* t );
+};
+
+//____________________________________________________________________________//
+
+template<>
+struct BOOST_TEST_DECL print_log_value<wchar_t const*> {
+ void operator()( std::ostream& ostr, wchar_t const* t );
+};
+
+//____________________________________________________________________________//
+
+namespace tt_detail {
+
+// ************************************************************************** //
+// ************** tools classification ************** //
+// ************************************************************************** //
+
+enum check_type {
+ CHECK_PRED,
+ CHECK_MSG,
+ CHECK_EQUAL,
+ CHECK_NE,
+ CHECK_LT,
+ CHECK_LE,
+ CHECK_GT,
+ CHECK_GE,
+ CHECK_CLOSE,
+ CHECK_CLOSE_FRACTION,
+ CHECK_SMALL,
+ CHECK_BITWISE_EQUAL,
+ CHECK_PRED_WITH_ARGS,
+ CHECK_EQUAL_COLL
+};
+
+enum tool_level {
+ WARN, CHECK, REQUIRE, PASS
+};
+
+// ************************************************************************** //
+// ************** print_helper ************** //
+// ************************************************************************** //
+// Adds level of indirection to the output operation, allowing us to customize
+// it for types that do not support operator << directly or for any other reason
+
+template<typename T>
+struct print_helper_t {
+ explicit print_helper_t( T const& t ) : m_t( t ) {}
+
+ T const& m_t;
+};
+
+//____________________________________________________________________________//
+
+#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
+// Borland suffers premature pointer decay passing arrays by reference
+template<typename T, std::size_t N >
+struct print_helper_t< T[N] > {
+ explicit print_helper_t( T const * t ) : m_t( t ) {}
+
+ T const * m_t;
+};
+#endif
+
+//____________________________________________________________________________//
+
+template<typename T>
+inline print_helper_t<T> print_helper( T const& t )
+{
+ return print_helper_t<T>( t );
+}
+
+//____________________________________________________________________________//
+
+template<typename T>
+inline std::ostream&
+operator<<( std::ostream& ostr, print_helper_t<T> const& ph )
+{
+ print_log_value<T>()( ostr, ph.m_t );
+
+ return ostr;
+}
+
+//____________________________________________________________________________//
+
+// ************************************************************************** //
+// ************** TOOL BOX Implementation ************** //
+// ************************************************************************** //
+
+BOOST_TEST_DECL
+bool check_impl( predicate_result const& pr, ::ndnboost::unit_test::lazy_ostream const& check_descr,
+ const_string file_name, std::size_t line_num,
+ tool_level tl, check_type ct,
+ std::size_t num_args, ... );
+
+//____________________________________________________________________________//
+
+#define TEMPL_PARAMS( z, m, dummy ) , typename BOOST_JOIN( Arg, m )
+#define FUNC_PARAMS( z, m, dummy ) \
+ , BOOST_JOIN( Arg, m ) const& BOOST_JOIN( arg, m ) \
+ , char const* BOOST_JOIN( BOOST_JOIN( arg, m ), _descr ) \
+/**/
+
+#define PRED_PARAMS( z, m, dummy ) BOOST_PP_COMMA_IF( m ) BOOST_JOIN( arg, m )
+
+#define ARG_INFO( z, m, dummy ) \
+ , BOOST_JOIN( BOOST_JOIN( arg, m ), _descr ) \
+ , &static_cast<const unit_test::lazy_ostream&>(unit_test::lazy_ostream::instance() \
+ << ::ndnboost::test_tools::tt_detail::print_helper( BOOST_JOIN( arg, m ) )) \
+/**/
+
+#define IMPL_FRWD( z, n, dummy ) \
+template<typename Pred \
+ BOOST_PP_REPEAT_ ## z( BOOST_PP_ADD( n, 1 ), TEMPL_PARAMS, _ )> \
+inline bool \
+check_frwd( Pred P, unit_test::lazy_ostream const& check_descr, \
+ const_string file_name, std::size_t line_num, \
+ tool_level tl, check_type ct \
+ BOOST_PP_REPEAT_ ## z( BOOST_PP_ADD( n, 1 ), FUNC_PARAMS, _ ) \
+) \
+{ \
+ return \
+ check_impl( P( BOOST_PP_REPEAT_ ## z( BOOST_PP_ADD( n, 1 ), PRED_PARAMS, _ ) ), \
+ check_descr, file_name, line_num, tl, ct, \
+ BOOST_PP_ADD( n, 1 ) \
+ BOOST_PP_REPEAT_ ## z( BOOST_PP_ADD( n, 1 ), ARG_INFO, _ ) \
+ ); \
+} \
+/**/
+
+#ifndef BOOST_TEST_MAX_PREDICATE_ARITY
+#define BOOST_TEST_MAX_PREDICATE_ARITY 5
+#endif
+
+BOOST_PP_REPEAT( BOOST_TEST_MAX_PREDICATE_ARITY, IMPL_FRWD, _ )
+
+#undef TEMPL_PARAMS
+#undef FUNC_PARAMS
+#undef PRED_INFO
+#undef ARG_INFO
+#undef IMPL_FRWD
+
+//____________________________________________________________________________//
+
+template <class Left, class Right>
+predicate_result equal_impl( Left const& left, Right const& right )
+{
+ return left == right;
+}
+
+//____________________________________________________________________________//
+
+predicate_result BOOST_TEST_DECL equal_impl( char const* left, char const* right );
+inline predicate_result equal_impl( char* left, char const* right ) { return equal_impl( static_cast<char const*>(left), static_cast<char const*>(right) ); }
+inline predicate_result equal_impl( char const* left, char* right ) { return equal_impl( static_cast<char const*>(left), static_cast<char const*>(right) ); }
+inline predicate_result equal_impl( char* left, char* right ) { return equal_impl( static_cast<char const*>(left), static_cast<char const*>(right) ); }
+
+#if !defined( BOOST_NO_CWCHAR )
+predicate_result BOOST_TEST_DECL equal_impl( wchar_t const* left, wchar_t const* right );
+inline predicate_result equal_impl( wchar_t* left, wchar_t const* right ) { return equal_impl( static_cast<wchar_t const*>(left), static_cast<wchar_t const*>(right) ); }
+inline predicate_result equal_impl( wchar_t const* left, wchar_t* right ) { return equal_impl( static_cast<wchar_t const*>(left), static_cast<wchar_t const*>(right) ); }
+inline predicate_result equal_impl( wchar_t* left, wchar_t* right ) { return equal_impl( static_cast<wchar_t const*>(left), static_cast<wchar_t const*>(right) ); }
+#endif
+
+//____________________________________________________________________________//
+
+struct equal_impl_frwd {
+ template <typename Left, typename Right>
+ inline predicate_result
+ call_impl( Left const& left, Right const& right, mpl::false_ ) const
+ {
+ return equal_impl( left, right );
+ }
+
+ template <typename Left, typename Right>
+ inline predicate_result
+ call_impl( Left const& left, Right const& right, mpl::true_ ) const
+ {
+ return (*this)( right, &left[0] );
+ }
+
+ template <typename Left, typename Right>
+ inline predicate_result
+ operator()( Left const& left, Right const& right ) const
+ {
+ typedef typename is_array<Left>::type left_is_array;
+ return call_impl( left, right, left_is_array() );
+ }
+};
+
+//____________________________________________________________________________//
+
+struct ne_impl {
+ template <class Left, class Right>
+ predicate_result operator()( Left const& left, Right const& right )
+ {
+ return !equal_impl_frwd()( left, right );
+ }
+};
+
+//____________________________________________________________________________//
+
+struct lt_impl {
+ template <class Left, class Right>
+ predicate_result operator()( Left const& left, Right const& right )
+ {
+ return left < right;
+ }
+};
+
+//____________________________________________________________________________//
+
+struct le_impl {
+ template <class Left, class Right>
+ predicate_result operator()( Left const& left, Right const& right )
+ {
+ return left <= right;
+ }
+};
+
+//____________________________________________________________________________//
+
+struct gt_impl {
+ template <class Left, class Right>
+ predicate_result operator()( Left const& left, Right const& right )
+ {
+ return left > right;
+ }
+};
+
+//____________________________________________________________________________//
+
+struct ge_impl {
+ template <class Left, class Right>
+ predicate_result operator()( Left const& left, Right const& right )
+ {
+ return left >= right;
+ }
+};
+
+//____________________________________________________________________________//
+
+template <typename Left, typename Right>
+inline predicate_result
+equal_coll_impl( Left left_begin, Left left_end, Right right_begin, Right right_end )
+{
+ predicate_result res( true );
+ std::size_t pos = 0;
+
+ for( ; left_begin != left_end && right_begin != right_end; ++left_begin, ++right_begin, ++pos ) {
+ if( *left_begin != *right_begin ) {
+ res = false;
+ res.message() << "\nMismatch in a position " << pos << ": " << *left_begin << " != " << *right_begin;
+ }
+ }
+
+ if( left_begin != left_end ) {
+ std::size_t r_size = pos;
+ while( left_begin != left_end ) {
+ ++pos;
+ ++left_begin;
+ }
+
+ res = false;
+ res.message() << "\nCollections size mismatch: " << pos << " != " << r_size;
+ }
+
+ if( right_begin != right_end ) {
+ std::size_t l_size = pos;
+ while( right_begin != right_end ) {
+ ++pos;
+ ++right_begin;
+ }
+
+ res = false;
+ res.message() << "\nCollections size mismatch: " << l_size << " != " << pos;
+ }
+
+ return res;
+}
+
+//____________________________________________________________________________//
+
+template <class Left, class Right>
+inline predicate_result
+bitwise_equal_impl( Left const& left, Right const& right )
+{
+ predicate_result res( true );
+
+ std::size_t left_bit_size = sizeof(Left)*CHAR_BIT;
+ std::size_t right_bit_size = sizeof(Right)*CHAR_BIT;
+
+ static Left const leftOne( 1 );
+ static Right const rightOne( 1 );
+
+ std::size_t total_bits = left_bit_size < right_bit_size ? left_bit_size : right_bit_size;
+
+ for( std::size_t counter = 0; counter < total_bits; ++counter ) {
+ if( ( left & ( leftOne << counter ) ) != ( right & ( rightOne << counter ) ) ) {
+ res = false;
+ res.message() << "\nMismatch in a position " << counter;
+ }
+ }
+
+ if( left_bit_size != right_bit_size ) {
+ res = false;
+ res.message() << "\nOperands bit sizes mismatch: " << left_bit_size << " != " << right_bit_size;
+ }
+
+ return res;
+}
+
+//____________________________________________________________________________//
+
+bool BOOST_TEST_DECL is_defined_impl( const_string symbol_name, const_string symbol_value );
+
+//____________________________________________________________________________//
+
+} // namespace tt_detail
+
+} // namespace test_tools
+
+namespace test_toolbox = test_tools;
+
+} // namespace ndnboost
+
+//____________________________________________________________________________//
+
+#include <ndnboost/test/detail/enable_warnings.hpp>
+
+#endif // BOOST_TEST_TEST_TOOLS_HPP_012705GER
diff --git a/ndnboost/test/unit_test_log.hpp b/ndnboost/test/unit_test_log.hpp
new file mode 100644
index 0000000..844b6d7
--- /dev/null
+++ b/ndnboost/test/unit_test_log.hpp
@@ -0,0 +1,177 @@
+// (C) Copyright Gennadiy Rozental 2001-2008.
+// Distributed under 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)
+
+// See http://www.boost.org/libs/test for the library home page.
+//
+// File : $RCSfile$
+//
+// Version : $Revision: 54633 $
+//
+// Description : defines singleton class unit_test_log and all manipulators.
+// unit_test_log has output stream like interface. It's implementation is
+// completely hidden with pimple idiom
+// ***************************************************************************
+
+#ifndef BOOST_TEST_UNIT_TEST_LOG_HPP_071894GER
+#define BOOST_TEST_UNIT_TEST_LOG_HPP_071894GER
+
+// Boost.Test
+#include <ndnboost/test/test_observer.hpp>
+
+#include <ndnboost/test/detail/global_typedef.hpp>
+#include <ndnboost/test/detail/log_level.hpp>
+#include <ndnboost/test/detail/fwd_decl.hpp>
+
+#include <ndnboost/test/utils/wrap_stringstream.hpp>
+#include <ndnboost/test/utils/trivial_singleton.hpp>
+#include <ndnboost/test/utils/lazy_ostream.hpp>
+
+// Boost
+#include <ndnboost/utility.hpp>
+
+// STL
+#include <iosfwd> // for std::ostream&
+
+#include <ndnboost/test/detail/suppress_warnings.hpp>
+
+//____________________________________________________________________________//
+
+namespace ndnboost {
+
+namespace unit_test {
+
+// ************************************************************************** //
+// ************** log manipulators ************** //
+// ************************************************************************** //
+
+namespace log {
+
+struct BOOST_TEST_DECL begin {
+ begin( const_string fn, std::size_t ln )
+ : m_file_name( fn )
+ , m_line_num( ln )
+ {}
+
+ const_string m_file_name;
+ std::size_t m_line_num;
+};
+
+struct end {};
+
+} // namespace log
+
+// ************************************************************************** //
+// ************** entry_value_collector ************** //
+// ************************************************************************** //
+
+namespace ut_detail {
+
+class BOOST_TEST_DECL entry_value_collector {
+public:
+ // Constructors
+ entry_value_collector() : m_last( true ) {}
+ entry_value_collector( entry_value_collector const& rhs ) : m_last( true ) { rhs.m_last = false; }
+ ~entry_value_collector();
+
+ // collection interface
+ entry_value_collector const& operator<<( lazy_ostream const& ) const;
+ entry_value_collector const& operator<<( const_string ) const;
+
+private:
+ // Data members
+ mutable bool m_last;
+};
+
+} // namespace ut_detail
+
+// ************************************************************************** //
+// ************** unit_test_log ************** //
+// ************************************************************************** //
+
+class BOOST_TEST_DECL unit_test_log_t : public test_observer, public singleton<unit_test_log_t> {
+public:
+ // test_observer interface implementation
+ void test_start( counter_t test_cases_amount );
+ void test_finish();
+ void test_aborted();
+
+ void test_unit_start( test_unit const& );
+ void test_unit_finish( test_unit const&, unsigned long elapsed );
+ void test_unit_skipped( test_unit const& );
+ void test_unit_aborted( test_unit const& );
+
+ void assertion_result( bool passed );
+ void exception_caught( execution_exception const& );
+
+ virtual int priority() { return 1; }
+
+ // log configuration methods
+ void set_stream( std::ostream& );
+ void set_threshold_level( log_level );
+ void set_format( output_format );
+ void set_formatter( unit_test_log_formatter* );
+
+ // test progress logging
+ void set_checkpoint( const_string file, std::size_t line_num, const_string msg = const_string() );
+
+ // entry logging
+ unit_test_log_t& operator<<( log::begin const& ); // begin entry
+ unit_test_log_t& operator<<( log::end const& ); // end entry
+ unit_test_log_t& operator<<( log_level ); // set entry level
+ unit_test_log_t& operator<<( const_string ); // log entry value
+ unit_test_log_t& operator<<( lazy_ostream const& ); // log entry value
+
+ ut_detail::entry_value_collector operator()( log_level ); // initiate entry collection
+
+private:
+ bool log_entry_start();
+
+ BOOST_TEST_SINGLETON_CONS( unit_test_log_t );
+}; // unit_test_log_t
+
+BOOST_TEST_SINGLETON_INST( unit_test_log )
+
+// helper macros
+#define BOOST_TEST_LOG_ENTRY( ll ) \
+ (::ndnboost::unit_test::unit_test_log \
+ << ::ndnboost::unit_test::log::begin( BOOST_TEST_L(__FILE__), __LINE__ ))(ll) \
+/**/
+
+} // namespace unit_test
+
+} // namespace ndnboost
+
+// ************************************************************************** //
+// ************** Unit test log interface helpers ************** //
+// ************************************************************************** //
+
+#define BOOST_TEST_MESSAGE( M ) \
+ BOOST_TEST_LOG_ENTRY( ::ndnboost::unit_test::log_messages ) \
+ << (::ndnboost::unit_test::lazy_ostream::instance() << M) \
+/**/
+
+//____________________________________________________________________________//
+
+#define BOOST_TEST_PASSPOINT() \
+ ::ndnboost::unit_test::unit_test_log.set_checkpoint( \
+ BOOST_TEST_L(__FILE__), \
+ static_cast<std::size_t>(__LINE__) ) \
+/**/
+
+//____________________________________________________________________________//
+
+#define BOOST_TEST_CHECKPOINT( M ) \
+ ::ndnboost::unit_test::unit_test_log.set_checkpoint( \
+ BOOST_TEST_L(__FILE__), \
+ static_cast<std::size_t>(__LINE__), \
+ (::ndnboost::wrap_stringstream().ref() << M).str() ) \
+/**/
+
+//____________________________________________________________________________//
+
+#include <ndnboost/test/detail/enable_warnings.hpp>
+
+#endif // BOOST_TEST_UNIT_TEST_LOG_HPP_071894GER
+
diff --git a/ndnboost/test/unit_test_log_formatter.hpp b/ndnboost/test/unit_test_log_formatter.hpp
new file mode 100644
index 0000000..6449c83
--- /dev/null
+++ b/ndnboost/test/unit_test_log_formatter.hpp
@@ -0,0 +1,123 @@
+// (C) Copyright Gennadiy Rozental 2003-2008.
+// Distributed under 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)
+
+// See http://www.boost.org/libs/test for the library home page.
+//
+// File : $RCSfile$
+//
+// Version : $Revision: 57992 $
+//
+// Description :
+// ***************************************************************************
+
+#ifndef BOOST_TEST_UNIT_TEST_LOG_FORMATTER_HPP_071894GER
+#define BOOST_TEST_UNIT_TEST_LOG_FORMATTER_HPP_071894GER
+
+// Boost.Test
+#include <ndnboost/test/detail/global_typedef.hpp>
+#include <ndnboost/test/detail/log_level.hpp>
+#include <ndnboost/test/detail/fwd_decl.hpp>
+
+#include <ndnboost/test/execution_monitor.hpp>
+
+// STL
+#include <iosfwd>
+#include <string> // for std::string
+
+#include <ndnboost/test/detail/suppress_warnings.hpp>
+
+//____________________________________________________________________________//
+
+namespace ndnboost {
+
+namespace unit_test {
+
+// ************************************************************************** //
+// ************** log_entry_data ************** //
+// ************************************************************************** //
+
+struct BOOST_TEST_DECL log_entry_data {
+ log_entry_data()
+ {
+ m_file_name.reserve( 200 );
+ }
+
+ std::string m_file_name;
+ std::size_t m_line_num;
+ log_level m_level;
+
+ void clear()
+ {
+ m_file_name.erase();
+ m_line_num = 0;
+ m_level = log_nothing;
+ }
+};
+
+// ************************************************************************** //
+// ************** checkpoint_data ************** //
+// ************************************************************************** //
+
+struct BOOST_TEST_DECL log_checkpoint_data
+{
+ const_string m_file_name;
+ std::size_t m_line_num;
+ std::string m_message;
+
+ void clear()
+ {
+ m_file_name.clear();
+ m_line_num = 0;
+ m_message = std::string();
+ }
+};
+
+// ************************************************************************** //
+// ************** unit_test_log_formatter ************** //
+// ************************************************************************** //
+
+class BOOST_TEST_DECL unit_test_log_formatter {
+public:
+ enum log_entry_types { BOOST_UTL_ET_INFO,
+ BOOST_UTL_ET_MESSAGE,
+ BOOST_UTL_ET_WARNING,
+ BOOST_UTL_ET_ERROR,
+ BOOST_UTL_ET_FATAL_ERROR };
+
+ // Destructor
+ virtual ~unit_test_log_formatter() {}
+
+ // Formatter interface
+ virtual void log_start( std::ostream&, counter_t test_cases_amount ) = 0;
+ virtual void log_finish( std::ostream& ) = 0;
+ virtual void log_build_info( std::ostream& ) = 0;
+
+ virtual void test_unit_start( std::ostream&, test_unit const& tu ) = 0;
+ virtual void test_unit_finish( std::ostream&, test_unit const& tu, unsigned long elapsed ) = 0;
+ virtual void test_unit_skipped( std::ostream&, test_unit const& ) = 0;
+
+ virtual void log_exception( std::ostream& os, log_checkpoint_data const& cd, execution_exception const& ex )
+ {
+ // for backward compatibility
+ log_exception( os, cd, ex.what() );
+ }
+ virtual void log_exception( std::ostream&, log_checkpoint_data const&, const_string /* explanation */ ) {}
+
+ virtual void log_entry_start( std::ostream&, log_entry_data const&, log_entry_types let ) = 0;
+ virtual void log_entry_value( std::ostream&, const_string value ) = 0;
+ virtual void log_entry_value( std::ostream&, lazy_ostream const& value ); // there is a default impl
+ virtual void log_entry_finish( std::ostream& ) = 0;
+};
+
+} // namespace unit_test
+
+} // namespace ndnboost
+
+//____________________________________________________________________________//
+
+#include <ndnboost/test/detail/enable_warnings.hpp>
+
+#endif // BOOST_TEST_UNIT_TEST_LOG_FORMATTER_HPP_071894GER
+
diff --git a/ndnboost/test/unit_test_monitor.hpp b/ndnboost/test/unit_test_monitor.hpp
new file mode 100644
index 0000000..4777d17
--- /dev/null
+++ b/ndnboost/test/unit_test_monitor.hpp
@@ -0,0 +1,69 @@
+// (C) Copyright Gennadiy Rozental 2001-2008.
+// Distributed under 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)
+
+// See http://www.boost.org/libs/test for the library home page.
+//
+// File : $RCSfile$
+//
+// Version : $Revision: 49312 $
+//
+// Description : defines specific version of execution monitor used to managed
+// run unit of test cases. Translates execution exception into error level
+// ***************************************************************************
+
+#ifndef BOOST_TEST_UNIT_TEST_MONITOR_HPP_020905GER
+#define BOOST_TEST_UNIT_TEST_MONITOR_HPP_020905GER
+
+// Boost.Test
+#include <ndnboost/test/execution_monitor.hpp>
+#include <ndnboost/test/detail/fwd_decl.hpp>
+#include <ndnboost/test/utils/trivial_singleton.hpp>
+#include <ndnboost/test/utils/callback.hpp>
+
+#include <ndnboost/test/detail/suppress_warnings.hpp>
+
+//____________________________________________________________________________//
+
+namespace ndnboost {
+
+namespace unit_test {
+
+// ************************************************************************** //
+// ************** unit_test_monitor ************** //
+// ************************************************************************** //
+
+class BOOST_TEST_DECL unit_test_monitor_t : public singleton<unit_test_monitor_t>, public execution_monitor {
+public:
+ enum error_level {
+ test_fail = 1,
+ test_ok = 0,
+ constructor_error = -1,
+ unexpected_exception = -2,
+ os_exception = -3,
+ os_timeout = -4,
+ fatal_error = -5, // includes both system and user
+ destructor_error = -6
+ };
+
+ static bool is_critical_error( error_level e ) { return e <= fatal_error; }
+
+ // monitor method
+ error_level execute_and_translate( test_case const& );
+
+private:
+ BOOST_TEST_SINGLETON_CONS( unit_test_monitor_t );
+};
+
+BOOST_TEST_SINGLETON_INST( unit_test_monitor )
+
+} // namespace unit_test
+
+} // namespace ndnboost
+
+//____________________________________________________________________________//
+
+#include <ndnboost/test/detail/enable_warnings.hpp>
+
+#endif // BOOST_TEST_UNIT_TEST_MONITOR_HPP_020905GER
diff --git a/ndnboost/test/unit_test_suite.hpp b/ndnboost/test/unit_test_suite.hpp
new file mode 100644
index 0000000..5ef5f13
--- /dev/null
+++ b/ndnboost/test/unit_test_suite.hpp
@@ -0,0 +1,245 @@
+// (C) Copyright Gennadiy Rozental 2001-2008.
+// Distributed under 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)
+
+// See http://www.boost.org/libs/test for the library home page.
+//
+// File : $RCSfile$
+//
+// Version : $Revision: 57992 $
+//
+// Description : defines Unit Test Framework public API
+// ***************************************************************************
+
+#ifndef BOOST_TEST_UNIT_TEST_SUITE_HPP_071894GER
+#define BOOST_TEST_UNIT_TEST_SUITE_HPP_071894GER
+
+// Boost.Test
+#include <ndnboost/test/unit_test_suite_impl.hpp>
+#include <ndnboost/test/framework.hpp>
+
+//____________________________________________________________________________//
+
+// ************************************************************************** //
+// ************** Non-auto (explicit) test case interface ************** //
+// ************************************************************************** //
+
+#define BOOST_TEST_CASE( test_function ) \
+ndnboost::unit_test::make_test_case( ndnboost::unit_test::callback0<>(test_function), BOOST_TEST_STRINGIZE( test_function ) )
+#define BOOST_CLASS_TEST_CASE( test_function, tc_instance ) \
+ndnboost::unit_test::make_test_case((test_function), BOOST_TEST_STRINGIZE( test_function ), tc_instance )
+
+// ************************************************************************** //
+// ************** BOOST_TEST_SUITE ************** //
+// ************************************************************************** //
+
+#define BOOST_TEST_SUITE( testsuite_name ) \
+( new ndnboost::unit_test::test_suite( testsuite_name ) )
+
+// ************************************************************************** //
+// ************** BOOST_AUTO_TEST_SUITE ************** //
+// ************************************************************************** //
+
+#define BOOST_AUTO_TEST_SUITE( suite_name ) \
+namespace suite_name { \
+BOOST_AUTO_TU_REGISTRAR( suite_name )( BOOST_STRINGIZE( suite_name ) ); \
+/**/
+
+// ************************************************************************** //
+// ************** BOOST_FIXTURE_TEST_SUITE ************** //
+// ************************************************************************** //
+
+#define BOOST_FIXTURE_TEST_SUITE( suite_name, F ) \
+BOOST_AUTO_TEST_SUITE( suite_name ) \
+typedef F BOOST_AUTO_TEST_CASE_FIXTURE; \
+/**/
+
+// ************************************************************************** //
+// ************** BOOST_AUTO_TEST_SUITE_END ************** //
+// ************************************************************************** //
+
+#define BOOST_AUTO_TEST_SUITE_END() \
+BOOST_AUTO_TU_REGISTRAR( BOOST_JOIN( end_suite, __LINE__ ) )( 1 ); \
+} \
+/**/
+
+// ************************************************************************** //
+// ************** BOOST_AUTO_TEST_CASE_EXPECTED_FAILURES ************** //
+// ************************************************************************** //
+
+#define BOOST_AUTO_TEST_CASE_EXPECTED_FAILURES( test_name, n ) \
+struct BOOST_AUTO_TC_UNIQUE_ID( test_name ); \
+ \
+static struct BOOST_JOIN( test_name, _exp_fail_num_spec ) \
+: ndnboost::unit_test::ut_detail:: \
+ auto_tc_exp_fail<BOOST_AUTO_TC_UNIQUE_ID( test_name ) > \
+{ \
+ BOOST_JOIN( test_name, _exp_fail_num_spec )() \
+ : ndnboost::unit_test::ut_detail:: \
+ auto_tc_exp_fail<BOOST_AUTO_TC_UNIQUE_ID( test_name ) >( n ) \
+ {} \
+} BOOST_JOIN( test_name, _exp_fail_num_spec_inst ); \
+ \
+/**/
+
+// ************************************************************************** //
+// ************** BOOST_FIXTURE_TEST_CASE ************** //
+// ************************************************************************** //
+
+#define BOOST_FIXTURE_TEST_CASE( test_name, F ) \
+struct test_name : public F { void test_method(); }; \
+ \
+static void BOOST_AUTO_TC_INVOKER( test_name )() \
+{ \
+ test_name t; \
+ t.test_method(); \
+} \
+ \
+struct BOOST_AUTO_TC_UNIQUE_ID( test_name ) {}; \
+ \
+BOOST_AUTO_TU_REGISTRAR( test_name )( \
+ ndnboost::unit_test::make_test_case( \
+ &BOOST_AUTO_TC_INVOKER( test_name ), #test_name ), \
+ ndnboost::unit_test::ut_detail::auto_tc_exp_fail< \
+ BOOST_AUTO_TC_UNIQUE_ID( test_name )>::instance()->value() ); \
+ \
+void test_name::test_method() \
+/**/
+
+// ************************************************************************** //
+// ************** BOOST_AUTO_TEST_CASE ************** //
+// ************************************************************************** //
+
+#define BOOST_AUTO_TEST_CASE( test_name ) \
+BOOST_FIXTURE_TEST_CASE( test_name, BOOST_AUTO_TEST_CASE_FIXTURE )
+/**/
+
+// ************************************************************************** //
+// ************** BOOST_FIXTURE_TEST_CASE_TEMPLATE ************** //
+// ************************************************************************** //
+
+#define BOOST_FIXTURE_TEST_CASE_TEMPLATE( test_name, type_name, TL, F ) \
+template<typename type_name> \
+struct test_name : public F \
+{ void test_method(); }; \
+ \
+struct BOOST_AUTO_TC_INVOKER( test_name ) { \
+ template<typename TestType> \
+ static void run( ndnboost::type<TestType>* = 0 ) \
+ { \
+ test_name<TestType> t; \
+ t.test_method(); \
+ } \
+}; \
+ \
+BOOST_AUTO_TU_REGISTRAR( test_name )( \
+ ndnboost::unit_test::ut_detail::template_test_case_gen< \
+ BOOST_AUTO_TC_INVOKER( test_name ),TL >( \
+ BOOST_STRINGIZE( test_name ) ) ); \
+ \
+template<typename type_name> \
+void test_name<type_name>::test_method() \
+/**/
+
+// ************************************************************************** //
+// ************** BOOST_AUTO_TEST_CASE_TEMPLATE ************** //
+// ************************************************************************** //
+
+#define BOOST_AUTO_TEST_CASE_TEMPLATE( test_name, type_name, TL ) \
+BOOST_FIXTURE_TEST_CASE_TEMPLATE( test_name, type_name, TL, BOOST_AUTO_TEST_CASE_FIXTURE )
+
+// ************************************************************************** //
+// ************** BOOST_TEST_CASE_TEMPLATE ************** //
+// ************************************************************************** //
+
+#define BOOST_TEST_CASE_TEMPLATE( name, typelist ) \
+ ndnboost::unit_test::ut_detail::template_test_case_gen<name,typelist >( \
+ BOOST_TEST_STRINGIZE( name ) ) \
+/**/
+
+// ************************************************************************** //
+// ************** BOOST_TEST_CASE_TEMPLATE_FUNCTION ************** //
+// ************************************************************************** //
+
+#define BOOST_TEST_CASE_TEMPLATE_FUNCTION( name, type_name ) \
+template<typename type_name> \
+void BOOST_JOIN( name, _impl )( ndnboost::type<type_name>* ); \
+ \
+struct name { \
+ template<typename TestType> \
+ static void run( ndnboost::type<TestType>* frwrd = 0 ) \
+ { \
+ BOOST_JOIN( name, _impl )( frwrd ); \
+ } \
+}; \
+ \
+template<typename type_name> \
+void BOOST_JOIN( name, _impl )( ndnboost::type<type_name>* ) \
+/**/
+
+// ************************************************************************** //
+// ************** BOOST_GLOBAL_FIXURE ************** //
+// ************************************************************************** //
+
+#define BOOST_GLOBAL_FIXTURE( F ) \
+static ndnboost::unit_test::ut_detail::global_fixture_impl<F> BOOST_JOIN( gf_, F ) ; \
+/**/
+
+// ************************************************************************** //
+// ************** BOOST_AUTO_TEST_CASE_FIXTURE ************** //
+// ************************************************************************** //
+
+namespace ndnboost { namespace unit_test { namespace ut_detail {
+
+struct nil_t {};
+
+} // namespace ut_detail
+} // unit_test
+} // namespace ndnboost
+
+// Intentionally is in global namespace, so that FIXURE_TEST_SUITE can reset it in user code.
+typedef ::ndnboost::unit_test::ut_detail::nil_t BOOST_AUTO_TEST_CASE_FIXTURE;
+
+// ************************************************************************** //
+// ************** Auto registration facility helper macros ************** //
+// ************************************************************************** //
+
+#define BOOST_AUTO_TU_REGISTRAR( test_name ) \
+static ndnboost::unit_test::ut_detail::auto_test_unit_registrar BOOST_JOIN( BOOST_JOIN( test_name, _registrar ), __LINE__ )
+#define BOOST_AUTO_TC_INVOKER( test_name ) BOOST_JOIN( test_name, _invoker )
+#define BOOST_AUTO_TC_UNIQUE_ID( test_name ) BOOST_JOIN( test_name, _id )
+
+// ************************************************************************** //
+// ************** BOOST_TEST_MAIN ************** //
+// ************************************************************************** //
+
+#if defined(BOOST_TEST_MAIN)
+
+#ifdef BOOST_TEST_ALTERNATIVE_INIT_API
+bool init_unit_test() {
+#else
+::ndnboost::unit_test::test_suite*
+init_unit_test_suite( int, char* [] ) {
+#endif
+
+#ifdef BOOST_TEST_MODULE
+ using namespace ::ndnboost::unit_test;
+ assign_op( framework::master_test_suite().p_name.value, BOOST_TEST_STRINGIZE( BOOST_TEST_MODULE ).trim( "\"" ), 0 );
+
+#endif
+
+#ifdef BOOST_TEST_ALTERNATIVE_INIT_API
+ return true;
+}
+#else
+ return 0;
+}
+#endif
+
+#endif
+
+//____________________________________________________________________________//
+
+#endif // BOOST_TEST_UNIT_TEST_SUITE_HPP_071894GER
+
diff --git a/ndnboost/test/unit_test_suite_impl.hpp b/ndnboost/test/unit_test_suite_impl.hpp
new file mode 100644
index 0000000..42933e4
--- /dev/null
+++ b/ndnboost/test/unit_test_suite_impl.hpp
@@ -0,0 +1,434 @@
+// (C) Copyright Gennadiy Rozental 2001-2008.
+// Distributed under 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)
+
+// See http://www.boost.org/libs/test for the library home page.
+//
+// File : $RCSfile$
+//
+// Version : $Revision: 54633 $
+//
+// Description : defines test_unit, test_case, test_case_results, test_suite and test_tree_visitor
+// ***************************************************************************
+
+#ifndef BOOST_TEST_UNIT_TEST_SUITE_IMPL_HPP_071894GER
+#define BOOST_TEST_UNIT_TEST_SUITE_IMPL_HPP_071894GER
+
+// Boost.Test
+#include <ndnboost/test/detail/config.hpp>
+#include <ndnboost/test/detail/global_typedef.hpp>
+#include <ndnboost/test/utils/class_properties.hpp>
+#include <ndnboost/test/utils/callback.hpp>
+#include <ndnboost/test/detail/fwd_decl.hpp>
+#include <ndnboost/test/detail/workaround.hpp>
+#include <ndnboost/test/test_observer.hpp>
+
+// Boost
+#include <ndnboost/shared_ptr.hpp>
+#include <ndnboost/mpl/for_each.hpp>
+#include <ndnboost/mpl/identity.hpp>
+#include <ndnboost/type.hpp>
+#include <ndnboost/type_traits/is_const.hpp>
+
+// STL
+#include <typeinfo> // for typeid
+#include <string> // for std::string
+#include <list> // for std::list
+#include <vector> // for std::vector
+
+#include <ndnboost/test/detail/suppress_warnings.hpp>
+
+//____________________________________________________________________________//
+
+namespace ndnboost {
+
+namespace unit_test {
+
+// ************************************************************************** //
+// ************** test_unit ************** //
+// ************************************************************************** //
+
+class BOOST_TEST_DECL test_unit {
+public:
+ enum { type = tut_any };
+
+ // Constructor
+ test_unit( const_string tu_name, test_unit_type t );
+
+ // dependencies management
+ void depends_on( test_unit* tu );
+ bool check_dependencies() const;
+
+ // Public r/o properties
+ typedef BOOST_READONLY_PROPERTY(test_unit_id,(framework_impl)) id_t;
+ typedef BOOST_READONLY_PROPERTY(test_unit_id,(test_suite)) parent_id_t;
+ readonly_property<test_unit_type> p_type; // type for this test unit
+ readonly_property<const_string> p_type_name; // "case"/"suite"
+ id_t p_id; // unique id for this test unit
+ parent_id_t p_parent_id; // parent test suite id
+
+ // Public r/w properties
+ readwrite_property<std::string> p_name; // name for this test unit
+ readwrite_property<unsigned> p_timeout; // timeout for the test unit execution
+ readwrite_property<counter_t> p_expected_failures; // number of expected failures in this test unit
+ mutable readwrite_property<bool> p_enabled; // enabled status for this unit
+
+ void increase_exp_fail( unsigned num );
+
+protected:
+ ~test_unit();
+
+private:
+ // Data members
+ std::list<test_unit_id> m_dependencies;
+};
+
+// ************************************************************************** //
+// ************** test_case_generator ************** //
+// ************************************************************************** //
+
+class BOOST_TEST_DECL test_unit_generator {
+public:
+ virtual test_unit* next() const = 0;
+
+protected:
+ BOOST_TEST_PROTECTED_VIRTUAL ~test_unit_generator() {}
+};
+
+// ************************************************************************** //
+// ************** test_case ************** //
+// ************************************************************************** //
+
+class BOOST_TEST_DECL test_case : public test_unit {
+public:
+ enum { type = tut_case };
+
+ // Constructor
+ test_case( const_string tc_name, callback0<> const& test_func );
+
+ // Access methods
+ callback0<> const& test_func() const { return m_test_func; }
+
+private:
+ friend class framework_impl;
+ ~test_case() {}
+
+ // BOOST_MSVC <= 1200 have problems with callback as property
+ // Data members
+ callback0<> m_test_func;
+};
+
+// ************************************************************************** //
+// ************** test_suite ************** //
+// ************************************************************************** //
+
+class BOOST_TEST_DECL test_suite : public test_unit {
+public:
+ enum { type = tut_suite };
+
+ // Constructor
+ explicit test_suite( const_string ts_name );
+
+ // test unit list management
+ void add( test_unit* tu, counter_t expected_failures = 0, unsigned timeout = 0 );
+ void add( test_unit_generator const& gen, unsigned timeout = 0 );
+ void remove( test_unit_id id );
+
+ // access methods
+ test_unit_id get( const_string tu_name ) const;
+ std::size_t size() const { return m_members.size(); }
+
+protected:
+ friend BOOST_TEST_DECL
+ void traverse_test_tree( test_suite const&, test_tree_visitor& );
+ friend class framework_impl;
+ virtual ~test_suite() {}
+
+ // Data members
+ std::vector<test_unit_id> m_members;
+};
+
+// ************************************************************************** //
+// ************** master_test_suite ************** //
+// ************************************************************************** //
+
+class BOOST_TEST_DECL master_test_suite_t : public test_suite {
+public:
+ master_test_suite_t() : test_suite( "Master Test Suite" )
+ , argc( 0 )
+ , argv( 0 )
+ {}
+
+ // Data members
+ int argc;
+ char** argv;
+};
+
+
+// ************************************************************************** //
+// ************** test_tree_visitor ************** //
+// ************************************************************************** //
+
+class BOOST_TEST_DECL test_tree_visitor {
+public:
+ // test tree visitor interface
+ virtual void visit( test_case const& ) {}
+ virtual bool test_suite_start( test_suite const& ) { return true; }
+ virtual void test_suite_finish( test_suite const& ) {}
+
+protected:
+ BOOST_TEST_PROTECTED_VIRTUAL ~test_tree_visitor() {}
+};
+
+// ************************************************************************** //
+// ************** traverse_test_tree ************** //
+// ************************************************************************** //
+
+BOOST_TEST_DECL void traverse_test_tree( test_case const&, test_tree_visitor& );
+BOOST_TEST_DECL void traverse_test_tree( test_suite const&, test_tree_visitor& );
+BOOST_TEST_DECL void traverse_test_tree( test_unit_id , test_tree_visitor& );
+
+//____________________________________________________________________________//
+
+inline void
+traverse_test_tree( test_unit const& tu, test_tree_visitor& V )
+{
+ if( tu.p_type == tut_case )
+ traverse_test_tree( static_cast<test_case const&>( tu ), V );
+ else
+ traverse_test_tree( static_cast<test_suite const&>( tu ), V );
+}
+
+//____________________________________________________________________________//
+
+// ************************************************************************** //
+// ************** test_case_counter ************** //
+// ************************************************************************** //
+
+class test_case_counter : public test_tree_visitor {
+public:
+ // Constructor
+ test_case_counter() : p_count( 0 ) {}
+
+ BOOST_READONLY_PROPERTY( counter_t, (test_case_counter)) p_count;
+private:
+ // test tree visitor interface
+ virtual void visit( test_case const& );
+ virtual bool test_suite_start( test_suite const& ts ) { return ts.p_enabled; }
+};
+
+// ************************************************************************** //
+// ************** test_being_aborted ************** //
+// ************************************************************************** //
+
+struct BOOST_TEST_DECL test_being_aborted {};
+
+// ************************************************************************** //
+// ************** object generators ************** //
+// ************************************************************************** //
+
+namespace ut_detail {
+
+BOOST_TEST_DECL std::string normalize_test_case_name( const_string tu_name );
+
+template<typename InstanceType,typename UserTestCase>
+struct user_tc_method_invoker {
+ typedef void (UserTestCase::*TestMethod )();
+
+ user_tc_method_invoker( shared_ptr<InstanceType> inst, TestMethod test_method )
+ : m_inst( inst ), m_test_method( test_method ) {}
+
+ void operator()() { ((*m_inst).*m_test_method)(); }
+
+ shared_ptr<InstanceType> m_inst;
+ TestMethod m_test_method;
+};
+
+} // namespace ut_detail
+
+//____________________________________________________________________________//
+
+inline test_case*
+make_test_case( callback0<> const& test_func, const_string tc_name )
+{
+ return new test_case( ut_detail::normalize_test_case_name( tc_name ), test_func );
+}
+
+//____________________________________________________________________________//
+
+template<typename UserTestCase, typename InstanceType>
+inline test_case*
+make_test_case( void (UserTestCase::* test_method )(),
+ const_string tc_name,
+ ndnboost::shared_ptr<InstanceType> user_test_case )
+{
+ return new test_case( ut_detail::normalize_test_case_name( tc_name ),
+ ut_detail::user_tc_method_invoker<InstanceType,UserTestCase>( user_test_case, test_method ) );
+}
+
+//____________________________________________________________________________//
+
+// ************************************************************************** //
+// ************** auto_test_unit_registrar ************** //
+// ************************************************************************** //
+
+namespace ut_detail {
+
+struct BOOST_TEST_DECL auto_test_unit_registrar
+{
+ // Constructors
+ auto_test_unit_registrar( test_case* tc, counter_t exp_fail );
+ explicit auto_test_unit_registrar( const_string ts_name );
+ explicit auto_test_unit_registrar( test_unit_generator const& tc_gen );
+ explicit auto_test_unit_registrar( int );
+
+private:
+ static std::list<test_suite*>& curr_ts_store();
+};
+
+//____________________________________________________________________________//
+
+template<typename T>
+struct auto_tc_exp_fail {
+ auto_tc_exp_fail() : m_value( 0 ) {}
+
+ explicit auto_tc_exp_fail( unsigned v )
+ : m_value( v )
+ {
+ instance() = this;
+ }
+
+ static auto_tc_exp_fail*& instance()
+ {
+ static auto_tc_exp_fail inst;
+ static auto_tc_exp_fail* inst_ptr = &inst;
+
+ return inst_ptr;
+ }
+
+ unsigned value() const { return m_value; }
+
+private:
+ // Data members
+ unsigned m_value;
+};
+
+//____________________________________________________________________________//
+
+} // namespace ut_detail
+
+// ************************************************************************** //
+// ************** global_fixture ************** //
+// ************************************************************************** //
+
+class BOOST_TEST_DECL global_fixture : public test_observer {
+public:
+ // Constructor
+ global_fixture();
+};
+
+//____________________________________________________________________________//
+
+namespace ut_detail {
+
+template<typename F>
+struct global_fixture_impl : public global_fixture {
+ // Constructor
+ global_fixture_impl(): m_fixure( 0 ) {}
+
+ // test observer interface
+ virtual void test_start( counter_t ) { m_fixure = new F; }
+ virtual void test_finish() { delete m_fixure; m_fixure = 0; }
+ virtual void test_aborted() { delete m_fixure; m_fixure = 0; }
+
+private:
+ // Data members
+ F* m_fixure;
+};
+
+// ************************************************************************** //
+// ************** test_case_template_invoker ************** //
+// ************************************************************************** //
+
+template<typename TestCaseTemplate,typename TestType>
+class test_case_template_invoker {
+public:
+ void operator()() { TestCaseTemplate::run( (ndnboost::type<TestType>*)0 ); }
+};
+
+// ************************************************************************** //
+// ************** generate_test_case_4_type ************** //
+// ************************************************************************** //
+
+template<typename Generator,typename TestCaseTemplate>
+struct generate_test_case_4_type {
+ explicit generate_test_case_4_type( const_string tc_name, Generator& G )
+ : m_test_case_name( tc_name )
+ , m_holder( G )
+ {}
+
+ template<typename TestType>
+ void operator()( mpl::identity<TestType> )
+ {
+ std::string full_name;
+ assign_op( full_name, m_test_case_name, 0 );
+ full_name += '<';
+ full_name += typeid(TestType).name();
+ if( ndnboost::is_const<TestType>::value )
+ full_name += " const";
+ full_name += '>';
+
+ m_holder.m_test_cases.push_back(
+ new test_case( full_name, test_case_template_invoker<TestCaseTemplate,TestType>() ) );
+ }
+
+private:
+ // Data members
+ const_string m_test_case_name;
+ Generator& m_holder;
+};
+
+// ************************************************************************** //
+// ************** test_case_template ************** //
+// ************************************************************************** //
+
+template<typename TestCaseTemplate,typename TestTypesList>
+class template_test_case_gen : public test_unit_generator {
+public:
+ // Constructor
+ template_test_case_gen( const_string tc_name )
+ {
+ typedef generate_test_case_4_type<template_test_case_gen<TestCaseTemplate,TestTypesList>,
+ TestCaseTemplate
+ > single_test_gen;
+ mpl::for_each<TestTypesList,mpl::make_identity<mpl::_> >( single_test_gen( tc_name, *this ) );
+ }
+
+ virtual test_unit* next() const
+ {
+ if( m_test_cases.empty() )
+ return 0;
+
+ test_unit* res = m_test_cases.front();
+ m_test_cases.pop_front();
+
+ return res;
+ }
+
+ // Data members
+ mutable std::list<test_unit*> m_test_cases;
+};
+
+//____________________________________________________________________________//
+
+} // namespace ut_detail
+
+} // unit_test
+
+} // namespace ndnboost
+
+#include <ndnboost/test/detail/enable_warnings.hpp>
+
+#endif // BOOST_TEST_UNIT_TEST_SUITE_IMPL_HPP_071894GER
+
diff --git a/ndnboost/test/utils/algorithm.hpp b/ndnboost/test/utils/algorithm.hpp
new file mode 100644
index 0000000..8003dfe
--- /dev/null
+++ b/ndnboost/test/utils/algorithm.hpp
@@ -0,0 +1,228 @@
+// (C) Copyright Gennadiy Rozental 2004-2008.
+// Distributed under 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)
+
+// See http://www.boost.org/libs/test for the library home page.
+//
+// File : $RCSfile$
+//
+// Version : $Revision: 49312 $
+//
+// Description : addition to STL algorithms
+// ***************************************************************************
+
+#ifndef BOOST_ALGORITHM_HPP_062304GER
+#define BOOST_ALGORITHM_HPP_062304GER
+
+#include <utility>
+#include <algorithm> // std::find
+#include <functional> // std::bind1st
+
+#include <ndnboost/test/detail/suppress_warnings.hpp>
+
+//____________________________________________________________________________//
+
+namespace ndnboost {
+
+namespace unit_test {
+
+/// @brief this algorithm search through two collections for first mismatch position that get returned as a pair
+/// of iterators, first pointing to the mismatch position in first collection, second iterator in second one
+
+/// @param first1 - first collection begin iterator
+/// @param last1 - first collection end iterator
+/// @param first2 - second collection begin iterator
+/// @param last2 - second collection end iterator
+template <class InputIter1, class InputIter2>
+inline std::pair<InputIter1, InputIter2>
+mismatch( InputIter1 first1, InputIter1 last1,
+ InputIter2 first2, InputIter2 last2 )
+{
+ while( first1 != last1 && first2 != last2 && *first1 == *first2 ) {
+ ++first1;
+ ++first2;
+ }
+
+ return std::pair<InputIter1, InputIter2>(first1, first2);
+}
+
+//____________________________________________________________________________//
+
+/// @brief this algorithm search through two collections for first mismatch position that get returned as a pair
+/// of iterators, first pointing to the mismatch position in first collection, second iterator in second one. This algorithms
+/// uses supplied predicate for collection elements comparison
+
+/// @param first1 - first collection begin iterator
+/// @param last1 - first collection end iterator
+/// @param first2 - second collection begin iterator
+/// @param last2 - second collection end iterator
+/// @param pred - predicate to be used for search
+template <class InputIter1, class InputIter2, class Predicate>
+inline std::pair<InputIter1, InputIter2>
+mismatch( InputIter1 first1, InputIter1 last1,
+ InputIter2 first2, InputIter2 last2,
+ Predicate pred )
+{
+ while( first1 != last1 && first2 != last2 && pred( *first1, *first2 ) ) {
+ ++first1;
+ ++first2;
+ }
+
+ return std::pair<InputIter1, InputIter2>(first1, first2);
+}
+
+//____________________________________________________________________________//
+
+/// @brief this algorithm search through first collection for first element that does not belong a second one
+
+/// @param first1 - first collection begin iterator
+/// @param last1 - first collection end iterator
+/// @param first2 - second collection begin iterator
+/// @param last2 - second collection end iterator
+template<class ForwardIterator1, class ForwardIterator2>
+inline ForwardIterator1
+find_first_not_of( ForwardIterator1 first1, ForwardIterator1 last1,
+ ForwardIterator2 first2, ForwardIterator2 last2 )
+{
+ while( first1 != last1 ) {
+ if( std::find( first2, last2, *first1 ) == last2 )
+ break;
+ ++first1;
+ }
+
+ return first1;
+}
+
+//____________________________________________________________________________//
+
+/// @brief this algorithm search through first collection for first element that does not satisfy binary
+/// predicate in conjunction will any element in second collection
+
+/// @param first1 - first collection begin iterator
+/// @param last1 - first collection end iterator
+/// @param first2 - second collection begin iterator
+/// @param last2 - second collection end iterator
+/// @param pred - predicate to be used for search
+template<class ForwardIterator1, class ForwardIterator2, class Predicate>
+inline ForwardIterator1
+find_first_not_of( ForwardIterator1 first1, ForwardIterator1 last1,
+ ForwardIterator2 first2, ForwardIterator2 last2,
+ Predicate pred )
+{
+ while( first1 != last1 ) {
+ if( std::find_if( first2, last2, std::bind1st( pred, *first1 ) ) == last2 )
+ break;
+ ++first1;
+ }
+
+ return first1;
+}
+
+//____________________________________________________________________________//
+
+/// @brief this algorithm search through first collection for last element that belongs to a second one
+
+/// @param first1 - first collection begin iterator
+/// @param last1 - first collection end iterator
+/// @param first2 - second collection begin iterator
+/// @param last2 - second collection end iterator
+template<class BidirectionalIterator1, class ForwardIterator2>
+inline BidirectionalIterator1
+find_last_of( BidirectionalIterator1 first1, BidirectionalIterator1 last1,
+ ForwardIterator2 first2, ForwardIterator2 last2 )
+{
+ if( first1 == last1 || first2 == last2 )
+ return last1;
+
+ BidirectionalIterator1 it1 = last1;
+ while( --it1 != first1 && std::find( first2, last2, *it1 ) == last2 ) {}
+
+ return it1 == first1 && std::find( first2, last2, *it1 ) == last2 ? last1 : it1;
+}
+
+//____________________________________________________________________________//
+
+/// @brief this algorithm search through first collection for last element that satisfy binary
+/// predicate in conjunction will at least one element in second collection
+
+/// @param first1 - first collection begin iterator
+/// @param last1 - first collection end iterator
+/// @param first2 - second collection begin iterator
+/// @param last2 - second collection end iterator
+/// @param pred - predicate to be used for search
+template<class BidirectionalIterator1, class ForwardIterator2, class Predicate>
+inline BidirectionalIterator1
+find_last_of( BidirectionalIterator1 first1, BidirectionalIterator1 last1,
+ ForwardIterator2 first2, ForwardIterator2 last2,
+ Predicate pred )
+{
+ if( first1 == last1 || first2 == last2 )
+ return last1;
+
+ BidirectionalIterator1 it1 = last1;
+ while( --it1 != first1 && std::find_if( first2, last2, std::bind1st( pred, *it1 ) ) == last2 ) {}
+
+ return it1 == first1 && std::find_if( first2, last2, std::bind1st( pred, *it1 ) ) == last2 ? last1 : it1;
+}
+
+//____________________________________________________________________________//
+
+/// @brief this algorithm search through first collection for last element that does not belong to a second one
+
+/// @param first1 - first collection begin iterator
+/// @param last1 - first collection end iterator
+/// @param first2 - second collection begin iterator
+/// @param last2 - second collection end iterator
+template<class BidirectionalIterator1, class ForwardIterator2>
+inline BidirectionalIterator1
+find_last_not_of( BidirectionalIterator1 first1, BidirectionalIterator1 last1,
+ ForwardIterator2 first2, ForwardIterator2 last2 )
+{
+ if( first1 == last1 || first2 == last2 )
+ return last1;
+
+ BidirectionalIterator1 it1 = last1;
+ while( --it1 != first1 && std::find( first2, last2, *it1 ) != last2 ) {}
+
+ return it1 == first1 && std::find( first2, last2, *it1 ) != last2 ? last1 : it1;
+}
+
+//____________________________________________________________________________//
+
+/// @brief this algorithm search through first collection for last element that does not satisfy binary
+/// predicate in conjunction will any element in second collection
+
+/// @param first1 - first collection begin iterator
+/// @param last1 - first collection end iterator
+/// @param first2 - second collection begin iterator
+/// @param last2 - second collection end iterator
+/// @param pred - predicate to be used for search
+template<class BidirectionalIterator1, class ForwardIterator2, class Predicate>
+inline BidirectionalIterator1
+find_last_not_of( BidirectionalIterator1 first1, BidirectionalIterator1 last1,
+ ForwardIterator2 first2, ForwardIterator2 last2,
+ Predicate pred )
+{
+ if( first1 == last1 || first2 == last2 )
+ return last1;
+
+ BidirectionalIterator1 it1 = last1;
+ while( --it1 != first1 && std::find_if( first2, last2, std::bind1st( pred, *it1 ) ) != last2 ) {}
+
+ return it1 == first1 && std::find_if( first2, last2, std::bind1st( pred, *it1 ) ) == last2 ? last1 : it1;
+}
+
+//____________________________________________________________________________//
+
+} // namespace unit_test
+
+} // namespace ndnboost
+
+//____________________________________________________________________________//
+
+#include <ndnboost/test/detail/enable_warnings.hpp>
+
+#endif // BOOST_ALGORITHM_HPP_062304GER
+
+
diff --git a/ndnboost/test/utils/assign_op.hpp b/ndnboost/test/utils/assign_op.hpp
new file mode 100644
index 0000000..b3d7ca0
--- /dev/null
+++ b/ndnboost/test/utils/assign_op.hpp
@@ -0,0 +1,41 @@
+// (C) Copyright Gennadiy Rozental 2005-2008.
+// Distributed under 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)
+
+// See http://www.boost.org/libs/test for the library home page.
+//
+// File : $RCSfile$
+//
+// Version : $Revision: 49312 $
+//
+// Description : overloadable assignment
+// ***************************************************************************
+
+#ifndef BOOST_TEST_ASSIGN_OP_033005GER
+#define BOOST_TEST_ASSIGN_OP_033005GER
+
+namespace ndnboost {
+
+namespace unit_test {
+
+// ************************************************************************** //
+// ************** generic assign operator ************** //
+// ************************************************************************** //
+
+// generic
+template<typename T,typename S>
+inline void
+assign_op( T& t, S const& s, long )
+{
+ t = s;
+}
+
+//____________________________________________________________________________//
+
+} // namespace unit_test
+
+} // namespace ndnboost
+
+#endif // BOOST_TEST_ASSIGN_OP_033005GER
+
diff --git a/ndnboost/test/utils/basic_cstring/basic_cstring.hpp b/ndnboost/test/utils/basic_cstring/basic_cstring.hpp
new file mode 100644
index 0000000..b3982df
--- /dev/null
+++ b/ndnboost/test/utils/basic_cstring/basic_cstring.hpp
@@ -0,0 +1,731 @@
+// (C) Copyright Gennadiy Rozental 2004-2008.
+// Distributed under 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)
+
+// See http://www.boost.org/libs/test for the library home page.
+//
+// File : $RCSfile$
+//
+// Version : $Revision: 57992 $
+//
+// Description : class basic_cstring wraps C string and provide std_string like
+// interface
+// ***************************************************************************
+
+#ifndef BOOST_TEST_BASIC_CSTRING_HPP_071894GER
+#define BOOST_TEST_BASIC_CSTRING_HPP_071894GER
+
+// Boost.Test
+#include <ndnboost/test/utils/basic_cstring/basic_cstring_fwd.hpp>
+#include <ndnboost/test/utils/basic_cstring/bcs_char_traits.hpp>
+
+// STL
+#include <string>
+
+#include <ndnboost/test/detail/suppress_warnings.hpp>
+
+//____________________________________________________________________________//
+
+namespace ndnboost {
+
+namespace unit_test {
+
+// ************************************************************************** //
+// ************** basic_cstring ************** //
+// ************************************************************************** //
+
+template<typename CharT>
+class basic_cstring {
+ typedef basic_cstring<CharT> self_type;
+public:
+ // Subtypes
+ typedef ut_detail::bcs_char_traits<CharT> traits_type;
+ typedef typename ut_detail::bcs_char_traits<CharT>::std_string std_string;
+
+ typedef CharT value_type;
+ typedef value_type* pointer;
+ typedef value_type const* const_pointer;
+ typedef value_type& reference;
+ typedef const value_type& const_reference;
+ typedef std::size_t size_type;
+ typedef std::ptrdiff_t difference_type;
+
+ typedef value_type const* const_iterator;
+ typedef value_type* iterator;
+
+ // !! should also present reverse_iterator, const_reverse_iterator
+
+#if !BOOST_WORKAROUND(__IBMCPP__, BOOST_TESTED_AT(600))
+ enum npos_type { npos = static_cast<size_type>(-1) };
+#else
+ // IBM/VisualAge version 6 is not able to handle enums larger than 4 bytes.
+ // But size_type is 8 bytes in 64bit mode.
+ static const size_type npos = -1 ;
+#endif
+
+ static pointer null_str();
+
+ // Constructors; default copy constructor is generated by compiler
+ basic_cstring();
+ basic_cstring( std_string const& s );
+ basic_cstring( pointer s );
+ basic_cstring( pointer s, size_type arg_size );
+ basic_cstring( pointer first, pointer last );
+
+ // data access methods
+ value_type operator[]( size_type index ) const;
+ value_type at( size_type index ) const;
+
+ // size operators
+ size_type size() const;
+ bool is_empty() const;
+ void clear();
+ void resize( size_type new_len );
+
+ // !! only for STL container conformance use is_empty instead
+ bool empty() const;
+
+ // Trimming
+ self_type& trim_right( size_type trim_size );
+ self_type& trim_left( size_type trim_size );
+ self_type& trim_right( iterator it );
+ self_type& trim_left( iterator it );
+#ifndef __IBMCPP__
+ self_type& trim_left( self_type exclusions = self_type() ) ;
+ self_type& trim_right( self_type exclusions = self_type() ) ;
+ self_type& trim( self_type exclusions = self_type() ) ;
+#else
+ // VisualAge version 6 has in this case a problem with the default arguments.
+ self_type& trim_left( self_type exclusions ) ;
+ self_type& trim_right( self_type exclusions ) ;
+ self_type& trim( self_type exclusions ) ;
+ self_type& trim_left() { trim_left( self_type() ) ; }
+ self_type& trim_right() { trim_right( self_type() ) ; }
+ self_type& trim() { trim( self_type() ) ; }
+#endif
+
+ // Assignment operators
+ basic_cstring& operator=( self_type const& s );
+ basic_cstring& operator=( std_string const& s );
+ basic_cstring& operator=( pointer s );
+
+ template<typename CharT2>
+ basic_cstring& assign( basic_cstring<CharT2> const& s ) { *this = basic_cstring<CharT>( s.begin(), s.end() ); return *this; }
+ basic_cstring& assign( self_type const& s, size_type pos, size_type len );
+ basic_cstring& assign( std_string const& s );
+ basic_cstring& assign( std_string const& s, size_type pos, size_type len );
+ basic_cstring& assign( pointer s );
+ basic_cstring& assign( pointer s, size_type len );
+ basic_cstring& assign( pointer f, pointer l );
+
+ // swapping
+ void swap( self_type& s );
+
+ // Iterators
+ iterator begin();
+ const_iterator begin() const;
+ iterator end();
+ const_iterator end() const;
+
+ // !! should have rbegin, rend
+
+ // substring search operation
+ size_type find( basic_cstring ) const;
+ size_type rfind( basic_cstring ) const;
+ self_type substr( size_type beg_index, size_type end_index = npos ) const;
+
+private:
+ static self_type default_trim_ex();
+
+ // Data members
+ iterator m_begin;
+ iterator m_end;
+};
+
+//____________________________________________________________________________//
+
+template<typename CharT>
+inline typename basic_cstring<CharT>::pointer
+basic_cstring<CharT>::null_str()
+{
+ static CharT null = 0;
+ return &null;
+}
+
+//____________________________________________________________________________//
+
+template<typename CharT>
+inline
+basic_cstring<CharT>::basic_cstring()
+: m_begin( null_str() )
+, m_end( m_begin )
+{
+}
+
+//____________________________________________________________________________//
+
+template<typename CharT>
+inline
+basic_cstring<CharT>::basic_cstring( std_string const& s )
+: m_begin( s.c_str() )
+, m_end( m_begin + s.size() )
+{
+}
+
+//____________________________________________________________________________//
+
+template<typename CharT>
+inline
+basic_cstring<CharT>::basic_cstring( pointer s )
+: m_begin( s ? s : null_str() )
+, m_end ( m_begin + (s ? traits_type::length( s ) : 0 ) )
+{
+}
+
+//____________________________________________________________________________//
+
+template<typename CharT>
+inline
+basic_cstring<CharT>::basic_cstring( pointer s, size_type arg_size )
+: m_begin( s ), m_end( m_begin + arg_size )
+{
+}
+
+//____________________________________________________________________________//
+
+template<typename CharT>
+inline
+basic_cstring<CharT>::basic_cstring( pointer first, pointer last )
+: m_begin( first )
+, m_end( last )
+{
+}
+
+//____________________________________________________________________________//
+
+template<typename CharT>
+inline typename basic_cstring<CharT>::value_type
+basic_cstring<CharT>::operator[]( size_type index ) const
+{
+ return m_begin[index];
+}
+
+//____________________________________________________________________________//
+
+template<typename CharT>
+inline typename basic_cstring<CharT>::value_type
+basic_cstring<CharT>::at( size_type index ) const
+{
+ if( m_begin + index >= m_end )
+ return static_cast<value_type>(0);
+
+ return m_begin[index];
+}
+
+//____________________________________________________________________________//
+
+template<typename CharT>
+inline typename basic_cstring<CharT>::size_type
+basic_cstring<CharT>::size() const
+{
+ return m_end - m_begin;
+}
+
+//____________________________________________________________________________//
+
+template<typename CharT>
+inline bool
+basic_cstring<CharT>::is_empty() const
+{
+ return m_end == m_begin;
+}
+
+//____________________________________________________________________________//
+
+template<typename CharT>
+inline bool
+basic_cstring<CharT>::empty() const
+{
+ return is_empty();
+}
+
+//____________________________________________________________________________//
+
+template<typename CharT>
+inline void
+basic_cstring<CharT>::clear()
+{
+ m_begin = m_end;
+}
+
+//____________________________________________________________________________//
+
+template<typename CharT>
+inline void
+basic_cstring<CharT>::resize( size_type new_len )
+{
+ if( m_begin + new_len < m_end )
+ m_end = m_begin + new_len;
+}
+
+//____________________________________________________________________________//
+
+template<typename CharT>
+inline basic_cstring<CharT>&
+basic_cstring<CharT>::trim_left( size_type trim_size )
+{
+ m_begin += trim_size;
+ if( m_end <= m_begin )
+ clear();
+
+ return *this;
+}
+
+//____________________________________________________________________________//
+
+template<typename CharT>
+inline basic_cstring<CharT>&
+basic_cstring<CharT>::trim_left( iterator it )
+{
+ m_begin = it;
+ if( m_end <= m_begin )
+ clear();
+
+ return *this;
+}
+
+//____________________________________________________________________________//
+
+template<typename CharT>
+inline basic_cstring<CharT>&
+basic_cstring<CharT>::trim_left( basic_cstring exclusions )
+{
+ if( exclusions.is_empty() )
+ exclusions = default_trim_ex();
+
+ iterator it;
+ for( it = begin(); it != end(); ++it ) {
+ if( traits_type::find( exclusions.begin(), exclusions.size(), *it ) == reinterpret_cast<pointer>(0) )
+ break;
+ }
+
+ return trim_left( it );
+}
+
+//____________________________________________________________________________//
+
+template<typename CharT>
+inline basic_cstring<CharT>&
+basic_cstring<CharT>::trim_right( size_type trim_size )
+{
+ m_end -= trim_size;
+ if( m_end <= m_begin )
+ clear();
+
+ return *this;
+}
+
+//____________________________________________________________________________//
+
+template<typename CharT>
+inline basic_cstring<CharT>&
+basic_cstring<CharT>::trim_right( iterator it )
+{
+ m_end = it;
+ if( m_end <= m_begin )
+ clear();
+
+ return *this;
+}
+
+//____________________________________________________________________________//
+
+template<typename CharT>
+inline basic_cstring<CharT>&
+basic_cstring<CharT>::trim_right( basic_cstring exclusions )
+{
+ if( exclusions.is_empty() )
+ exclusions = default_trim_ex();
+
+ iterator it;
+
+ for( it = end()-1; it != begin()-1; --it ) {
+ if( self_type::traits_type::find( exclusions.begin(), exclusions.size(), *it ) == reinterpret_cast<pointer>(0) )
+ break;
+ }
+
+ return trim_right( it+1 );
+}
+
+//____________________________________________________________________________//
+
+template<typename CharT>
+inline basic_cstring<CharT>&
+basic_cstring<CharT>::trim( basic_cstring exclusions )
+{
+ trim_left( exclusions );
+ trim_right( exclusions );
+
+ return *this;
+}
+
+//____________________________________________________________________________//
+
+template<typename CharT>
+inline basic_cstring<CharT>&
+basic_cstring<CharT>::operator=( basic_cstring<CharT> const& s )
+{
+ m_begin = s.m_begin;
+ m_end = s.m_end;
+
+ return *this;
+}
+
+//____________________________________________________________________________//
+
+template<typename CharT>
+inline basic_cstring<CharT>&
+basic_cstring<CharT>::operator=( std_string const& s )
+{
+ return *this = self_type( s );
+}
+
+//____________________________________________________________________________//
+
+template<typename CharT>
+inline basic_cstring<CharT>&
+basic_cstring<CharT>::operator=( pointer s )
+{
+ return *this = self_type( s );
+}
+
+//____________________________________________________________________________//
+
+template<typename CharT>
+inline basic_cstring<CharT>&
+basic_cstring<CharT>::assign( basic_cstring<CharT> const& s, size_type pos, size_type len )
+{
+ return *this = self_type( s.m_begin + pos, len );
+}
+
+//____________________________________________________________________________//
+
+template<typename CharT>
+inline basic_cstring<CharT>&
+basic_cstring<CharT>::assign( std_string const& s )
+{
+ return *this = self_type( s );
+}
+
+//____________________________________________________________________________//
+
+template<typename CharT>
+inline basic_cstring<CharT>&
+basic_cstring<CharT>::assign( std_string const& s, size_type pos, size_type len )
+{
+ return *this = self_type( s.c_str() + pos, len );
+}
+
+//____________________________________________________________________________//
+
+template<typename CharT>
+inline basic_cstring<CharT>&
+basic_cstring<CharT>::assign( pointer s )
+{
+ return *this = self_type( s );
+}
+
+//____________________________________________________________________________//
+
+template<typename CharT>
+inline basic_cstring<CharT>&
+basic_cstring<CharT>::assign( pointer s, size_type len )
+{
+ return *this = self_type( s, len );
+}
+
+//____________________________________________________________________________//
+
+template<typename CharT>
+inline basic_cstring<CharT>&
+basic_cstring<CharT>::assign( pointer f, pointer l )
+{
+ return *this = self_type( f, l );
+}
+
+//____________________________________________________________________________//
+
+template<typename CharT>
+inline void
+basic_cstring<CharT>::swap( basic_cstring<CharT>& s )
+{
+ // do not want to include alogrithm
+ pointer tmp1 = m_begin;
+ pointer tmp2 = m_end;
+
+ m_begin = s.m_begin;
+ m_end = s.m_end;
+
+ s.m_begin = tmp1;
+ s.m_end = tmp2;
+}
+
+//____________________________________________________________________________//
+
+template<typename CharT>
+inline typename basic_cstring<CharT>::iterator
+basic_cstring<CharT>::begin()
+{
+ return m_begin;
+}
+
+//____________________________________________________________________________//
+
+template<typename CharT>
+inline typename basic_cstring<CharT>::const_iterator
+basic_cstring<CharT>::begin() const
+{
+ return m_begin;
+}
+
+//____________________________________________________________________________//
+
+template<typename CharT>
+inline typename basic_cstring<CharT>::iterator
+basic_cstring<CharT>::end()
+{
+ return m_end;
+}
+
+//____________________________________________________________________________//
+
+template<typename CharT>
+inline typename basic_cstring<CharT>::const_iterator
+basic_cstring<CharT>::end() const
+{
+ return m_end;
+}
+
+//____________________________________________________________________________//
+
+template<typename CharT>
+inline typename basic_cstring<CharT>::size_type
+basic_cstring<CharT>::find( basic_cstring<CharT> str ) const
+{
+ if( str.is_empty() || str.size() > size() )
+ return static_cast<size_type>(npos);
+
+ const_iterator it = begin();
+ const_iterator last = end() - str.size() + 1;
+
+ while( it != last ) {
+ if( traits_type::compare( it, str.begin(), str.size() ) == 0 )
+ break;
+
+ ++it;
+ }
+
+ return it == last ? static_cast<size_type>(npos) : it - begin();
+}
+
+//____________________________________________________________________________//
+
+template<typename CharT>
+inline typename basic_cstring<CharT>::size_type
+basic_cstring<CharT>::rfind( basic_cstring<CharT> str ) const
+{
+ if( str.is_empty() || str.size() > size() )
+ return static_cast<size_type>(npos);
+
+ const_iterator it = end() - str.size();
+ const_iterator last = begin()-1;
+
+ while( it != last ) {
+ if( traits_type::compare( it, str.begin(), str.size() ) == 0 )
+ break;
+
+ --it;
+ }
+
+ return it == last ? static_cast<size_type>(npos) : static_cast<size_type>(it - begin());
+}
+
+//____________________________________________________________________________//
+
+template<typename CharT>
+inline basic_cstring<CharT>
+basic_cstring<CharT>::substr( size_type beg_index, size_type end_index ) const
+{
+ return beg_index > size()
+ ? self_type()
+ : end_index > size()
+ ? self_type( m_begin + beg_index, m_end )
+ : self_type( m_begin + beg_index, m_begin + end_index );
+}
+
+//____________________________________________________________________________//
+
+template<typename CharT>
+inline basic_cstring<CharT>
+basic_cstring<CharT>::default_trim_ex()
+{
+ static CharT ws[3] = { CharT(' '), CharT('\t'), CharT('\n') }; // !! wide case
+
+ return self_type( ws, 3 );
+}
+
+//____________________________________________________________________________//
+
+// ************************************************************************** //
+// ************** comparison operators ************** //
+// ************************************************************************** //
+
+template<typename CharT1,typename CharT2>
+inline bool
+operator==( basic_cstring<CharT1> const& s1, basic_cstring<CharT2> const& s2 )
+{
+ typedef typename basic_cstring<CharT1>::traits_type traits_type;
+ return s1.size() == s2.size() &&
+ traits_type::compare( s1.begin(), s2.begin(), s1.size() ) == 0;
+}
+
+//____________________________________________________________________________//
+
+template<typename CharT1,typename CharT2>
+inline bool
+operator==( basic_cstring<CharT1> const& s1, CharT2* s2 )
+{
+#if !defined(__DMC__)
+ return s1 == basic_cstring<CharT2>( s2 );
+#else
+ return s1 == basic_cstring<CharT2 const>( s2 );
+#endif
+}
+
+//____________________________________________________________________________//
+
+template<typename CharT>
+inline bool
+operator==( basic_cstring<CharT> const& s1, typename basic_cstring<CharT>::std_string const& s2 )
+{
+ return s1 == basic_cstring<CharT>( s2 );
+}
+
+//____________________________________________________________________________//
+
+template<typename CharT1,typename CharT2>
+inline bool
+operator==( CharT1* s2, basic_cstring<CharT2> const& s1 )
+{
+ return s1 == s2;
+}
+
+//____________________________________________________________________________//
+
+template<typename CharT>
+inline bool
+operator==( typename basic_cstring<CharT>::std_string const& s2, basic_cstring<CharT> const& s1 )
+{
+ return s1 == s2;
+}
+
+//____________________________________________________________________________//
+
+template<typename CharT>
+inline bool
+operator!=( basic_cstring<CharT> const& s1, CharT* s2 )
+{
+ return !(s1 == s2);
+}
+
+//____________________________________________________________________________//
+
+template<typename CharT>
+inline bool
+operator!=( CharT* s2, basic_cstring<CharT> const& s1 )
+{
+ return !(s1 == s2);
+}
+
+//____________________________________________________________________________//
+
+template<typename CharT>
+inline bool
+operator!=( basic_cstring<CharT> const& s1, basic_cstring<CharT> const& s2 )
+{
+ return !(s1 == s2);
+}
+
+//____________________________________________________________________________//
+
+template<typename CharT>
+inline bool
+operator!=( basic_cstring<CharT> const& s1, typename basic_cstring<CharT>::std_string const& s2 )
+{
+ return !(s1 == s2);
+}
+
+//____________________________________________________________________________//
+
+template<typename CharT>
+inline bool
+operator!=( typename basic_cstring<CharT>::std_string const& s2, basic_cstring<CharT> const& s1 )
+{
+ return !(s1 == s2);
+}
+
+//____________________________________________________________________________//
+
+// ************************************************************************** //
+// ************** first_char ************** //
+// ************************************************************************** //
+
+template<typename CharT>
+inline typename basic_cstring<CharT>::value_type
+first_char( basic_cstring<CharT> source )
+{
+ typedef typename basic_cstring<CharT>::value_type string_value_type;
+
+ return source.is_empty() ? static_cast<string_value_type>(0) : *source.begin();
+}
+
+//____________________________________________________________________________//
+
+// ************************************************************************** //
+// ************** last_char ************** //
+// ************************************************************************** //
+
+template<typename CharT>
+inline typename basic_cstring<CharT>::value_type
+last_char( basic_cstring<CharT> source )
+{
+ typedef typename basic_cstring<CharT>::value_type string_value_type;
+
+ return source.is_empty() ? static_cast<string_value_type>(0) : *(source.end()-1);
+}
+
+//____________________________________________________________________________//
+
+// ************************************************************************** //
+// ************** assign_op ************** //
+// ************************************************************************** //
+
+template<typename CharT1, typename CharT2>
+inline void
+assign_op( std::basic_string<CharT1>& target, basic_cstring<CharT2> src, int )
+{
+ target.assign( src.begin(), src.size() );
+}
+
+//____________________________________________________________________________//
+
+} // namespace unit_test
+
+} // namespace ndnboost
+
+//____________________________________________________________________________//
+
+#include <ndnboost/test/detail/enable_warnings.hpp>
+
+#endif // BOOST_TEST_BASIC_CSTRING_HPP_071894GER
diff --git a/ndnboost/test/utils/basic_cstring/basic_cstring_fwd.hpp b/ndnboost/test/utils/basic_cstring/basic_cstring_fwd.hpp
new file mode 100644
index 0000000..14cb33b
--- /dev/null
+++ b/ndnboost/test/utils/basic_cstring/basic_cstring_fwd.hpp
@@ -0,0 +1,40 @@
+// (C) Copyright Gennadiy Rozental 2004-2008.
+// Distributed under 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)
+
+// See http://www.boost.org/libs/test for the library home page.
+//
+// File : $RCSfile$
+//
+// Version : $Revision: 49312 $
+//
+// Description : basic_cstring class wrap C string and provide std_string like
+// interface
+// ***************************************************************************
+
+#ifndef BOOST_TEST_BASIC_CSTRING_FWD_HPP_071894GER
+#define BOOST_TEST_BASIC_CSTRING_FWD_HPP_071894GER
+
+#include <ndnboost/detail/workaround.hpp>
+
+namespace ndnboost {
+
+namespace unit_test {
+
+template<typename CharT> class basic_cstring;
+typedef basic_cstring<char const> const_string;
+#if BOOST_WORKAROUND(__DECCXX_VER, BOOST_TESTED_AT(60590041))
+typedef const_string literal_string;
+#else
+typedef const_string const literal_string;
+#endif
+
+typedef char const* const c_literal_string;
+
+} // namespace unit_test
+
+} // namespace ndnboost
+
+#endif // BOOST_TEST_BASIC_CSTRING_FWD_HPP_071894GER
+
diff --git a/ndnboost/test/utils/basic_cstring/bcs_char_traits.hpp b/ndnboost/test/utils/basic_cstring/bcs_char_traits.hpp
new file mode 100644
index 0000000..d6571f7
--- /dev/null
+++ b/ndnboost/test/utils/basic_cstring/bcs_char_traits.hpp
@@ -0,0 +1,150 @@
+// (C) Copyright Gennadiy Rozental 2004-2008.
+// Distributed under 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)
+
+// See http://www.boost.org/libs/test for the library home page.
+//
+// File : $RCSfile$
+//
+// Version : $Revision: 49312 $
+//
+// Description : generic char traits class; wraps std::char_traits
+// ***************************************************************************
+
+#ifndef BOOST_TEST_BCS_CHAR_TRAITS_HPP_071894GER
+#define BOOST_TEST_BCS_CHAR_TRAITS_HPP_071894GER
+
+// Boost
+#include <ndnboost/config.hpp>
+#include <ndnboost/detail/workaround.hpp>
+#include <ndnboost/test/detail/config.hpp>
+#include <ndnboost/type_traits/add_const.hpp>
+
+// STL
+#include <string> // std::char_traits
+#include <cstddef> // std::size_t
+
+#include <ndnboost/test/detail/suppress_warnings.hpp>
+
+//____________________________________________________________________________//
+
+namespace ndnboost {
+
+namespace unit_test {
+
+namespace ut_detail {
+
+template<typename CharT> struct bcs_base_char { typedef CharT type; };
+
+template<> struct bcs_base_char<char const> { typedef char type; };
+template<> struct bcs_base_char<unsigned char> { typedef char type; };
+#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x551))
+template<> struct bcs_base_char<unsigned char const> { typedef char type; };
+#endif
+
+template<> struct bcs_base_char<wchar_t const> { typedef wchar_t type; };
+
+// ************************************************************************** //
+// ************** bcs_char_traits ************** //
+// ************************************************************************** //
+
+template<typename CharT>
+struct bcs_char_traits_impl
+{
+#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
+ typedef CharT const const_char;
+#else
+ typedef typename ndnboost::add_const<CharT>::type const_char;
+#endif
+ static bool eq( CharT c1, CharT c2 )
+ {
+ return c1 == c2;
+ }
+ static bool lt( CharT c1, CharT c2 )
+ {
+ return c1 < c2;
+ }
+
+ static int compare( const_char* cstr1, const_char* cstr2, std::size_t n )
+ {
+ while( n > 0 ) {
+ if( !eq( *cstr1, *cstr2 ) )
+ return lt( *cstr1, *cstr2 ) ? -1 : 1;
+ ++cstr1;
+ ++cstr2;
+ --n;
+ }
+
+ return 0;
+ }
+
+ static std::size_t length( const_char* cstr )
+ {
+ const_char null_char = CharT();
+
+ const_char* ptr = cstr;
+ while( !eq( *ptr, null_char ) )
+ ++ptr;
+
+ return ptr - cstr;
+ }
+
+ static const_char* find( const_char* s, std::size_t n, CharT c )
+ {
+ while( n > 0 ) {
+ if( eq( *s, c ) )
+ return s;
+
+ ++s;
+ --n;
+ }
+ return 0;
+ }
+};
+
+#ifdef BOOST_CLASSIC_IOSTREAMS
+template<typename CharT>
+struct char_traits_with_find : std::string_char_traits<CharT> {
+ static CharT const* find( CharT const* s, std::size_t n, CharT c )
+ {
+ while( n > 0 ) {
+ if( eq( *s, c ) )
+ return s;
+
+ ++s;
+ --n;
+ }
+ return 0;
+ }
+};
+
+template<> struct bcs_char_traits_impl<char> : char_traits_with_find<char> {};
+template<> struct bcs_char_traits_impl<wchar_t> : char_traits_with_find<wchar_t> {};
+#else
+template<> struct bcs_char_traits_impl<char> : std::char_traits<char> {};
+template<> struct bcs_char_traits_impl<wchar_t> : std::char_traits<wchar_t> {};
+#endif
+
+template<typename CharT>
+class bcs_char_traits : public bcs_char_traits_impl<CharT> {
+ typedef typename ut_detail::bcs_base_char<CharT>::type the_base_char;
+public:
+#ifdef BOOST_CLASSIC_IOSTREAMS
+ typedef std::basic_string<the_base_char, std::string_char_traits<the_base_char> > std_string;
+#else
+ typedef std::basic_string<the_base_char, std::char_traits<the_base_char> > std_string;
+#endif
+};
+
+} // namespace ut_detail
+
+} // namespace unit_test
+
+} // namespace ndnboost
+
+//____________________________________________________________________________//
+
+#include <ndnboost/test/detail/enable_warnings.hpp>
+
+#endif // BOOST_TEST_BCS_CHAR_TRAITS_HPP_071894GER
diff --git a/ndnboost/test/utils/basic_cstring/compare.hpp b/ndnboost/test/utils/basic_cstring/compare.hpp
new file mode 100644
index 0000000..db9c854
--- /dev/null
+++ b/ndnboost/test/utils/basic_cstring/compare.hpp
@@ -0,0 +1,115 @@
+// (C) Copyright Gennadiy Rozental 2004-2008.
+// Distributed under 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)
+
+// See http://www.boost.org/libs/test for the library home page.
+//
+// File : $RCSfile$
+//
+// Version : $Revision: 49312 $
+//
+// Description : class basic_cstring comparisons implementation
+// ***************************************************************************
+
+#ifndef BOOST_TEST_BASIC_CSTRING_COMPARE_HPP_071894GER
+#define BOOST_TEST_BASIC_CSTRING_COMPARE_HPP_071894GER
+
+// Boost.Test
+#include <ndnboost/test/utils/basic_cstring/basic_cstring.hpp>
+
+// STL
+#include <functional>
+#include <cctype>
+
+#include <ndnboost/test/detail/suppress_warnings.hpp>
+
+//____________________________________________________________________________//
+
+# if defined(BOOST_NO_STDC_NAMESPACE) && !BOOST_WORKAROUND(__BORLANDC__, <= 0x570)
+namespace std { using ::toupper; }
+# endif
+
+namespace ndnboost {
+
+namespace unit_test {
+
+// ************************************************************************** //
+// ************** case_ins_compare ************** //
+// ************************************************************************** //
+
+namespace ut_detail {
+
+template<class CharT>
+struct case_ins
+{
+ static bool eq( CharT c1, CharT c2 ) { return (std::toupper)( c1 ) == (std::toupper)( c2 ); }
+ static bool lt( CharT c1, CharT c2 ) { return (std::toupper)( c1 ) < (std::toupper)( c2 ); }
+
+ static int compare( CharT const* s1, CharT const* s2, std::size_t n )
+ {
+ for( std::size_t i = 0; i < n; ++i ) {
+ if( !eq( s1[i], s2[i] ) )
+ return lt( s1[i], s2[i] ) ? -1 : 1;
+ }
+ return 0;
+ }
+};
+
+} // namespace ut_detail
+
+// ************************************************************************** //
+// ************** case_ins_eq ************** //
+// ************************************************************************** //
+
+template<class CharT>
+inline bool
+case_ins_eq( basic_cstring<CharT> x, basic_cstring<CharT> y )
+{
+ return x.size() == y.size() && ut_detail::case_ins<CharT>::compare( x.begin(), y.begin(), x.size() ) == 0;
+}
+
+//____________________________________________________________________________//
+
+// ************************************************************************** //
+// ************** case_ins_less ************** //
+// ************************************************************************** //
+
+template<class CharT>
+class case_ins_less : public std::binary_function<basic_cstring<CharT>,basic_cstring<CharT>,bool>
+{
+public:
+ bool operator()( basic_cstring<CharT> x, basic_cstring<CharT> y ) const
+ {
+ return x.size() != y.size()
+ ? x.size() < y.size()
+ : ut_detail::case_ins<CharT>::compare( x.begin(), y.begin(), x.size() ) < 0;
+ }
+};
+
+//____________________________________________________________________________//
+
+// ************************************************************************** //
+// ************** operator < ************** //
+// ************************************************************************** //
+
+template<class CharT>
+inline bool
+operator <( ndnboost::unit_test::basic_cstring<CharT> const& x,
+ ndnboost::unit_test::basic_cstring<CharT> const& y )
+{
+ typedef typename ndnboost::unit_test::basic_cstring<CharT>::traits_type traits_type;
+ return x.size() != y.size()
+ ? x.size() < y.size()
+ : traits_type::compare( x.begin(), y.begin(), x.size() ) < 0;
+}
+
+} // namespace unit_test
+
+} // namespace ndnboost
+
+//____________________________________________________________________________//
+
+#include <ndnboost/test/detail/enable_warnings.hpp>
+
+#endif // BOOST_TEST_BASIC_CSTRING_COMPARE_HPP_071894GER
diff --git a/ndnboost/test/utils/basic_cstring/io.hpp b/ndnboost/test/utils/basic_cstring/io.hpp
new file mode 100644
index 0000000..adb6d1e
--- /dev/null
+++ b/ndnboost/test/utils/basic_cstring/io.hpp
@@ -0,0 +1,73 @@
+// (C) Copyright Gennadiy Rozental 2004-2008.
+// Distributed under 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)
+
+// See http://www.boost.org/libs/test for the library home page.
+//
+// File : $RCSfile$
+//
+// Version : $Revision: 49312 $
+//
+// Description : basic_cstring i/o implementation
+// ***************************************************************************
+
+#ifndef BOOST_TEST_BASIC_CSTRING_IO_HPP_071894GER
+#define BOOST_TEST_BASIC_CSTRING_IO_HPP_071894GER
+
+// Boost.Test
+#include <ndnboost/test/utils/basic_cstring/basic_cstring.hpp>
+
+// STL
+#include <iosfwd>
+#include <string>
+
+#include <ndnboost/test/detail/suppress_warnings.hpp>
+
+//____________________________________________________________________________//
+
+namespace ndnboost {
+
+namespace unit_test {
+
+#ifdef BOOST_CLASSIC_IOSTREAMS
+
+template<typename CharT>
+inline std::ostream&
+operator<<( std::ostream& os, basic_cstring<CharT> const& str )
+{
+ typedef typename ut_detail::bcs_base_char<CharT>::type char_type;
+ char_type const* const beg = reinterpret_cast<char_type const* const>( str.begin() );
+ char_type const* const end = reinterpret_cast<char_type const* const>( str.end() );
+ os << std::basic_string<char_type>( beg, end - beg );
+
+ return os;
+}
+
+#else
+
+template<typename CharT1, typename Tr,typename CharT2>
+inline std::basic_ostream<CharT1,Tr>&
+operator<<( std::basic_ostream<CharT1,Tr>& os, basic_cstring<CharT2> const& str )
+{
+ CharT1 const* const beg = reinterpret_cast<CharT1 const*>( str.begin() ); // !!
+ CharT1 const* const end = reinterpret_cast<CharT1 const*>( str.end() );
+ os << std::basic_string<CharT1,Tr>( beg, end - beg );
+
+ return os;
+}
+
+#endif
+
+//____________________________________________________________________________//
+
+
+} // namespace unit_test
+
+} // namespace ndnboost
+
+//____________________________________________________________________________//
+
+#include <ndnboost/test/detail/enable_warnings.hpp>
+
+#endif // BOOST_TEST_BASIC_CSTRING_IO_HPP_071894GER
diff --git a/ndnboost/test/utils/callback.hpp b/ndnboost/test/utils/callback.hpp
new file mode 100644
index 0000000..91e23f3
--- /dev/null
+++ b/ndnboost/test/utils/callback.hpp
@@ -0,0 +1,310 @@
+// (C) Copyright Gennadiy Rozental 2005-2008.
+// 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)
+
+// See http://www.boost.org/libs/test for the library home page.
+//
+// File : $RCSfile$
+//
+// Version : $Revision: 49312 $
+//
+// Description :
+// ***************************************************************************
+
+#ifndef BOOST_TEST_CALLBACK_020505GER
+#define BOOST_TEST_CALLBACK_020505GER
+
+// Boost
+#include <ndnboost/config.hpp>
+#include <ndnboost/detail/workaround.hpp>
+#include <ndnboost/shared_ptr.hpp>
+
+#include <ndnboost/test/detail/suppress_warnings.hpp>
+
+#if BOOST_WORKAROUND(BOOST_MSVC, < 1300) || BOOST_WORKAROUND(BOOST_INTEL, <= 700)
+# define BOOST_CALLBACK_EXPLICIT_COPY_CONSTRUCTOR
+#endif
+
+//____________________________________________________________________________//
+
+namespace ndnboost {
+
+namespace unit_test {
+
+namespace ut_detail {
+
+struct unused {};
+
+template<typename R>
+struct invoker {
+ template<typename Functor>
+ R invoke( Functor& f ) { return f(); }
+ template<typename Functor, typename T1>
+ R invoke( Functor& f, T1 t1 ) { return f( t1 ); }
+ template<typename Functor, typename T1, typename T2>
+ R invoke( Functor& f, T1 t1, T2 t2 ) { return f( t1, t2 ); }
+ template<typename Functor, typename T1, typename T2, typename T3>
+ R invoke( Functor& f, T1 t1, T2 t2, T3 t3 ) { return f( t1, t2, t3 ); }
+};
+
+//____________________________________________________________________________//
+
+template<>
+struct invoker<unused> {
+ template<typename Functor>
+ unused invoke( Functor& f ) { f(); return unused(); }
+ template<typename Functor, typename T1>
+ unused invoke( Functor& f, T1 t1 ) { f( t1 ); return unused(); }
+ template<typename Functor, typename T1, typename T2>
+ unused invoke( Functor& f, T1 t1, T2 t2 ) { f( t1, t2 ); return unused(); }
+ template<typename Functor, typename T1, typename T2, typename T3>
+ unused invoke( Functor& f, T1 t1, T2 t2, T3 t3 ) { f( t1, t2, t3 ); return unused(); }
+};
+
+//____________________________________________________________________________//
+
+} // namespace ut_detail
+
+// ************************************************************************** //
+// ************** unit_test::callback0 ************** //
+// ************************************************************************** //
+
+namespace ut_detail {
+
+template<typename R>
+struct callback0_impl {
+ virtual ~callback0_impl() {}
+
+ virtual R invoke() = 0;
+};
+
+//____________________________________________________________________________//
+
+template<typename R, typename Functor>
+struct callback0_impl_t : callback0_impl<R> {
+ // Constructor
+ explicit callback0_impl_t( Functor f ) : m_f( f ) {}
+
+ virtual R invoke() { return invoker<R>().invoke( m_f ); }
+
+private:
+ // Data members
+ Functor m_f;
+};
+
+//____________________________________________________________________________//
+
+} // namespace ut_detail
+
+template<typename R = ut_detail::unused>
+class callback0 {
+public:
+ // Constructors
+ callback0() {}
+#ifdef BOOST_CALLBACK_EXPLICIT_COPY_CONSTRUCTOR
+ callback0( callback0 const& rhs ) : m_impl( rhs.m_impl ) {}
+#endif
+
+ template<typename Functor>
+ callback0( Functor f )
+ : m_impl( new ut_detail::callback0_impl_t<R,Functor>( f ) ) {}
+
+ void operator=( callback0 const& rhs ) { m_impl = rhs.m_impl; }
+
+ template<typename Functor>
+ void operator=( Functor f ) { m_impl.reset( new ut_detail::callback0_impl_t<R,Functor>( f ) ); }
+
+ R operator()() const { return m_impl->invoke(); }
+
+ bool operator!() const { return !m_impl; }
+
+private:
+ // Data members
+ ndnboost::shared_ptr<ut_detail::callback0_impl<R> > m_impl;
+};
+
+// ************************************************************************** //
+// ************** unit_test::callback1 ************** //
+// ************************************************************************** //
+
+namespace ut_detail {
+
+template<typename R, typename T1>
+struct callback1_impl {
+ virtual ~callback1_impl() {}
+
+ virtual R invoke( T1 t1 ) = 0;
+};
+
+//____________________________________________________________________________//
+
+template<typename R, typename T1,typename Functor>
+struct callback1_impl_t : callback1_impl<R,T1> {
+ // Constructor
+ explicit callback1_impl_t( Functor f ) : m_f( f ) {}
+
+ virtual R invoke( T1 t1 ) { return invoker<R>().invoke( m_f, t1 ); }
+
+private:
+ // Data members
+ Functor m_f;
+};
+
+//____________________________________________________________________________//
+
+} // namespace ut_detail
+
+template<typename T1,typename R = ut_detail::unused>
+class callback1 {
+public:
+ // Constructors
+ callback1() {}
+#ifdef BOOST_CALLBACK_EXPLICIT_COPY_CONSTRUCTOR
+ callback1( callback1 const& rhs ) : m_impl( rhs.m_impl ) {}
+#endif
+
+ template<typename Functor>
+ callback1( Functor f )
+ : m_impl( new ut_detail::callback1_impl_t<R,T1,Functor>( f ) ) {}
+
+ void operator=( callback1 const& rhs ) { m_impl = rhs.m_impl; }
+
+ template<typename Functor>
+ void operator=( Functor f ) { m_impl.reset( new ut_detail::callback1_impl_t<R,T1,Functor>( f ) ); }
+
+ R operator()( T1 t1 ) const { return m_impl->invoke( t1 ); }
+
+ bool operator!() const { return !m_impl; }
+
+private:
+ // Data members
+ ndnboost::shared_ptr<ut_detail::callback1_impl<R,T1> > m_impl;
+};
+
+// ************************************************************************** //
+// ************** unit_test::callback2 ************** //
+// ************************************************************************** //
+
+namespace ut_detail {
+
+template<typename R, typename T1,typename T2>
+struct callback2_impl {
+ virtual ~callback2_impl() {}
+
+ virtual R invoke( T1 t1, T2 t2 ) = 0;
+};
+
+//____________________________________________________________________________//
+
+template<typename R, typename T1, typename T2, typename Functor>
+struct callback2_impl_t : callback2_impl<R,T1,T2> {
+ // Constructor
+ explicit callback2_impl_t( Functor f ) : m_f( f ) {}
+
+ virtual R invoke( T1 t1, T2 t2 ) { return invoker<R>().template invoke<Functor,T1,T2>( m_f, t1, t2 ); }
+
+private:
+ // Data members
+ Functor m_f;
+};
+
+//____________________________________________________________________________//
+
+} // namespace ut_detail
+
+template<typename T1,typename T2, typename R = ut_detail::unused>
+class callback2 {
+public:
+ // Constructors
+ callback2() {}
+#ifdef BOOST_CALLBACK_EXPLICIT_COPY_CONSTRUCTOR
+ callback2( callback2 const& rhs ) : m_impl( rhs.m_impl ) {}
+#endif
+
+ template<typename Functor>
+ callback2( Functor f ) : m_impl( new ut_detail::callback2_impl_t<R,T1,T2,Functor>( f ) ) {}
+
+ void operator=( callback2 const& rhs ) { m_impl = rhs.m_impl; }
+
+ template<typename Functor>
+ void operator=( Functor f ) { m_impl.reset( new ut_detail::callback2_impl_t<R,T1,T2,Functor>( f ) ); }
+
+ R operator()( T1 t1, T2 t2 ) const { return m_impl->invoke( t1, t2 ); }
+
+ bool operator!() const { return !m_impl; }
+
+private:
+ // Data members
+ ndnboost::shared_ptr<ut_detail::callback2_impl<R,T1,T2> > m_impl;
+};
+
+// ************************************************************************** //
+// ************** unit_test::callback3 ************** //
+// ************************************************************************** //
+
+namespace ut_detail {
+
+template<typename R, typename T1, typename T2, typename T3>
+struct callback3_impl {
+ virtual ~callback3_impl() {}
+
+ virtual R invoke( T1 t1, T2 t2, T3 t3 ) = 0;
+};
+
+//____________________________________________________________________________//
+
+template<typename R, typename T1, typename T2, typename T3, typename Functor>
+struct callback3_impl_t : callback3_impl<R,T1,T2,T3> {
+ // Constructor
+ explicit callback3_impl_t( Functor f ) : m_f( f ) {}
+
+ virtual R invoke( T1 t1, T2 t2, T3 t3 ) { return invoker<R>().invoke( m_f, t1, t2, t3 ); }
+
+private:
+ // Data members
+ Functor m_f;
+};
+
+//____________________________________________________________________________//
+
+} // namespace ut_detail
+
+template<typename T1,typename T2, typename T3, typename R = ut_detail::unused>
+class callback3 {
+public:
+ // Constructors
+ callback3() {}
+#ifdef BOOST_CALLBACK_EXPLICIT_COPY_CONSTRUCTOR
+ callback3( callback3 const& rhs ) : m_impl( rhs.m_impl ) {}
+#endif
+
+ template<typename Functor>
+ callback3( Functor f )
+ : m_impl( new ut_detail::callback3_impl_t<R,T1,T2,T3,Functor>( f ) ) {}
+
+ void operator=( callback3 const& rhs ) { m_impl = rhs.m_impl; }
+
+ template<typename Functor>
+ void operator=( Functor f ) { m_impl.reset( new ut_detail::callback3_impl_t<R,T1,T2,T3,Functor>( f ) ); }
+
+ R operator()( T1 t1, T2 t2, T3 t3 ) const { return m_impl->invoke( t1, t2, t3 ); }
+
+ bool operator!() const { return !m_impl; }
+
+private:
+ // Data members
+ ndnboost::shared_ptr<ut_detail::callback3_impl<R,T1,T2,T3> > m_impl;
+};
+
+} // namespace unit_test
+
+} // namespace ndnboost
+
+#undef BOOST_CALLBACK_EXPLICIT_COPY_CONSTRUCTOR
+
+//____________________________________________________________________________//
+
+#include <ndnboost/test/detail/enable_warnings.hpp>
+
+#endif // BOOST_TEST_CALLBACK_020505GER
diff --git a/ndnboost/test/utils/class_properties.hpp b/ndnboost/test/utils/class_properties.hpp
new file mode 100644
index 0000000..8da1f45
--- /dev/null
+++ b/ndnboost/test/utils/class_properties.hpp
@@ -0,0 +1,221 @@
+// (C) Copyright Gennadiy Rozental 2001-2008.
+// Distributed under 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)
+
+// See http://www.boost.org/libs/test for the library home page.
+//
+// File : $RCSfile$
+//
+// Version : $Revision: 54633 $
+//
+// Description : simple facility that mimmic notion of read-only read-write
+// properties in C++ classes. Original idea by Henrik Ravn.
+// ***************************************************************************
+
+#ifndef BOOST_TEST_CLASS_PROPERTIES_HPP_071894GER
+#define BOOST_TEST_CLASS_PROPERTIES_HPP_071894GER
+
+// Boost.Test
+#include <ndnboost/test/detail/config.hpp>
+
+// Boost
+#if !BOOST_WORKAROUND(__IBMCPP__, BOOST_TESTED_AT(600))
+#include <ndnboost/preprocessor/seq/for_each.hpp>
+#endif
+#include <ndnboost/call_traits.hpp>
+#include <ndnboost/type_traits/add_pointer.hpp>
+#include <ndnboost/type_traits/add_const.hpp>
+#include <ndnboost/utility/addressof.hpp>
+
+// STL
+#include <iosfwd>
+
+#include <ndnboost/test/detail/suppress_warnings.hpp>
+
+//____________________________________________________________________________//
+
+namespace ndnboost {
+
+namespace unit_test {
+
+// ************************************************************************** //
+// ************** class_property ************** //
+// ************************************************************************** //
+
+template<class PropertyType>
+class class_property {
+protected:
+ typedef typename call_traits<PropertyType>::const_reference read_access_t;
+ typedef typename call_traits<PropertyType>::param_type write_param_t;
+ typedef typename add_pointer<typename add_const<PropertyType>::type>::type address_res_t;
+public:
+ // Constructor
+ class_property() : value( PropertyType() ) {}
+ explicit class_property( write_param_t init_value )
+ : value( init_value ) {}
+
+ // Access methods
+ operator read_access_t() const { return value; }
+ read_access_t get() const { return value; }
+ bool operator!() const { return !value; }
+ address_res_t operator&() const { return &value; }
+
+ // Data members
+#ifndef BOOST_TEST_NO_PROTECTED_USING
+protected:
+#endif
+ PropertyType value;
+};
+
+//____________________________________________________________________________//
+
+#ifdef BOOST_CLASSIC_IOSTREAMS
+
+template<class PropertyType>
+inline std::ostream&
+operator<<( std::ostream& os, class_property<PropertyType> const& p )
+
+#else
+
+template<typename CharT1, typename Tr,class PropertyType>
+inline std::basic_ostream<CharT1,Tr>&
+operator<<( std::basic_ostream<CharT1,Tr>& os, class_property<PropertyType> const& p )
+
+#endif
+{
+ return os << p.get();
+}
+
+//____________________________________________________________________________//
+
+#define DEFINE_PROPERTY_FREE_BINARY_OPERATOR( op ) \
+template<class PropertyType> \
+inline bool \
+operator op( PropertyType const& lhs, class_property<PropertyType> const& rhs ) \
+{ \
+ return lhs op rhs.get(); \
+} \
+template<class PropertyType> \
+inline bool \
+operator op( class_property<PropertyType> const& lhs, PropertyType const& rhs ) \
+{ \
+ return lhs.get() op rhs; \
+} \
+template<class PropertyType> \
+inline bool \
+operator op( class_property<PropertyType> const& lhs, \
+ class_property<PropertyType> const& rhs ) \
+{ \
+ return lhs.get() op rhs.get(); \
+} \
+/**/
+
+DEFINE_PROPERTY_FREE_BINARY_OPERATOR( == )
+DEFINE_PROPERTY_FREE_BINARY_OPERATOR( != )
+
+#undef DEFINE_PROPERTY_FREE_BINARY_OPERATOR
+
+#if BOOST_WORKAROUND(BOOST_MSVC, < 1300)
+
+#define DEFINE_PROPERTY_LOGICAL_OPERATOR( op ) \
+template<class PropertyType> \
+inline bool \
+operator op( bool b, class_property<PropertyType> const& p ) \
+{ \
+ return b op p.get(); \
+} \
+template<class PropertyType> \
+inline bool \
+operator op( class_property<PropertyType> const& p, bool b ) \
+{ \
+ return b op p.get(); \
+} \
+/**/
+
+DEFINE_PROPERTY_LOGICAL_OPERATOR( && )
+DEFINE_PROPERTY_LOGICAL_OPERATOR( || )
+
+#endif
+
+// ************************************************************************** //
+// ************** readonly_property ************** //
+// ************************************************************************** //
+
+template<class PropertyType>
+class readonly_property : public class_property<PropertyType> {
+ typedef class_property<PropertyType> base_prop;
+ typedef typename base_prop::address_res_t arrow_res_t;
+protected:
+ typedef typename base_prop::write_param_t write_param_t;
+public:
+ // Constructor
+ readonly_property() {}
+ explicit readonly_property( write_param_t init_value ) : base_prop( init_value ) {}
+
+ // access methods
+ arrow_res_t operator->() const { return ndnboost::addressof( base_prop::value ); }
+};
+
+//____________________________________________________________________________//
+
+#if BOOST_WORKAROUND(__IBMCPP__, BOOST_TESTED_AT(600))
+
+#define BOOST_READONLY_PROPERTY( property_type, friends ) ndnboost::unit_test::readwrite_property<property_type >
+
+#else
+
+#define BOOST_READONLY_PROPERTY_DECLARE_FRIEND(r, data, elem) friend class elem;
+
+#define BOOST_READONLY_PROPERTY( property_type, friends ) \
+class BOOST_JOIN( readonly_property, __LINE__ ) \
+: public ndnboost::unit_test::readonly_property<property_type > { \
+ typedef ndnboost::unit_test::readonly_property<property_type > base_prop; \
+ BOOST_PP_SEQ_FOR_EACH( BOOST_READONLY_PROPERTY_DECLARE_FRIEND, ' ', friends ) \
+ typedef base_prop::write_param_t write_param_t; \
+public: \
+ BOOST_JOIN( readonly_property, __LINE__ )() {} \
+ explicit BOOST_JOIN( readonly_property, __LINE__ )( write_param_t init_v ) \
+ : base_prop( init_v ) {} \
+} \
+/**/
+
+#endif
+
+// ************************************************************************** //
+// ************** readwrite_property ************** //
+// ************************************************************************** //
+
+template<class PropertyType>
+class readwrite_property : public class_property<PropertyType> {
+ typedef class_property<PropertyType> base_prop;
+ typedef typename add_pointer<PropertyType>::type arrow_res_t;
+ typedef typename base_prop::address_res_t const_arrow_res_t;
+ typedef typename base_prop::write_param_t write_param_t;
+public:
+ readwrite_property() : base_prop() {}
+ explicit readwrite_property( write_param_t init_value ) : base_prop( init_value ) {}
+
+ // access methods
+ void set( write_param_t v ) { base_prop::value = v; }
+ arrow_res_t operator->() { return ndnboost::addressof( base_prop::value ); }
+ const_arrow_res_t operator->() const { return ndnboost::addressof( base_prop::value ); }
+
+#ifndef BOOST_TEST_NO_PROTECTED_USING
+ using base_prop::value;
+#endif
+};
+
+//____________________________________________________________________________//
+
+} // unit_test
+
+} // namespace ndnboost
+
+//____________________________________________________________________________//
+
+#include <ndnboost/test/detail/enable_warnings.hpp>
+
+#undef BOOST_TEST_NO_PROTECTED_USING
+
+#endif // BOOST_TEST_CLASS_PROPERTIES_HPP_071894GER
diff --git a/ndnboost/test/utils/custom_manip.hpp b/ndnboost/test/utils/custom_manip.hpp
new file mode 100644
index 0000000..cf5d76d
--- /dev/null
+++ b/ndnboost/test/utils/custom_manip.hpp
@@ -0,0 +1,63 @@
+// (C) Copyright Gennadiy Rozental 2005-2008.
+// Distributed under 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)
+
+// See http://www.boost.org/libs/test for the library home page.
+//
+// File : $RCSfile$
+//
+// Version : $Revision: 49312 $
+//
+// Description : simple helpers for creating cusom output manipulators
+// ***************************************************************************
+
+#ifndef BOOST_TEST_CUSTOM_MANIP_HPP_071894GER
+#define BOOST_TEST_CUSTOM_MANIP_HPP_071894GER
+
+// STL
+#include <iosfwd>
+
+#include <ndnboost/test/detail/suppress_warnings.hpp>
+
+//____________________________________________________________________________//
+
+namespace ndnboost {
+
+namespace unit_test {
+
+// ************************************************************************** //
+// ************** custom manipulators helpers ************** //
+// ************************************************************************** //
+
+template<typename Manip>
+struct custom_printer {
+ explicit custom_printer( std::ostream& ostr ) : m_ostr( &ostr ) {}
+
+ std::ostream& operator*() const { return *m_ostr; }
+
+private:
+ std::ostream* const m_ostr;
+};
+
+//____________________________________________________________________________//
+
+template<typename Uniq> struct custom_manip {};
+
+//____________________________________________________________________________//
+
+template<typename Uniq>
+inline custom_printer<custom_manip<Uniq> >
+operator<<( std::ostream& ostr, custom_manip<Uniq> const& ) { return custom_printer<custom_manip<Uniq> >( ostr ); }
+
+//____________________________________________________________________________//
+
+} // namespace unit_test
+
+} // namespace ndnboost
+
+//____________________________________________________________________________//
+
+#include <ndnboost/test/detail/enable_warnings.hpp>
+
+#endif // BOOST_TEST_CUSTOM_MANIP_HPP_071894GER
diff --git a/ndnboost/test/utils/fixed_mapping.hpp b/ndnboost/test/utils/fixed_mapping.hpp
new file mode 100644
index 0000000..dc08593
--- /dev/null
+++ b/ndnboost/test/utils/fixed_mapping.hpp
@@ -0,0 +1,124 @@
+// (C) Copyright Gennadiy Rozental 2001-2008.
+// Distributed under 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)
+
+// See http://www.boost.org/libs/test for the library home page.
+//
+// File : $RCSfile$
+//
+// Version : $Revision: 54633 $
+//
+// Description : fixed sized mapping with specified invalid value
+// ***************************************************************************
+
+#ifndef BOOST_TEST_FIXED_MAPPING_HPP_071894GER
+#define BOOST_TEST_FIXED_MAPPING_HPP_071894GER
+
+// Boost
+#include <ndnboost/preprocessor/repetition/repeat.hpp>
+#include <ndnboost/preprocessor/arithmetic/add.hpp>
+#include <ndnboost/call_traits.hpp>
+#include <ndnboost/detail/binary_search.hpp>
+
+// STL
+#include <vector>
+#include <functional>
+#include <algorithm>
+#include <utility>
+
+#include <ndnboost/test/detail/suppress_warnings.hpp>
+
+//____________________________________________________________________________//
+
+namespace ndnboost {
+
+namespace unit_test {
+
+// configurable maximum fixed sized mapping size supported by this header.
+// You can redefine it before inclusion of this file.
+#ifndef MAX_MAP_SIZE
+#define MAX_MAP_SIZE 20
+#endif
+
+#define CONSTR_DECL_MID( z, i, dummy1 ) key_param_type key##i, value_param_type v##i,
+#define CONSTR_BODY_MID( z, i, dummy1 ) add_pair( key##i, v##i );
+
+#define CONSTR_DECL( z, n, dummy1 ) \
+ fixed_mapping( BOOST_PP_REPEAT_ ## z( n, CONSTR_DECL_MID, "" ) \
+ value_param_type invalid_value ) \
+ : m_invalid_value( invalid_value ) \
+ { \
+ BOOST_PP_REPEAT_ ## z( n, CONSTR_BODY_MID, "" ) \
+ init(); \
+ } \
+/**/
+
+#define CONTRUCTORS( n ) BOOST_PP_REPEAT( n, CONSTR_DECL, "" )
+
+template<typename Key, typename Value, typename Compare = std::less<Key> >
+class fixed_mapping
+{
+ typedef std::pair<Key,Value> elem_type;
+ typedef std::vector<elem_type> map_type;
+ typedef typename std::vector<elem_type>::const_iterator iterator;
+
+ typedef typename call_traits<Key>::param_type key_param_type;
+ typedef typename call_traits<Value>::param_type value_param_type;
+ typedef typename call_traits<Value>::const_reference value_ref_type;
+
+#if BOOST_WORKAROUND(__DECCXX_VER, BOOST_TESTED_AT(60590042))
+ struct p1; friend struct p1;
+ struct p2; friend struct p2;
+#endif
+
+ // bind( Compare(), bind(select1st<elem_type>(), _1), bind(identity<Key>(), _2) )
+ struct p1 : public std::binary_function<elem_type,Key,bool>
+ {
+ bool operator()( elem_type const& x, Key const& y ) const { return Compare()( x.first, y ); }
+ };
+
+ // bind( Compare(), bind(select1st<elem_type>(), _1), bind(select1st<elem_type>(), _2) )
+ struct p2 : public std::binary_function<elem_type,elem_type,bool>
+ {
+ bool operator()( elem_type const& x, elem_type const& y ) const { return Compare()( x.first, y.first ); }
+ };
+
+public:
+ // Constructors
+ CONTRUCTORS( BOOST_PP_ADD( MAX_MAP_SIZE, 1 ) )
+
+ // key -> value access
+ value_ref_type operator[]( key_param_type key ) const
+ {
+ iterator it = ndnboost::detail::lower_bound( m_map.begin(), m_map.end(), key, p1() );
+
+ return (it == m_map.end() || Compare()( key, it->first ) ) ? m_invalid_value : it->second;
+ }
+
+private:
+ // Implementation
+ void init() { std::sort( m_map.begin(), m_map.end(), p2() ); }
+ void add_pair( key_param_type key, value_param_type value ) { m_map.push_back( elem_type( key, value ) ); }
+
+ // Data members
+ Value m_invalid_value;
+ map_type m_map;
+};
+
+} // namespace unit_test
+
+} // namespace ndnboost
+
+//____________________________________________________________________________//
+
+#include <ndnboost/test/detail/enable_warnings.hpp>
+
+#undef MAX_MAP_SIZE
+#undef CONSTR_DECL_MID
+#undef CONSTR_BODY_MID
+#undef CONSTR_DECL
+#undef CONTRUCTORS
+
+#endif // BOOST_TEST_FIXED_MAPPING_HPP_071894GER
+
diff --git a/ndnboost/test/utils/foreach.hpp b/ndnboost/test/utils/foreach.hpp
new file mode 100644
index 0000000..8404e72
--- /dev/null
+++ b/ndnboost/test/utils/foreach.hpp
@@ -0,0 +1,281 @@
+// (C) Copyright Eric Niebler 2004-2005
+// (C) Copyright Gennadiy Rozental 2005-2008.
+// Distributed under 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)
+
+// See http://www.boost.org/libs/test for the library home page.
+//
+// File : $RCSfile$
+//
+// Version : $Revision: 54633 $
+//
+// Description : this is an abridged version of an excelent BOOST_FOREACH facility
+// presented by Eric Niebler. I am so fond of it so I can't wait till it
+// going to be accepted into Boost. Also I need version with less number of dependencies
+// and more portable. This version doesn't support rvalues and will reeveluate it's
+// parameters, but should be good enough for my purposes.
+// ***************************************************************************
+
+#ifndef BOOST_TEST_FOREACH_HPP_021005GER
+#define BOOST_TEST_FOREACH_HPP_021005GER
+
+// Boost.Test
+#include <ndnboost/test/detail/config.hpp>
+
+// Boost
+#include <ndnboost/type.hpp>
+#include <ndnboost/mpl/bool.hpp>
+#include <ndnboost/test/detail/workaround.hpp>
+
+#include <ndnboost/type_traits/is_const.hpp>
+
+#include <ndnboost/test/detail/suppress_warnings.hpp>
+
+//____________________________________________________________________________//
+
+namespace ndnboost {
+
+namespace unit_test {
+
+namespace for_each {
+
+// ************************************************************************** //
+// ************** static_any ************** //
+// ************************************************************************** //
+
+struct static_any_base
+{
+ operator bool() const { return false; }
+};
+
+//____________________________________________________________________________//
+
+template<typename Iter>
+struct static_any : static_any_base
+{
+ static_any( Iter const& t ) : m_it( t ) {}
+
+ mutable Iter m_it;
+};
+
+//____________________________________________________________________________//
+
+typedef static_any_base const& static_any_t;
+
+//____________________________________________________________________________//
+
+template<typename Iter>
+inline Iter&
+static_any_cast( static_any_t a, Iter* = 0 )
+{
+ return static_cast<Iter&>( static_cast<static_any<Iter> const&>( a ).m_it );
+}
+
+//____________________________________________________________________________//
+
+// ************************************************************************** //
+// ************** is_const ************** //
+// ************************************************************************** //
+
+template<typename C>
+inline is_const<C>
+is_const_coll( C& )
+{
+ return is_const<C>();
+}
+
+//____________________________________________________________________________//
+
+// ************************************************************************** //
+// ************** begin ************** //
+// ************************************************************************** //
+
+template<typename C>
+inline static_any<BOOST_DEDUCED_TYPENAME C::iterator>
+begin( C& t, mpl::false_ )
+{
+ return static_any<BOOST_DEDUCED_TYPENAME C::iterator>( t.begin() );
+}
+
+//____________________________________________________________________________//
+
+template<typename C>
+inline static_any<BOOST_DEDUCED_TYPENAME C::const_iterator>
+begin( C const& t, mpl::true_ )
+{
+ return static_any<BOOST_DEDUCED_TYPENAME C::const_iterator>( t.begin() );
+}
+
+//____________________________________________________________________________//
+
+// ************************************************************************** //
+// ************** end ************** //
+// ************************************************************************** //
+
+template<typename C>
+inline static_any<BOOST_DEDUCED_TYPENAME C::iterator>
+end( C& t, mpl::false_ )
+{
+ return static_any<BOOST_DEDUCED_TYPENAME C::iterator>( t.end() );
+}
+
+//____________________________________________________________________________//
+
+template<typename C>
+inline static_any<BOOST_DEDUCED_TYPENAME C::const_iterator>
+end( C const& t, mpl::true_ )
+{
+ return static_any<BOOST_DEDUCED_TYPENAME C::const_iterator>( t.end() );
+}
+
+//____________________________________________________________________________//
+
+// ************************************************************************** //
+// ************** done ************** //
+// ************************************************************************** //
+
+template<typename C>
+inline bool
+done( static_any_t cur, static_any_t end, C&, mpl::false_ )
+{
+ return static_any_cast<BOOST_DEDUCED_TYPENAME C::iterator>( cur ) ==
+ static_any_cast<BOOST_DEDUCED_TYPENAME C::iterator>( end );
+}
+
+//____________________________________________________________________________//
+
+template<typename C>
+inline bool
+done( static_any_t cur, static_any_t end, C const&, mpl::true_ )
+{
+ return static_any_cast<BOOST_DEDUCED_TYPENAME C::const_iterator>( cur ) ==
+ static_any_cast<BOOST_DEDUCED_TYPENAME C::const_iterator>( end );
+}
+
+//____________________________________________________________________________//
+
+// ************************************************************************** //
+// ************** next ************** //
+// ************************************************************************** //
+
+template<typename C>
+inline void
+next( static_any_t cur, C&, mpl::false_ )
+{
+ ++static_any_cast<BOOST_DEDUCED_TYPENAME C::iterator>( cur );
+}
+
+//____________________________________________________________________________//
+
+template<typename C>
+inline void
+next( static_any_t cur, C const&, mpl::true_ )
+{
+ ++static_any_cast<BOOST_DEDUCED_TYPENAME C::const_iterator>( cur );
+}
+
+//____________________________________________________________________________//
+
+// ************************************************************************** //
+// ************** deref ************** //
+// ************************************************************************** //
+
+template<class RefType,typename C>
+inline RefType
+deref( static_any_t cur, C&, ::ndnboost::type<RefType>, mpl::false_ )
+{
+ return *static_any_cast<BOOST_DEDUCED_TYPENAME C::iterator>( cur );
+}
+
+//____________________________________________________________________________//
+
+template<class RefType,typename C>
+inline RefType
+deref( static_any_t cur, C const&, ::ndnboost::type<RefType>, mpl::true_ )
+{
+ return *static_any_cast<BOOST_DEDUCED_TYPENAME C::const_iterator>( cur );
+}
+
+//____________________________________________________________________________//
+
+// ************************************************************************** //
+// ************** BOOST_TEST_FOREACH ************** //
+// ************************************************************************** //
+
+#define BOOST_TEST_FE_ANY ::ndnboost::unit_test::for_each::static_any_t
+#define BOOST_TEST_FE_IS_CONST( COL ) ::ndnboost::unit_test::for_each::is_const_coll( COL )
+
+#define BOOST_TEST_FE_BEG( COL ) \
+ ::ndnboost::unit_test::for_each::begin( \
+ COL, \
+ BOOST_TEST_FE_IS_CONST( COL ) ) \
+/**/
+
+#define BOOST_TEST_FE_END( COL ) \
+ ::ndnboost::unit_test::for_each::end( \
+ COL, \
+ BOOST_TEST_FE_IS_CONST( COL ) ) \
+/**/
+
+#define BOOST_TEST_FE_DONE( COL ) \
+ ::ndnboost::unit_test::for_each::done( \
+ BOOST_TEST_FE_CUR_VAR, \
+ BOOST_TEST_FE_END_VAR, \
+ COL, \
+ BOOST_TEST_FE_IS_CONST( COL ) ) \
+/**/
+
+#define BOOST_TEST_FE_NEXT( COL ) \
+ ::ndnboost::unit_test::for_each::next( \
+ BOOST_TEST_FE_CUR_VAR, \
+ COL, \
+ BOOST_TEST_FE_IS_CONST( COL ) ) \
+/**/
+
+#define BOOST_FOREACH_NOOP(COL) \
+ ((void)&(COL))
+
+#define BOOST_TEST_FE_DEREF( COL, RefType ) \
+ ::ndnboost::unit_test::for_each::deref( \
+ BOOST_TEST_FE_CUR_VAR, \
+ COL, \
+ ::ndnboost::type<RefType >(), \
+ BOOST_TEST_FE_IS_CONST( COL ) ) \
+/**/
+
+#if BOOST_WORKAROUND( BOOST_MSVC, == 1310 )
+#define BOOST_TEST_LINE_NUM
+#else
+#define BOOST_TEST_LINE_NUM __LINE__
+#endif
+
+#define BOOST_TEST_FE_CUR_VAR BOOST_JOIN( _fe_cur_, BOOST_TEST_LINE_NUM )
+#define BOOST_TEST_FE_END_VAR BOOST_JOIN( _fe_end_, BOOST_TEST_LINE_NUM )
+#define BOOST_TEST_FE_CON_VAR BOOST_JOIN( _fe_con_, BOOST_TEST_LINE_NUM )
+
+#define BOOST_TEST_FOREACH( RefType, var, COL ) \
+if( BOOST_TEST_FE_ANY BOOST_TEST_FE_CUR_VAR = BOOST_TEST_FE_BEG( COL ) ) {} else \
+if( BOOST_TEST_FE_ANY BOOST_TEST_FE_END_VAR = BOOST_TEST_FE_END( COL ) ) {} else \
+for( bool BOOST_TEST_FE_CON_VAR = true; \
+ BOOST_TEST_FE_CON_VAR && !BOOST_TEST_FE_DONE( COL ); \
+ BOOST_TEST_FE_CON_VAR ? BOOST_TEST_FE_NEXT( COL ) : BOOST_FOREACH_NOOP( COL )) \
+ \
+ if( (BOOST_TEST_FE_CON_VAR = false, false) ) {} else \
+ for( RefType var = BOOST_TEST_FE_DEREF( COL, RefType ); \
+ !BOOST_TEST_FE_CON_VAR; BOOST_TEST_FE_CON_VAR = true ) \
+/**/
+
+//____________________________________________________________________________//
+
+} // namespace for_each
+
+} // namespace unit_test
+
+} // namespace ndnboost
+
+//____________________________________________________________________________//
+
+#include <ndnboost/test/detail/enable_warnings.hpp>
+
+#endif // BOOST_TEST_FOREACH_HPP_021005GER
diff --git a/ndnboost/test/utils/iterator/input_iterator_facade.hpp b/ndnboost/test/utils/iterator/input_iterator_facade.hpp
new file mode 100644
index 0000000..92968ac
--- /dev/null
+++ b/ndnboost/test/utils/iterator/input_iterator_facade.hpp
@@ -0,0 +1,109 @@
+// (C) Copyright Gennadiy Rozental 2004-2008.
+// Distributed under 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)
+
+// See http://www.boost.org/libs/test for the library home page.
+//
+// File : $RCSfile$
+//
+// Version : $Revision: 49312 $
+//
+// Description : Input iterator facade
+// ***************************************************************************
+
+#ifndef BOOST_INPUT_ITERATOR_FACADE_HPP_071894GER
+#define BOOST_INPUT_ITERATOR_FACADE_HPP_071894GER
+
+// Boost
+#include <ndnboost/iterator/iterator_facade.hpp>
+
+#include <ndnboost/test/detail/suppress_warnings.hpp>
+
+//____________________________________________________________________________//
+
+namespace ndnboost {
+
+namespace unit_test {
+
+// ************************************************************************** //
+// ************** input_iterator_core_access ************** //
+// ************************************************************************** //
+
+class input_iterator_core_access
+{
+#if defined(BOOST_NO_MEMBER_TEMPLATE_FRIENDS) || BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x551))
+public:
+#else
+ template <class I, class V, class R, class TC> friend class input_iterator_facade;
+#endif
+
+ template <class Facade>
+ static bool get( Facade& f )
+ {
+ return f.get();
+ }
+
+private:
+ // objects of this class are useless
+ input_iterator_core_access(); //undefined
+};
+
+// ************************************************************************** //
+// ************** input_iterator_facade ************** //
+// ************************************************************************** //
+
+template<typename Derived,
+ typename ValueType,
+ typename Reference = ValueType const&,
+ typename Traversal = single_pass_traversal_tag>
+class input_iterator_facade : public iterator_facade<Derived,ValueType,Traversal,Reference>
+{
+public:
+ // Constructor
+ input_iterator_facade() : m_valid( false ), m_value() {}
+
+protected: // provide access to the Derived
+ void init()
+ {
+ m_valid = true;
+ increment();
+ }
+
+ // Data members
+ mutable bool m_valid;
+ ValueType m_value;
+
+private:
+ friend class ndnboost::iterator_core_access;
+
+ // iterator facade interface implementation
+ void increment()
+ {
+ // we make post-end incrementation indefinetly safe
+ if( m_valid )
+ m_valid = input_iterator_core_access::get( *static_cast<Derived*>(this) );
+ }
+ Reference dereference() const
+ {
+ return m_value;
+ }
+
+ // iterator facade interface implementation
+ bool equal( input_iterator_facade const& rhs ) const
+ {
+ // two invalid iterator equals, inequal otherwise
+ return !m_valid && !rhs.m_valid;
+ }
+};
+
+} // namespace unit_test
+
+} // namespace ndnboost
+
+//____________________________________________________________________________//
+
+#include <ndnboost/test/detail/enable_warnings.hpp>
+
+#endif // BOOST_INPUT_ITERATOR_FACADE_HPP_071894GER
+
diff --git a/ndnboost/test/utils/iterator/token_iterator.hpp b/ndnboost/test/utils/iterator/token_iterator.hpp
new file mode 100644
index 0000000..c1b2dbc
--- /dev/null
+++ b/ndnboost/test/utils/iterator/token_iterator.hpp
@@ -0,0 +1,418 @@
+// (C) Copyright Gennadiy Rozental 2004-2008.
+// Distributed under 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)
+
+// See http://www.boost.org/libs/test for the library home page.
+//
+// File : $RCSfile$
+//
+// Version : $Revision: 54633 $
+//
+// Description : token iterator for string and range tokenization
+// ***************************************************************************
+
+#ifndef BOOST_TOKEN_ITERATOR_HPP_071894GER
+#define BOOST_TOKEN_ITERATOR_HPP_071894GER
+
+// Boost
+#include <ndnboost/config.hpp>
+#include <ndnboost/detail/workaround.hpp>
+
+#include <ndnboost/iterator/iterator_categories.hpp>
+#include <ndnboost/iterator/iterator_traits.hpp>
+
+#include <ndnboost/test/utils/iterator/input_iterator_facade.hpp>
+#include <ndnboost/test/utils/basic_cstring/basic_cstring.hpp>
+#include <ndnboost/test/utils/named_params.hpp>
+#include <ndnboost/test/utils/foreach.hpp>
+
+// STL
+#include <iosfwd>
+#include <cctype>
+
+#include <ndnboost/test/detail/suppress_warnings.hpp>
+
+//____________________________________________________________________________//
+
+#ifdef BOOST_NO_STDC_NAMESPACE
+namespace std{ using ::ispunct; using ::isspace; }
+#endif
+
+namespace ndnboost {
+
+namespace unit_test {
+
+// ************************************************************************** //
+// ************** ti_delimeter_type ************** //
+// ************************************************************************** //
+
+enum ti_delimeter_type {
+ dt_char, // character is delimeter if it among explicit list of some characters
+ dt_ispunct, // character is delimeter if it satisfies ispunct functor
+ dt_isspace, // character is delimeter if it satisfies isspace functor
+ dt_none // no character is delimeter
+};
+
+namespace ut_detail {
+
+// ************************************************************************** //
+// ************** default_char_compare ************** //
+// ************************************************************************** //
+
+template<typename CharT>
+class default_char_compare {
+public:
+ bool operator()( CharT c1, CharT c2 )
+ {
+#ifdef BOOST_CLASSIC_IOSTREAMS
+ return std::string_char_traits<CharT>::eq( c1, c2 );
+#else
+ return std::char_traits<CharT>::eq( c1, c2 );
+#endif
+ }
+};
+
+// ************************************************************************** //
+// ************** delim_policy ************** //
+// ************************************************************************** //
+
+template<typename CharT,typename CharCompare>
+class delim_policy {
+ typedef basic_cstring<CharT const> cstring;
+public:
+ // Constructor
+ explicit delim_policy( ti_delimeter_type t = dt_char, cstring d = cstring() )
+ : m_type( t )
+ {
+ set_delimeters( d );
+ }
+
+ void set_delimeters( ti_delimeter_type t ) { m_type = t; }
+ template<typename Src>
+ void set_delimeters( Src d )
+ {
+ nfp::optionally_assign( m_delimeters, d );
+
+ if( !m_delimeters.is_empty() )
+ m_type = dt_char;
+ }
+
+ bool operator()( CharT c )
+ {
+ switch( m_type ) {
+ case dt_char: {
+ BOOST_TEST_FOREACH( CharT, delim, m_delimeters )
+ if( CharCompare()( delim, c ) )
+ return true;
+
+ return false;
+ }
+ case dt_ispunct:
+ return (std::ispunct)( c ) != 0;
+ case dt_isspace:
+ return (std::isspace)( c ) != 0;
+ case dt_none:
+ return false;
+ }
+
+ return false;
+ }
+
+private:
+ // Data members
+ cstring m_delimeters;
+ ti_delimeter_type m_type;
+};
+
+// ************************************************************************** //
+// ************** token_assigner ************** //
+// ************************************************************************** //
+
+template<typename TraversalTag>
+struct token_assigner {
+#if BOOST_WORKAROUND( BOOST_DINKUMWARE_STDLIB, < 306 )
+ template<typename Iterator, typename C, typename T>
+ static void assign( Iterator b, Iterator e, std::basic_string<C,T>& t )
+ { for( ; b != e; ++b ) t += *b; }
+
+ template<typename Iterator, typename C>
+ static void assign( Iterator b, Iterator e, basic_cstring<C>& t ) { t.assign( b, e ); }
+#else
+ template<typename Iterator, typename Token>
+ static void assign( Iterator b, Iterator e, Token& t ) { t.assign( b, e ); }
+#endif
+ template<typename Iterator, typename Token>
+ static void append_move( Iterator& b, Token& ) { ++b; }
+};
+
+//____________________________________________________________________________//
+
+template<>
+struct token_assigner<single_pass_traversal_tag> {
+ template<typename Iterator, typename Token>
+ static void assign( Iterator b, Iterator e, Token& t ) {}
+
+ template<typename Iterator, typename Token>
+ static void append_move( Iterator& b, Token& t ) { t += *b; ++b; }
+};
+
+} // namespace ut_detail
+
+// ************************************************************************** //
+// ************** modifiers ************** //
+// ************************************************************************** //
+
+namespace {
+nfp::keyword<struct dropped_delimeters_t > dropped_delimeters;
+nfp::keyword<struct kept_delimeters_t > kept_delimeters;
+nfp::typed_keyword<bool,struct keep_empty_tokens_t > keep_empty_tokens;
+nfp::typed_keyword<std::size_t,struct max_tokens_t > max_tokens;
+}
+
+// ************************************************************************** //
+// ************** token_iterator_base ************** //
+// ************************************************************************** //
+
+template<typename Derived,
+ typename CharT,
+ typename CharCompare = ut_detail::default_char_compare<CharT>,
+ typename ValueType = basic_cstring<CharT const>,
+ typename Reference = basic_cstring<CharT const>,
+ typename Traversal = forward_traversal_tag>
+class token_iterator_base
+: public input_iterator_facade<Derived,ValueType,Reference,Traversal> {
+ typedef basic_cstring<CharT const> cstring;
+ typedef ut_detail::delim_policy<CharT,CharCompare> delim_policy;
+ typedef input_iterator_facade<Derived,ValueType,Reference,Traversal> base;
+
+protected:
+ // Constructor
+ explicit token_iterator_base()
+ : m_is_dropped( dt_isspace )
+ , m_is_kept( dt_ispunct )
+ , m_keep_empty_tokens( false )
+ , m_tokens_left( static_cast<std::size_t>(-1) )
+ , m_token_produced( false )
+ {
+ }
+
+ template<typename Modifier>
+ void
+ apply_modifier( Modifier const& m )
+ {
+ if( m.has( dropped_delimeters ) )
+ m_is_dropped.set_delimeters( m[dropped_delimeters] );
+
+ if( m.has( kept_delimeters ) )
+ m_is_kept.set_delimeters( m[kept_delimeters] );
+
+ if( m.has( keep_empty_tokens ) )
+ m_keep_empty_tokens = true;
+
+ nfp::optionally_assign( m_tokens_left, m, max_tokens );
+ }
+
+ template<typename Iter>
+ bool get( Iter& begin, Iter end )
+ {
+ typedef ut_detail::token_assigner<BOOST_DEDUCED_TYPENAME iterator_traversal<Iter>::type> Assigner;
+ Iter check_point;
+
+ this->m_value.clear();
+
+ if( !m_keep_empty_tokens ) {
+ while( begin != end && m_is_dropped( *begin ) )
+ ++begin;
+
+ if( begin == end )
+ return false;
+
+ check_point = begin;
+
+ if( m_tokens_left == 1 )
+ while( begin != end )
+ Assigner::append_move( begin, this->m_value );
+ else if( m_is_kept( *begin ) )
+ Assigner::append_move( begin, this->m_value );
+ else
+ while( begin != end && !m_is_dropped( *begin ) && !m_is_kept( *begin ) )
+ Assigner::append_move( begin, this->m_value );
+
+ --m_tokens_left;
+ }
+ else { // m_keep_empty_tokens is true
+ check_point = begin;
+
+ if( begin == end ) {
+ if( m_token_produced )
+ return false;
+
+ m_token_produced = true;
+ }
+ if( m_is_kept( *begin ) ) {
+ if( m_token_produced )
+ Assigner::append_move( begin, this->m_value );
+
+ m_token_produced = !m_token_produced;
+ }
+ else if( !m_token_produced && m_is_dropped( *begin ) )
+ m_token_produced = true;
+ else {
+ if( m_is_dropped( *begin ) )
+ check_point = ++begin;
+
+ while( begin != end && !m_is_dropped( *begin ) && !m_is_kept( *begin ) )
+ Assigner::append_move( begin, this->m_value );
+
+ m_token_produced = true;
+ }
+ }
+
+ Assigner::assign( check_point, begin, this->m_value );
+
+ return true;
+ }
+
+private:
+ // Data members
+ delim_policy m_is_dropped;
+ delim_policy m_is_kept;
+ bool m_keep_empty_tokens;
+ std::size_t m_tokens_left;
+ bool m_token_produced;
+};
+
+// ************************************************************************** //
+// ************** basic_string_token_iterator ************** //
+// ************************************************************************** //
+
+template<typename CharT,
+ typename CharCompare = ut_detail::default_char_compare<CharT> >
+class basic_string_token_iterator
+: public token_iterator_base<basic_string_token_iterator<CharT,CharCompare>,CharT,CharCompare> {
+ typedef basic_cstring<CharT const> cstring;
+ typedef token_iterator_base<basic_string_token_iterator<CharT,CharCompare>,CharT,CharCompare> base;
+public:
+ explicit basic_string_token_iterator() {}
+ explicit basic_string_token_iterator( cstring src )
+ : m_src( src )
+ {
+ this->init();
+ }
+
+ template<typename Src, typename Modifier>
+ basic_string_token_iterator( Src src, Modifier const& m )
+ : m_src( src )
+ {
+ this->apply_modifier( m );
+
+ this->init();
+ }
+
+private:
+ friend class input_iterator_core_access;
+
+ // input iterator implementation
+ bool get()
+ {
+ typename cstring::iterator begin = m_src.begin();
+ bool res = base::get( begin, m_src.end() );
+
+ m_src.assign( begin, m_src.end() );
+
+ return res;
+ }
+
+ // Data members
+ cstring m_src;
+};
+
+typedef basic_string_token_iterator<char> string_token_iterator;
+typedef basic_string_token_iterator<wchar_t> wstring_token_iterator;
+
+// ************************************************************************** //
+// ************** range_token_iterator ************** //
+// ************************************************************************** //
+
+template<typename Iter,
+ typename CharCompare = ut_detail::default_char_compare<BOOST_DEDUCED_TYPENAME iterator_value<Iter>::type>,
+ typename ValueType = std::basic_string<BOOST_DEDUCED_TYPENAME iterator_value<Iter>::type>,
+ typename Reference = ValueType const&>
+class range_token_iterator
+: public token_iterator_base<range_token_iterator<Iter,CharCompare,ValueType,Reference>,
+ typename iterator_value<Iter>::type,CharCompare,ValueType,Reference> {
+ typedef basic_cstring<typename ValueType::value_type> cstring;
+ typedef token_iterator_base<range_token_iterator<Iter,CharCompare,ValueType,Reference>,
+ typename iterator_value<Iter>::type,CharCompare,ValueType,Reference> base;
+public:
+ explicit range_token_iterator() {}
+ explicit range_token_iterator( Iter begin, Iter end = Iter() )
+ : m_begin( begin ), m_end( end )
+ {
+ this->init();
+ }
+ range_token_iterator( range_token_iterator const& rhs )
+ : base( rhs )
+ {
+ if( this->m_valid ) {
+ m_begin = rhs.m_begin;
+ m_end = rhs.m_end;
+ }
+ }
+
+ template<typename Modifier>
+ range_token_iterator( Iter begin, Iter end, Modifier const& m )
+ : m_begin( begin ), m_end( end )
+ {
+ this->apply_modifier( m );
+
+ this->init();
+ }
+
+private:
+ friend class input_iterator_core_access;
+
+ // input iterator implementation
+ bool get()
+ {
+ return base::get( m_begin, m_end );
+ }
+
+ // Data members
+ Iter m_begin;
+ Iter m_end;
+};
+
+// ************************************************************************** //
+// ************** make_range_token_iterator ************** //
+// ************************************************************************** //
+
+template<typename Iter>
+inline range_token_iterator<Iter>
+make_range_token_iterator( Iter begin, Iter end = Iter() )
+{
+ return range_token_iterator<Iter>( begin, end );
+}
+
+//____________________________________________________________________________//
+
+template<typename Iter,typename Modifier>
+inline range_token_iterator<Iter>
+make_range_token_iterator( Iter begin, Iter end, Modifier const& m )
+{
+ return range_token_iterator<Iter>( begin, end, m );
+}
+
+//____________________________________________________________________________//
+
+} // namespace unit_test
+
+} // namespace ndnboost
+
+//____________________________________________________________________________//
+
+#include <ndnboost/test/detail/enable_warnings.hpp>
+
+#endif // BOOST_TOKEN_ITERATOR_HPP_071894GER
+
diff --git a/ndnboost/test/utils/lazy_ostream.hpp b/ndnboost/test/utils/lazy_ostream.hpp
new file mode 100644
index 0000000..4b9a0a3
--- /dev/null
+++ b/ndnboost/test/utils/lazy_ostream.hpp
@@ -0,0 +1,114 @@
+// (C) Copyright Gennadiy Rozental 2008.
+// Distributed under 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)
+
+// See http://www.boost.org/libs/test for the library home page.
+//
+// File : $RCSfile$
+//
+// Version : $Revision: 49312 $
+//
+// Description : contains definition for all test tools in test toolbox
+// ***************************************************************************
+
+#ifndef BOOST_TEST_LAZY_OSTREAM_HPP_070708GER
+#define BOOST_TEST_LAZY_OSTREAM_HPP_070708GER
+
+// Boost.Test
+#include <ndnboost/test/detail/config.hpp>
+
+// STL
+#include <iosfwd>
+
+#include <ndnboost/test/detail/suppress_warnings.hpp>
+
+//____________________________________________________________________________//
+
+// ************************************************************************** //
+// ************** lazy_ostream ************** //
+// ************************************************************************** //
+
+namespace ndnboost {
+
+namespace unit_test {
+
+class lazy_ostream {
+public:
+ static lazy_ostream& instance() { static lazy_ostream inst; return inst; }
+
+ friend std::ostream& operator<<( std::ostream& ostr, lazy_ostream const& o ) { return o( ostr ); }
+
+ // access method
+ bool empty() const { return m_empty; }
+
+ // actual printing interface; to be accessed only by this class and children
+ virtual std::ostream& operator()( std::ostream& ostr ) const { return ostr; }
+protected:
+ explicit lazy_ostream( bool empty = true ) : m_empty( empty ) {}
+
+ // protected destructor to make sure right one is called
+#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x582))
+public:
+#endif
+ BOOST_TEST_PROTECTED_VIRTUAL ~lazy_ostream() {}
+
+private:
+ // Data members
+ bool m_empty;
+};
+
+//____________________________________________________________________________//
+
+template<typename T>
+class lazy_ostream_impl : public lazy_ostream {
+public:
+ lazy_ostream_impl( lazy_ostream const& prev, T value )
+ : lazy_ostream( false )
+ , m_prev( prev )
+ , m_value( value )
+ {}
+private:
+ virtual std::ostream& operator()( std::ostream& ostr ) const
+ {
+ return m_prev(ostr) << m_value;
+ }
+
+ // Data members
+ lazy_ostream const& m_prev;
+ T m_value;
+};
+
+//____________________________________________________________________________//
+
+template<typename T>
+inline lazy_ostream_impl<T const&>
+operator<<( lazy_ostream const& prev, T const& v )
+{
+ return lazy_ostream_impl<T const&>( prev, v );
+}
+
+//____________________________________________________________________________//
+
+#if BOOST_TEST_USE_STD_LOCALE
+
+template<typename R,typename S>
+inline lazy_ostream_impl<R& (BOOST_TEST_CALL_DECL *)(S&)>
+operator<<( lazy_ostream const& prev, R& (BOOST_TEST_CALL_DECL *man)(S&) )
+{
+ return lazy_ostream_impl<R& (BOOST_TEST_CALL_DECL *)(S&)>( prev, man );
+}
+
+//____________________________________________________________________________//
+
+#endif
+
+} // namespace unit_test
+
+} // namespace ndnboost
+
+//____________________________________________________________________________//
+
+#include <ndnboost/test/detail/enable_warnings.hpp>
+
+#endif // BOOST_TEST_LAZY_OSTREAM_HPP_070708GER
diff --git a/ndnboost/test/utils/named_params.hpp b/ndnboost/test/utils/named_params.hpp
new file mode 100644
index 0000000..371d594
--- /dev/null
+++ b/ndnboost/test/utils/named_params.hpp
@@ -0,0 +1,329 @@
+// (C) Copyright Gennadiy Rozental 2005-2008.
+// Distributed under 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)
+
+// See http://www.boost.org/libs/test for the library home page.
+//
+// File : $RCSfile$
+//
+// Version : $Revision: 54633 $
+//
+// Description : facilities for named function parameters support
+// ***************************************************************************
+
+#ifndef BOOST_TEST_NAMED_PARAM_022505GER
+#define BOOST_TEST_NAMED_PARAM_022505GER
+
+// Boost
+#include <ndnboost/config.hpp>
+#include <ndnboost/detail/workaround.hpp>
+
+// Boost.Test
+#include <ndnboost/test/utils/rtti.hpp>
+#include <ndnboost/test/utils/assign_op.hpp>
+
+#include <ndnboost/type_traits/remove_reference.hpp>
+
+#include <ndnboost/test/detail/suppress_warnings.hpp>
+
+//____________________________________________________________________________//
+
+namespace ndnboost {
+
+namespace nfp { // named function parameters
+
+// ************************************************************************** //
+// ************** forward declarations ************** //
+// ************************************************************************** //
+
+template<typename T, typename unique_id,typename RefType> struct named_parameter;
+template<typename unique_id,bool required> struct keyword;
+
+namespace nfp_detail {
+
+template<typename NP1,typename NP2> struct named_parameter_combine;
+
+// ************************************************************************** //
+// ************** access_to_invalid_parameter ************** //
+// ************************************************************************** //
+
+struct access_to_invalid_parameter {};
+
+//____________________________________________________________________________//
+
+inline void
+report_access_to_invalid_parameter()
+{
+ throw access_to_invalid_parameter();
+}
+
+//____________________________________________________________________________//
+
+// ************************************************************************** //
+// ************** nil ************** //
+// ************************************************************************** //
+
+struct nil {
+ template<typename T>
+#if defined(__GNUC__) || defined(__HP_aCC) || defined(__EDG__) || defined(__SUNPRO_CC)
+ operator T() const
+#else
+ operator T const&() const
+#endif
+ { report_access_to_invalid_parameter(); static T* v = 0; return *v; }
+
+ template<typename T>
+ T any_cast() const
+ { report_access_to_invalid_parameter(); static typename remove_reference<T>::type* v = 0; return *v; }
+
+ template<typename Arg1>
+ nil operator()( Arg1 const& )
+ { report_access_to_invalid_parameter(); return nil(); }
+
+ template<typename Arg1,typename Arg2>
+ nil operator()( Arg1 const&, Arg2 const& )
+ { report_access_to_invalid_parameter(); return nil(); }
+
+ template<typename Arg1,typename Arg2,typename Arg3>
+ nil operator()( Arg1 const&, Arg2 const&, Arg3 const& )
+ { report_access_to_invalid_parameter(); return nil(); }
+
+ // Visitation support
+ template<typename Visitor>
+ void apply_to( Visitor& V ) const {}
+
+ static nil& inst() { static nil s_inst; return s_inst; }
+private:
+ nil() {}
+};
+
+// ************************************************************************** //
+// ************** named_parameter_base ************** //
+// ************************************************************************** //
+
+template<typename Derived>
+struct named_parameter_base {
+ template<typename NP>
+ named_parameter_combine<NP,Derived>
+ operator,( NP const& np ) const { return named_parameter_combine<NP,Derived>( np, *static_cast<Derived const*>(this) ); }
+};
+
+//____________________________________________________________________________//
+
+// ************************************************************************** //
+// ************** named_parameter_combine ************** //
+// ************************************************************************** //
+
+template<typename NP, typename Rest = nil>
+struct named_parameter_combine
+: Rest
+, named_parameter_base<named_parameter_combine<NP,Rest> > {
+ typedef typename NP::ref_type res_type;
+ typedef named_parameter_combine<NP,Rest> self_type;
+
+ // Constructor
+ named_parameter_combine( NP const& np, Rest const& r )
+ : Rest( r )
+ , m_param( np )
+ {}
+
+ // Access methods
+ res_type operator[]( keyword<typename NP::id,true> kw ) const { return m_param[kw]; }
+ res_type operator[]( keyword<typename NP::id,false> kw ) const { return m_param[kw]; }
+ using Rest::operator[];
+
+ bool has( keyword<typename NP::id,false> kw ) const { return m_param.has( kw ); }
+ using Rest::has;
+
+ void erase( keyword<typename NP::id,false> kw ) const { m_param.erase( kw ); }
+ using Rest::erase;
+
+#if BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3206)) || \
+ BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x0610))
+ template<typename NP>
+ named_parameter_combine<NP,self_type> operator,( NP const& np ) const
+ { return named_parameter_combine<NP,self_type>( np, *this ); }
+#else
+ using named_parameter_base<named_parameter_combine<NP,Rest> >::operator,;
+#endif
+
+ // Visitation support
+ template<typename Visitor>
+ void apply_to( Visitor& V ) const
+ {
+ m_param.apply_to( V );
+
+ Rest::apply_to( V );
+ }
+private:
+ // Data members
+ NP m_param;
+};
+
+} // namespace nfp_detail
+
+// ************************************************************************** //
+// ************** named_parameter ************** //
+// ************************************************************************** //
+
+template<typename T, typename unique_id,typename ReferenceType=T&>
+struct named_parameter
+: nfp_detail::named_parameter_base<named_parameter<T, unique_id,ReferenceType> >
+{
+ typedef nfp_detail::nil nil_t;
+ typedef T data_type;
+ typedef ReferenceType ref_type;
+ typedef unique_id id;
+
+ // Constructor
+ explicit named_parameter( ref_type v )
+ : m_value( v )
+ , m_erased( false )
+ {}
+ named_parameter( named_parameter const& np )
+ : m_value( np.m_value )
+ , m_erased( np.m_erased )
+ {}
+
+ // Access methods
+ ref_type operator[]( keyword<unique_id,true> ) const { return m_erased ? nil_t::inst().template any_cast<ref_type>() : m_value; }
+ ref_type operator[]( keyword<unique_id,false> ) const { return m_erased ? nil_t::inst().template any_cast<ref_type>() : m_value; }
+ template<typename UnknownId>
+ nil_t operator[]( keyword<UnknownId,false> ) const { return nil_t::inst(); }
+
+ bool has( keyword<unique_id,false> ) const { return !m_erased; }
+ template<typename UnknownId>
+ bool has( keyword<UnknownId,false> ) const { return false; }
+
+ void erase( keyword<unique_id,false> ) const { m_erased = true; }
+ template<typename UnknownId>
+ void erase( keyword<UnknownId,false> ) const {}
+
+ // Visitation support
+ template<typename Visitor>
+ void apply_to( Visitor& V ) const
+ {
+ V.set_parameter( rtti::type_id<unique_id>(), m_value );
+ }
+
+private:
+ // Data members
+ ref_type m_value;
+ mutable bool m_erased;
+};
+
+//____________________________________________________________________________//
+
+// ************************************************************************** //
+// ************** no_params ************** //
+// ************************************************************************** //
+
+namespace nfp_detail {
+typedef named_parameter<char, struct no_params_type_t,char> no_params_type;
+} // namespace nfp_detail
+
+namespace {
+nfp_detail::no_params_type no_params( '\0' );
+} // local namespace
+
+//____________________________________________________________________________//
+
+// ************************************************************************** //
+// ************** keyword ************** //
+// ************************************************************************** //
+
+template<typename unique_id, bool required = false>
+struct keyword {
+ typedef unique_id id;
+
+ template<typename T>
+ named_parameter<T const,unique_id>
+ operator=( T const& t ) const { return named_parameter<T const,unique_id>( t ); }
+
+ template<typename T>
+ named_parameter<T,unique_id>
+ operator=( T& t ) const { return named_parameter<T,unique_id>( t ); }
+
+ named_parameter<char const*,unique_id,char const*>
+ operator=( char const* t ) const { return named_parameter<char const*,unique_id,char const*>( t ); }
+};
+
+//____________________________________________________________________________//
+
+// ************************************************************************** //
+// ************** typed_keyword ************** //
+// ************************************************************************** //
+
+template<typename T, typename unique_id, bool required = false>
+struct typed_keyword : keyword<unique_id,required> {
+ named_parameter<T const,unique_id>
+ operator=( T const& t ) const { return named_parameter<T const,unique_id>( t ); }
+
+ named_parameter<T,unique_id>
+ operator=( T& t ) const { return named_parameter<T,unique_id>( t ); }
+};
+
+//____________________________________________________________________________//
+
+template<typename unique_id>
+struct typed_keyword<bool,unique_id,false>
+: keyword<unique_id,false>
+, named_parameter<bool,unique_id,bool> {
+ typedef unique_id id;
+
+ typed_keyword() : named_parameter<bool,unique_id,bool>( true ) {}
+
+ named_parameter<bool,unique_id,bool>
+ operator!() const { return named_parameter<bool,unique_id,bool>( false ); }
+};
+
+//____________________________________________________________________________//
+
+// ************************************************************************** //
+// ************** optionally_assign ************** //
+// ************************************************************************** //
+
+template<typename T>
+inline void
+optionally_assign( T&, nfp_detail::nil )
+{
+ nfp_detail::report_access_to_invalid_parameter();
+}
+
+//____________________________________________________________________________//
+
+template<typename T, typename Source>
+inline void
+#if BOOST_WORKAROUND( __MWERKS__, BOOST_TESTED_AT( 0x3003 ) ) \
+ || BOOST_WORKAROUND( __DECCXX_VER, BOOST_TESTED_AT(60590042) )
+optionally_assign( T& target, Source src )
+#else
+optionally_assign( T& target, Source const& src )
+#endif
+{
+ using namespace unit_test;
+
+ assign_op( target, src, static_cast<int>(0) );
+}
+
+//____________________________________________________________________________//
+
+template<typename T, typename Params, typename Keyword>
+inline void
+optionally_assign( T& target, Params const& p, Keyword k )
+{
+ if( p.has(k) )
+ optionally_assign( target, p[k] );
+}
+
+//____________________________________________________________________________//
+
+} // namespace nfp
+
+} // namespace ndnboost
+
+#include <ndnboost/test/detail/enable_warnings.hpp>
+
+#endif // BOOST_TEST_NAMED_PARAM_022505GER
+
diff --git a/ndnboost/test/utils/rtti.hpp b/ndnboost/test/utils/rtti.hpp
new file mode 100644
index 0000000..2413106
--- /dev/null
+++ b/ndnboost/test/utils/rtti.hpp
@@ -0,0 +1,64 @@
+// (C) Copyright Gennadiy Rozental 2005-2008.
+// Distributed under 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)
+
+// See http://www.boost.org/libs/test for the library home page.
+//
+// File : $RCSfile$
+//
+// Version : $Revision: 49312 $
+//
+// Description : simple facilities for accessing type information at runtime
+// ***************************************************************************
+
+#ifndef BOOST_TEST_RTTI_HPP_062604GER
+#define BOOST_TEST_RTTI_HPP_062604GER
+
+#include <cstddef>
+
+namespace ndnboost {
+
+namespace rtti {
+
+// ************************************************************************** //
+// ************** rtti::type_id ************** //
+// ************************************************************************** //
+
+typedef std::ptrdiff_t id_t;
+
+namespace rtti_detail {
+
+template<typename T>
+struct rttid_holder {
+ static id_t id() { return reinterpret_cast<id_t>( &inst() ); }
+
+private:
+ struct rttid {};
+
+ static rttid const& inst() { static rttid s_inst; return s_inst; }
+};
+
+} // namespace rtti_detail
+
+//____________________________________________________________________________//
+
+template<typename T>
+inline id_t
+type_id()
+{
+ return rtti_detail::rttid_holder<T>::id();
+}
+
+//____________________________________________________________________________//
+
+#define BOOST_RTTI_SWITCH( type_id_ ) if( ::ndnboost::rtti::id_t switch_by_id = type_id_ )
+#define BOOST_RTTI_CASE( type ) if( switch_by_id == ::ndnboost::rtti::type_id<type>() )
+
+//____________________________________________________________________________//
+
+} // namespace rtti
+
+} // namespace ndnboost
+
+#endif // BOOST_RT_RTTI_HPP_062604GER
diff --git a/ndnboost/test/utils/runtime/argument.hpp b/ndnboost/test/utils/runtime/argument.hpp
new file mode 100644
index 0000000..c14956c
--- /dev/null
+++ b/ndnboost/test/utils/runtime/argument.hpp
@@ -0,0 +1,112 @@
+// (C) Copyright Gennadiy Rozental 2005-2008.
+// Distributed under 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)
+
+// See http://www.boost.org/libs/test for the library home page.
+//
+// File : $RCSfile$
+//
+// Version : $Revision: 57992 $
+//
+// Description : model of actual argument (both typed and abstract interface)
+// ***************************************************************************
+
+#ifndef BOOST_RT_ARGUMENT_HPP_062604GER
+#define BOOST_RT_ARGUMENT_HPP_062604GER
+
+// Boost.Runtime.Parameter
+#include <ndnboost/test/utils/runtime/config.hpp>
+#include <ndnboost/test/utils/runtime/fwd.hpp>
+#include <ndnboost/test/utils/runtime/validation.hpp>
+
+// Boost.Test
+#include <ndnboost/test/utils/class_properties.hpp>
+#include <ndnboost/test/utils/rtti.hpp>
+
+// STL
+#include <cassert>
+
+namespace ndnboost {
+
+namespace BOOST_RT_PARAM_NAMESPACE {
+
+// ************************************************************************** //
+// ************** runtime::argument ************** //
+// ************************************************************************** //
+
+#ifdef BOOST_MSVC
+# pragma warning(push)
+# pragma warning(disable:4244)
+#endif
+
+class argument {
+public:
+ // Constructor
+ argument( parameter const& p, rtti::id_t value_type )
+ : p_formal_parameter( p )
+ , p_value_type( value_type )
+ {}
+
+ // Destructor
+ virtual ~argument() {}
+
+ // Public properties
+ unit_test::readonly_property<parameter const&> p_formal_parameter;
+ unit_test::readonly_property<rtti::id_t> p_value_type;
+};
+
+// ************************************************************************** //
+// ************** runtime::typed_argument ************** //
+// ************************************************************************** //
+
+template<typename T>
+class typed_argument : public argument {
+public:
+ // Constructor
+ explicit typed_argument( parameter const& p )
+ : argument( p, rtti::type_id<T>() )
+ {}
+ typed_argument( parameter const& p, T const& t )
+ : argument( p, rtti::type_id<T>() )
+ , p_value( t )
+ {}
+
+ unit_test::readwrite_property<T> p_value;
+};
+
+// ************************************************************************** //
+// ************** runtime::arg_value ************** //
+// ************************************************************************** //
+
+template<typename T>
+inline T const&
+arg_value( argument const& arg_ )
+{
+ assert( arg_.p_value_type == rtti::type_id<T>() ); // detect logic error
+
+ return static_cast<typed_argument<T> const&>( arg_ ).p_value.value;
+}
+
+//____________________________________________________________________________//
+
+template<typename T>
+inline T&
+arg_value( argument& arg_ )
+{
+ assert( arg_.p_value_type == rtti::type_id<T>() ); // detect logic error
+
+ return static_cast<typed_argument<T>&>( arg_ ).p_value.value;
+}
+
+#ifdef BOOST_MSVC
+# pragma warning(pop)
+#endif
+
+//____________________________________________________________________________//
+
+} // namespace BOOST_RT_PARAM_NAMESPACE
+
+} // namespace ndnboost
+
+#endif // BOOST_RT_ARGUMENT_HPP_062604GER
diff --git a/ndnboost/test/utils/runtime/cla/argument_factory.hpp b/ndnboost/test/utils/runtime/cla/argument_factory.hpp
new file mode 100644
index 0000000..4f6709b
--- /dev/null
+++ b/ndnboost/test/utils/runtime/cla/argument_factory.hpp
@@ -0,0 +1,218 @@
+// (C) Copyright Gennadiy Rozental 2005-2008.
+// 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)
+
+// See http://www.boost.org/libs/test for the library home page.
+//
+// File : $RCSfile$
+//
+// Version : $Revision: 57992 $
+//
+// Description : generic typed_argument_factory implementation
+// ***************************************************************************
+
+#ifndef BOOST_RT_CLA_ARGUMENT_FACTORY_HPP_062604GER
+#define BOOST_RT_CLA_ARGUMENT_FACTORY_HPP_062604GER
+
+// Boost.Runtime.Parameter
+#include <ndnboost/test/utils/runtime/config.hpp>
+
+#include <ndnboost/test/utils/runtime/fwd.hpp>
+#include <ndnboost/test/utils/runtime/validation.hpp>
+#include <ndnboost/test/utils/runtime/argument.hpp>
+#include <ndnboost/test/utils/runtime/trace.hpp>
+#include <ndnboost/test/utils/runtime/interpret_argument_value.hpp>
+
+#include <ndnboost/test/utils/runtime/cla/fwd.hpp>
+#include <ndnboost/test/utils/runtime/cla/value_generator.hpp>
+#include <ndnboost/test/utils/runtime/cla/value_handler.hpp>
+#include <ndnboost/test/utils/runtime/cla/validation.hpp>
+#include <ndnboost/test/utils/runtime/cla/argv_traverser.hpp>
+#include <ndnboost/test/utils/runtime/cla/detail/argument_value_usage.hpp>
+
+#include <ndnboost/test/utils/runtime/cla/iface/argument_factory.hpp>
+
+// Boost.Test
+#include <ndnboost/test/utils/callback.hpp>
+
+// Boost
+#include <ndnboost/optional.hpp>
+
+namespace ndnboost {
+
+namespace BOOST_RT_PARAM_NAMESPACE {
+
+namespace cla {
+
+// ************************************************************************** //
+// ************** default_value_interpreter ************** //
+// ************************************************************************** //
+
+namespace rt_cla_detail {
+
+struct default_value_interpreter {
+ template<typename T>
+ void operator()( argv_traverser& tr, ndnboost::optional<T>& value )
+ {
+ if( interpret_argument_value( tr.token(), value, 0 ) )
+ tr.next_token();
+ }
+};
+
+} // namespace rt_cla_detail
+
+// ************************************************************************** //
+// ************** typed_argument_factory ************** //
+// ************************************************************************** //
+
+template<typename T>
+struct typed_argument_factory : public argument_factory {
+ // Constructor
+ typed_argument_factory()
+ : m_value_interpreter( rt_cla_detail::default_value_interpreter() )
+ {}
+ BOOST_RT_PARAM_UNNEEDED_VIRTUAL ~typed_argument_factory() {}
+
+ // properties modification
+ template<typename Modifier>
+ void accept_modifier( Modifier const& m )
+ {
+ optionally_assign( m_value_handler, m, handler );
+ optionally_assign( m_value_interpreter, m, interpreter );
+
+ if( m.has( default_value ) ) {
+ BOOST_RT_PARAM_VALIDATE_LOGIC( !m_value_generator,
+ BOOST_RT_PARAM_LITERAL( "multiple value generators for parameter" ) );
+
+ T const& dv_ref = m[default_value];
+ m_value_generator = rt_cla_detail::const_generator<T>( dv_ref );
+ }
+
+ if( m.has( default_refer_to ) ) {
+ BOOST_RT_PARAM_VALIDATE_LOGIC( !m_value_generator,
+ BOOST_RT_PARAM_LITERAL( "multiple value generators for parameter" ) );
+
+ cstring ref_id = m[default_refer_to];
+ m_value_generator = rt_cla_detail::ref_generator<T>( ref_id );
+ }
+
+ if( m.has( assign_to ) ) {
+ BOOST_RT_PARAM_VALIDATE_LOGIC( !m_value_handler,
+ BOOST_RT_PARAM_LITERAL( "multiple value handlers for parameter" ) );
+
+ m_value_handler = rt_cla_detail::assigner<T>( m[assign_to] );
+ }
+ }
+
+ // Argument factory implementation
+ virtual argument_ptr produce_using( parameter& p, argv_traverser& tr );
+ virtual argument_ptr produce_using( parameter& p, parser const& );
+ virtual void argument_usage_info( format_stream& fs );
+
+// !! private?
+ // Data members
+ unit_test::callback2<parameter const&,T&> m_value_handler;
+ unit_test::callback2<parser const&,ndnboost::optional<T>&> m_value_generator;
+ unit_test::callback2<argv_traverser&,ndnboost::optional<T>&> m_value_interpreter;
+};
+
+//____________________________________________________________________________//
+
+template<typename T>
+inline argument_ptr
+typed_argument_factory<T>::produce_using( parameter& p, argv_traverser& tr )
+{
+ ndnboost::optional<T> value;
+
+ try {
+ m_value_interpreter( tr, value );
+ }
+ catch( ... ) { // !! should we do that?
+ BOOST_RT_PARAM_TRACE( "Fail to parse argument value" );
+
+ if( !p.p_optional_value )
+ throw;
+ }
+
+ argument_ptr actual_arg = p.actual_argument();
+
+ BOOST_RT_CLA_VALIDATE_INPUT( !!value || p.p_optional_value, tr,
+ BOOST_RT_PARAM_LITERAL( "Argument value missing for parameter " ) << p.id_2_report() );
+
+ BOOST_RT_CLA_VALIDATE_INPUT( !actual_arg || p.p_multiplicable, tr,
+ BOOST_RT_PARAM_LITERAL( "Unexpected repetition of the parameter " ) << p.id_2_report() );
+
+ if( !!value && !!m_value_handler )
+ m_value_handler( p, *value );
+
+ if( !p.p_multiplicable )
+ actual_arg.reset( p.p_optional_value && (rtti::type_id<T>() != rtti::type_id<bool>())
+ ? static_cast<argument*>(new typed_argument<ndnboost::optional<T> >( p, value ))
+ : static_cast<argument*>(new typed_argument<T>( p, *value )) );
+ else {
+ typedef std::list<ndnboost::optional<T> > optional_list;
+
+ if( !actual_arg )
+ actual_arg.reset( p.p_optional_value
+ ? static_cast<argument*>(new typed_argument<optional_list>( p ))
+ : static_cast<argument*>(new typed_argument<std::list<T> >( p )) );
+
+ if( p.p_optional_value ) {
+ optional_list& values = arg_value<optional_list>( *actual_arg );
+
+ values.push_back( value );
+ }
+ else {
+ std::list<T>& values = arg_value<std::list<T> >( *actual_arg );
+
+ values.push_back( *value );
+ }
+ }
+
+ return actual_arg;
+}
+
+//____________________________________________________________________________//
+
+template<typename T>
+inline argument_ptr
+typed_argument_factory<T>::produce_using( parameter& p, parser const& pa )
+{
+ argument_ptr actual_arg;
+
+ if( !m_value_generator )
+ return actual_arg;
+
+ ndnboost::optional<T> value;
+ m_value_generator( pa, value );
+
+ if( !value )
+ return actual_arg;
+
+ if( !!m_value_handler )
+ m_value_handler( p, *value );
+
+ actual_arg.reset( new typed_argument<T>( p, *value ) );
+
+ return actual_arg;
+}
+
+//____________________________________________________________________________//
+
+template<typename T>
+inline void
+typed_argument_factory<T>::argument_usage_info( format_stream& fs )
+{
+ rt_cla_detail::argument_value_usage( fs, 0, reinterpret_cast<T*>(0) );
+}
+
+//____________________________________________________________________________//
+
+} // namespace ndnboost
+
+} // namespace BOOST_RT_PARAM_NAMESPACE
+
+} // namespace cla
+
+#endif // BOOST_RT_CLA_ARGUMENT_FACTORY_HPP_062604GER
diff --git a/ndnboost/test/utils/runtime/cla/argv_traverser.hpp b/ndnboost/test/utils/runtime/cla/argv_traverser.hpp
new file mode 100644
index 0000000..8674bd2
--- /dev/null
+++ b/ndnboost/test/utils/runtime/cla/argv_traverser.hpp
@@ -0,0 +1,98 @@
+// (C) Copyright Gennadiy Rozental 2005-2008.
+// 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)
+
+// See http://www.boost.org/libs/test for the library home page.
+//
+// File : $RCSfile$
+//
+// Version : $Revision: 57992 $
+//
+// Description : defines facility to hide input traversing details
+// ***************************************************************************
+
+#ifndef BOOST_RT_CLA_ARGV_TRAVERSER_HPP_062604GER
+#define BOOST_RT_CLA_ARGV_TRAVERSER_HPP_062604GER
+
+// Boost.Runtime.Parameter
+#include <ndnboost/test/utils/runtime/config.hpp>
+
+// Boost.Test
+#include <ndnboost/test/utils/class_properties.hpp>
+
+// Boost
+#include <ndnboost/noncopyable.hpp>
+#include <ndnboost/shared_array.hpp>
+
+namespace ndnboost {
+
+namespace BOOST_RT_PARAM_NAMESPACE {
+
+namespace cla {
+
+// ************************************************************************** //
+// ************** runtime::cla::argv_traverser ************** //
+// ************************************************************************** //
+
+class argv_traverser : noncopyable {
+ class parser;
+public:
+ // Constructor
+ argv_traverser();
+
+ // public_properties
+ unit_test::readwrite_property<bool> p_ignore_mismatch;
+ unit_test::readwrite_property<char_type> p_separator;
+
+ // argc+argv <-> internal buffer exchange
+ void init( int argc, char_type** argv );
+ void remainder( int& argc, char_type** argv );
+
+ // token based parsing
+ cstring token() const;
+ void next_token();
+
+ // whole input parsing
+ cstring input() const;
+ void trim( std::size_t size );
+ bool match_front( cstring );
+ bool match_front( char_type c );
+ bool eoi() const;
+
+ // transaction logic support
+ void commit();
+ void rollback();
+
+ // current position access; used to save some reference points in input
+ std::size_t input_pos() const;
+
+ // returns true if mismatch detected during input parsing handled successfully
+ bool handle_mismatch();
+
+private:
+ // Data members
+ dstring m_buffer;
+ cstring m_work_buffer;
+
+ cstring m_token;
+ cstring::iterator m_commited_end;
+
+ shared_array<char_type> m_remainder;
+ std::size_t m_remainder_size;
+};
+
+} // namespace cla
+
+} // namespace BOOST_RT_PARAM_NAMESPACE
+
+} // namespace ndnboost
+
+#ifndef BOOST_RT_PARAM_OFFLINE
+
+# define BOOST_RT_PARAM_INLINE inline
+# include <ndnboost/test/utils/runtime/cla/argv_traverser.ipp>
+
+#endif
+
+#endif // BOOST_RT_CLA_ARGV_TRAVERSER_HPP_062604GER
diff --git a/ndnboost/test/utils/runtime/cla/argv_traverser.ipp b/ndnboost/test/utils/runtime/cla/argv_traverser.ipp
new file mode 100644
index 0000000..da03cd9
--- /dev/null
+++ b/ndnboost/test/utils/runtime/cla/argv_traverser.ipp
@@ -0,0 +1,209 @@
+// (C) Copyright Gennadiy Rozental 2005-2008.
+// 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)
+
+// See http://www.boost.org/libs/test for the library home page.
+//
+// File : $RCSfile$
+//
+// Version : $Revision: 49312 $
+//
+// Description : implements facility to hide input traversing details
+// ***************************************************************************
+
+#ifndef BOOST_RT_CLA_ARGV_TRAVERSER_IPP_070604GER
+#define BOOST_RT_CLA_ARGV_TRAVERSER_IPP_070604GER
+
+// Boost.Runtime.Parameter
+#include <ndnboost/test/utils/runtime/trace.hpp>
+
+#include <ndnboost/test/utils/runtime/cla/argv_traverser.hpp>
+
+// STL
+#include <memory>
+#include <cstring>
+
+#ifdef BOOST_NO_STDC_NAMESPACE
+namespace std { using ::memcpy; }
+#endif
+
+namespace ndnboost {
+
+namespace BOOST_RT_PARAM_NAMESPACE {
+
+namespace cla {
+
+// ************************************************************************** //
+// ************** runtime::cla::argv_traverser ************** //
+// ************************************************************************** //
+
+BOOST_RT_PARAM_INLINE
+argv_traverser::argv_traverser()
+: p_ignore_mismatch( false ), p_separator( BOOST_RT_PARAM_LITERAL( ' ' ) )
+{
+}
+
+//____________________________________________________________________________//
+
+BOOST_RT_PARAM_INLINE void
+argv_traverser::init( int argc, char_type** argv )
+{
+ for( int index = 1; index < argc; ++index ) {
+ m_buffer += argv[index];
+ if( index != argc-1 )
+ m_buffer += BOOST_RT_PARAM_LITERAL( ' ' );
+ }
+
+ m_remainder.reset( new char_type[m_buffer.size()+1] );
+ m_remainder_size = 0;
+ m_work_buffer = m_buffer;
+ m_commited_end = m_work_buffer.begin();
+
+ BOOST_RT_PARAM_TRACE( "Input buffer: " << m_buffer );
+
+ next_token();
+}
+
+//____________________________________________________________________________//
+
+BOOST_RT_PARAM_INLINE void
+argv_traverser::remainder( int& argc, char_type** argv )
+{
+ argc = 1;
+ std::size_t pos = 0;
+ while(pos < m_remainder_size ) {
+ argv[argc++] = m_remainder.get() + pos;
+
+ pos = std::find( m_remainder.get() + pos, m_remainder.get() + m_remainder_size,
+ BOOST_RT_PARAM_LITERAL( ' ' ) ) - m_remainder.get();
+ m_remainder[pos++] = BOOST_RT_PARAM_LITERAL( '\0' );
+ }
+}
+
+//____________________________________________________________________________//
+
+BOOST_RT_PARAM_INLINE cstring
+argv_traverser::token() const
+{
+ return m_token;
+}
+
+//____________________________________________________________________________//
+
+BOOST_RT_PARAM_INLINE void
+argv_traverser::next_token()
+{
+ if( m_work_buffer.is_empty() )
+ return;
+
+ m_work_buffer.trim_left( m_token.size() ); // skip remainder of current token
+
+ if( m_work_buffer.size() != m_buffer.size() ) // !! is there a better way to identify first token
+ m_work_buffer.trim_left( 1 ); // skip separator if not first token;
+
+ m_token.assign( m_work_buffer.begin(),
+ std::find( m_work_buffer.begin(), m_work_buffer.end(), p_separator ) );
+}
+
+//____________________________________________________________________________//
+
+BOOST_RT_PARAM_INLINE cstring
+argv_traverser::input() const
+{
+ return m_work_buffer;
+}
+
+//____________________________________________________________________________//
+
+BOOST_RT_PARAM_INLINE void
+argv_traverser::trim( std::size_t size )
+{
+ m_work_buffer.trim_left( size );
+
+ if( size <= m_token.size() )
+ m_token.trim_left( size );
+ else {
+ m_token.assign( m_work_buffer.begin(),
+ std::find( m_work_buffer.begin(), m_work_buffer.end(), p_separator ) );
+ }
+}
+
+//____________________________________________________________________________//
+
+BOOST_RT_PARAM_INLINE bool
+argv_traverser::match_front( cstring str )
+{
+ return m_work_buffer.size() < str.size() ? false : m_work_buffer.substr( 0, str.size() ) == str;
+}
+
+//____________________________________________________________________________//
+
+BOOST_RT_PARAM_INLINE bool
+argv_traverser::match_front( char_type c )
+{
+ return first_char( m_work_buffer ) == c;
+}
+
+//____________________________________________________________________________//
+
+BOOST_RT_PARAM_INLINE bool
+argv_traverser::eoi() const
+{
+ return m_work_buffer.is_empty();
+}
+
+//____________________________________________________________________________//
+
+BOOST_RT_PARAM_INLINE void
+argv_traverser::commit()
+{
+ m_commited_end = m_work_buffer.begin();
+}
+
+//____________________________________________________________________________//
+
+BOOST_RT_PARAM_INLINE void
+argv_traverser::rollback()
+{
+ m_work_buffer.assign( m_commited_end, m_work_buffer.end() );
+ m_token.assign( m_work_buffer.begin(),
+ std::find( m_work_buffer.begin(), m_work_buffer.end(), p_separator ) );
+
+}
+
+//____________________________________________________________________________//
+
+BOOST_RT_PARAM_INLINE std::size_t
+argv_traverser::input_pos() const
+{
+ return m_work_buffer.begin() - m_commited_end;
+}
+
+//____________________________________________________________________________//
+
+BOOST_RT_PARAM_INLINE bool
+argv_traverser::handle_mismatch()
+{
+ if( !p_ignore_mismatch )
+ return false;
+
+ std::memcpy( m_remainder.get() + m_remainder_size, token().begin(), token().size() );
+ m_remainder_size += token().size();
+ m_remainder[m_remainder_size++] = p_separator;
+
+ next_token();
+ commit();
+
+ return true;
+}
+
+//____________________________________________________________________________//
+
+} // namespace cla
+
+} // namespace BOOST_RT_PARAM_NAMESPACE
+
+} // namespace ndnboost
+
+#endif // BOOST_RT_CLA_ARGV_TRAVERSER_IPP_070604GER
diff --git a/ndnboost/test/utils/runtime/cla/basic_parameter.hpp b/ndnboost/test/utils/runtime/cla/basic_parameter.hpp
new file mode 100644
index 0000000..39ebb72
--- /dev/null
+++ b/ndnboost/test/utils/runtime/cla/basic_parameter.hpp
@@ -0,0 +1,85 @@
+// (C) Copyright Gennadiy Rozental 2005-2008.
+// 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)
+
+// See http://www.boost.org/libs/test for the library home page.
+//
+// File : $RCSfile$
+//
+// Version : $Revision: 54633 $
+//
+// Description : generic custom parameter generator
+// ***************************************************************************
+
+#ifndef BOOST_RT_CLA_BASIC_PARAMETER_HPP_062604GER
+#define BOOST_RT_CLA_BASIC_PARAMETER_HPP_062604GER
+
+// Boost.Runtime.Parameter
+#include <ndnboost/test/utils/runtime/config.hpp>
+
+#include <ndnboost/test/utils/runtime/cla/typed_parameter.hpp>
+
+// Boost.Test
+#include <ndnboost/test/utils/rtti.hpp>
+
+// Boost
+#include <ndnboost/utility/base_from_member.hpp>
+
+namespace ndnboost {
+
+namespace BOOST_RT_PARAM_NAMESPACE {
+
+namespace cla {
+
+// ************************************************************************** //
+// ************** runtime::cla::basic_parameter ************** //
+// ************************************************************************** //
+
+template<typename T, typename IdPolicy>
+class basic_parameter : private base_from_member<IdPolicy>, public typed_parameter<T> {
+public:
+ // Constructors
+ explicit basic_parameter( cstring n )
+ : base_from_member<IdPolicy>()
+ , typed_parameter<T>( base_from_member<IdPolicy>::member )
+ {
+ this->accept_modifier( name = n );
+ }
+
+ // parameter properties modification
+ template<typename Modifier>
+ void accept_modifier( Modifier const& m )
+ {
+ typed_parameter<T>::accept_modifier( m );
+
+ base_from_member<IdPolicy>::member.accept_modifier( m );
+ }
+};
+
+//____________________________________________________________________________//
+
+#define BOOST_RT_CLA_NAMED_PARAM_GENERATORS( param_type ) \
+template<typename T> \
+inline shared_ptr<param_type ## _t<T> > \
+param_type( cstring name = cstring() ) \
+{ \
+ return shared_ptr<param_type ## _t<T> >( new param_type ## _t<T>( name ) ); \
+} \
+ \
+inline shared_ptr<param_type ## _t<cstring> > \
+param_type( cstring name = cstring() ) \
+{ \
+ return shared_ptr<param_type ## _t<cstring> >( new param_type ## _t<cstring>( name ) ); \
+} \
+/**/
+
+//____________________________________________________________________________//
+
+} // namespace cla
+
+} // namespace BOOST_RT_PARAM_NAMESPACE
+
+} // namespace ndnboost
+
+#endif // BOOST_RT_CLA_BASIC_PARAMETER_HPP_062604GER
diff --git a/ndnboost/test/utils/runtime/cla/char_parameter.hpp b/ndnboost/test/utils/runtime/cla/char_parameter.hpp
new file mode 100644
index 0000000..d95b95b
--- /dev/null
+++ b/ndnboost/test/utils/runtime/cla/char_parameter.hpp
@@ -0,0 +1,98 @@
+// (C) Copyright Gennadiy Rozental 2005-2008.
+// 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)
+
+// See http://www.boost.org/libs/test for the library home page.
+//
+// File : $RCSfile$
+//
+// Version : $Revision: 54633 $
+//
+// Description : defines model of parameter with single char name
+// ***************************************************************************
+
+#ifndef BOOST_RT_CLA_CHAR_PARAMETER_HPP_062604GER
+#define BOOST_RT_CLA_CHAR_PARAMETER_HPP_062604GER
+
+// Boost.Runtime.Parameter
+#include <ndnboost/test/utils/runtime/config.hpp>
+#include <ndnboost/test/utils/runtime/validation.hpp>
+
+#include <ndnboost/test/utils/runtime/cla/basic_parameter.hpp>
+#include <ndnboost/test/utils/runtime/cla/id_policy.hpp>
+
+namespace ndnboost {
+
+namespace BOOST_RT_PARAM_NAMESPACE {
+
+namespace cla {
+
+// ************************************************************************** //
+// ************** char_name_policy ************** //
+// ************************************************************************** //
+
+class char_name_policy : public basic_naming_policy {
+public:
+ // Constructor
+ char_name_policy();
+ BOOST_RT_PARAM_UNNEEDED_VIRTUAL ~char_name_policy() {}
+
+ // policy interface
+ virtual bool conflict_with( identification_policy const& ) const;
+
+ // Accept modifier
+ template<typename Modifier>
+ void accept_modifier( Modifier const& m )
+ {
+ basic_naming_policy::accept_modifier( m );
+
+ BOOST_RT_PARAM_VALIDATE_LOGIC( p_name->size() <= 1, "Invalid parameter name " << p_name );
+ }
+};
+
+// ************************************************************************** //
+// ************** runtime::cla::char_parameter ************** //
+// ************************************************************************** //
+
+template<typename T>
+class char_parameter_t : public basic_parameter<T,char_name_policy> {
+ typedef basic_parameter<T,char_name_policy> base;
+public:
+ // Constructors
+ explicit char_parameter_t( char_type name ) : base( cstring( &name, 1 ) ) {}
+};
+
+//____________________________________________________________________________//
+
+template<typename T>
+inline shared_ptr<char_parameter_t<T> >
+char_parameter( char_type name )
+{
+ return shared_ptr<char_parameter_t<T> >( new char_parameter_t<T>( name ) );
+}
+
+//____________________________________________________________________________//
+
+inline shared_ptr<char_parameter_t<cstring> >
+char_parameter( char_type name )
+{
+ return shared_ptr<char_parameter_t<cstring> >( new char_parameter_t<cstring>( name ) );
+}
+
+//____________________________________________________________________________//
+
+} // namespace cla
+
+} // namespace BOOST_RT_PARAM_NAMESPACE
+
+} // namespace ndnboost
+
+#ifndef BOOST_RT_PARAM_OFFLINE
+
+# define BOOST_RT_PARAM_INLINE inline
+# include <ndnboost/test/utils/runtime/cla/char_parameter.ipp>
+
+#endif
+
+#endif // BOOST_RT_CLA_CHAR_PARAMETER_HPP_062604GER
diff --git a/ndnboost/test/utils/runtime/cla/char_parameter.ipp b/ndnboost/test/utils/runtime/cla/char_parameter.ipp
new file mode 100644
index 0000000..5922902
--- /dev/null
+++ b/ndnboost/test/utils/runtime/cla/char_parameter.ipp
@@ -0,0 +1,57 @@
+// (C) Copyright Gennadiy Rozental 2005-2008.
+// 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)
+
+// See http://www.boost.org/libs/test for the library home page.
+//
+// File : $RCSfile$
+//
+// Version : $Revision: 54633 $
+//
+// Description : implements model of parameter with single char name
+// ***************************************************************************
+
+#ifndef BOOST_RT_CLA_CHAR_PARAMETER_IPP_062904GER
+#define BOOST_RT_CLA_CHAR_PARAMETER_IPP_062904GER
+
+// Boost.Runtime.Parameter
+#include <ndnboost/test/utils/runtime/config.hpp>
+
+#include <ndnboost/test/utils/runtime/cla/char_parameter.hpp>
+
+namespace ndnboost {
+
+namespace BOOST_RT_PARAM_NAMESPACE {
+
+namespace cla {
+
+// ************************************************************************** //
+// ************** char_name_policy ************** //
+// ************************************************************************** //
+
+BOOST_RT_PARAM_INLINE
+char_name_policy::char_name_policy()
+: basic_naming_policy( rtti::type_id<char_name_policy>() )
+{
+ assign_op( p_prefix.value, BOOST_RT_PARAM_CSTRING_LITERAL( "-" ), 0 );
+}
+
+//____________________________________________________________________________//
+
+BOOST_RT_PARAM_INLINE bool
+char_name_policy::conflict_with( identification_policy const& id ) const
+{
+ return id.p_type_id == p_type_id &&
+ p_name == static_cast<char_name_policy const&>( id ).p_name;
+}
+
+//____________________________________________________________________________//
+
+} // namespace cla
+
+} // namespace BOOST_RT_PARAM_NAMESPACE
+
+} // namespace ndnboost
+
+#endif // BOOST_RT_CLA_CHAR_PARAMETER_IPP_062904GER
diff --git a/ndnboost/test/utils/runtime/cla/detail/argument_value_usage.hpp b/ndnboost/test/utils/runtime/cla/detail/argument_value_usage.hpp
new file mode 100644
index 0000000..b78097b
--- /dev/null
+++ b/ndnboost/test/utils/runtime/cla/detail/argument_value_usage.hpp
@@ -0,0 +1,82 @@
+// (C) Copyright Gennadiy Rozental 2005-2008.
+// Permission to copy, use, modify, sell and distribute this software
+// is granted provided this copyright notice appears in all copies.
+// This software is provided "as is" without express or implied warranty,
+// and with no claim as to its suitability for any purpose.
+
+// See http://www.boost.org for updates, documentation, and revision history.
+//
+// File : $RCSfile$
+//
+// Version : $Revision: 54633 $
+//
+// Description : argument usage printing helpers
+// ***************************************************************************
+
+#ifndef BOOST_RT_CLA_ARGUMENT_VALUE_USAGE_HPP_062604GER
+#define BOOST_RT_CLA_ARGUMENT_VALUE_USAGE_HPP_062604GER
+
+// Boost.Runtime.Parameter
+#include <ndnboost/test/utils/runtime/config.hpp>
+#include <ndnboost/test/utils/runtime/cla/argv_traverser.hpp>
+
+// Boost.Test
+#include <ndnboost/test/utils/basic_cstring/io.hpp>
+#include <ndnboost/test/utils/basic_cstring/compare.hpp>
+
+#include <ndnboost/lexical_cast.hpp>
+
+// STL
+// !! can we eliminate these includes?
+#include <list>
+
+namespace ndnboost {
+
+namespace BOOST_RT_PARAM_NAMESPACE {
+
+namespace cla {
+
+namespace rt_cla_detail {
+
+// ************************************************************************** //
+// ************** argument_value_usage ************** //
+// ************************************************************************** //
+
+// generic case
+template<typename T>
+inline void
+argument_value_usage( format_stream& fs, long, T* = 0 )
+{
+ fs << BOOST_RT_PARAM_CSTRING_LITERAL( "<value>" );
+}
+
+//____________________________________________________________________________//
+
+// specialization for list of values
+template<typename T>
+inline void
+argument_value_usage( format_stream& fs, int, std::list<T>* = 0 )
+{
+ fs << BOOST_RT_PARAM_CSTRING_LITERAL( "(<value1>, ..., <valueN>)" );
+}
+
+//____________________________________________________________________________//
+
+// specialization for type bool
+inline void
+argument_value_usage( format_stream& fs, int, bool* = 0 )
+{
+ fs << BOOST_RT_PARAM_CSTRING_LITERAL( "yes|y|no|n" );
+}
+
+//____________________________________________________________________________//
+
+} // namespace rt_cla_detail
+
+} // namespace cla
+
+} // namespace BOOST_RT_PARAM_NAMESPACE
+
+} // namespace ndnboost
+
+#endif // BOOST_RT_CLA_ARGUMENT_VALUE_USAGE_HPP_062604GER
diff --git a/ndnboost/test/utils/runtime/cla/dual_name_parameter.hpp b/ndnboost/test/utils/runtime/cla/dual_name_parameter.hpp
new file mode 100644
index 0000000..3adbb85
--- /dev/null
+++ b/ndnboost/test/utils/runtime/cla/dual_name_parameter.hpp
@@ -0,0 +1,96 @@
+// (C) Copyright Gennadiy Rozental 2005-2008.
+// 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)
+
+// See http://www.boost.org/libs/test for the library home page.
+//
+// File : $RCSfile$
+//
+// Version : $Revision: 54633 $
+//
+// Description : defines model of generic parameter with dual naming
+// ***************************************************************************
+
+#ifndef BOOST_RT_CLA_DUAL_NAME_PARAMETER_HPP_062604GER
+#define BOOST_RT_CLA_DUAL_NAME_PARAMETER_HPP_062604GER
+
+// Boost.Runtime.Parameter
+#include <ndnboost/test/utils/runtime/config.hpp>
+
+#include <ndnboost/test/utils/runtime/cla/named_parameter.hpp>
+#include <ndnboost/test/utils/runtime/cla/char_parameter.hpp>
+
+namespace ndnboost {
+
+namespace BOOST_RT_PARAM_NAMESPACE {
+
+namespace cla {
+
+// ************************************************************************** //
+// ************** dual_name_policy ************** //
+// ************************************************************************** //
+
+class dual_name_policy : public dual_id_policy<dual_name_policy,string_name_policy,char_name_policy> {
+public:
+ dual_name_policy();
+
+ // Accept modifier
+ template<typename Modifier>
+ void accept_modifier( Modifier const& m )
+ {
+ if( m.has( prefix ) ) {
+ set_prefix( m[prefix] );
+ m.erase( prefix );
+ }
+
+ if( m.has( name ) ) {
+ set_name( m[name] );
+ m.erase( name );
+ }
+
+ if( m.has( separator ) ) {
+ set_separator( m[separator] );
+ m.erase( separator );
+ }
+
+ dual_id_policy<dual_name_policy,string_name_policy,char_name_policy>::accept_modifier( m );
+ }
+private:
+ void set_prefix( cstring );
+ void set_name( cstring );
+ void set_separator( cstring );
+};
+
+// ************************************************************************** //
+// ************** runtime::cla::dual_name_parameter ************** //
+// ************************************************************************** //
+
+template<typename T>
+class dual_name_parameter_t : public basic_parameter<T,dual_name_policy> {
+ typedef basic_parameter<T,dual_name_policy> base;
+public:
+ // Constructors
+ explicit dual_name_parameter_t( cstring name ) : base( name ) {}
+};
+
+//____________________________________________________________________________//
+
+BOOST_RT_CLA_NAMED_PARAM_GENERATORS( dual_name_parameter )
+
+//____________________________________________________________________________//
+
+} // namespace cla
+
+} // namespace BOOST_RT_PARAM_NAMESPACE
+
+} // namespace ndnboost
+
+#ifndef BOOST_RT_PARAM_OFFLINE
+
+# define BOOST_RT_PARAM_INLINE inline
+# include <ndnboost/test/utils/runtime/cla/dual_name_parameter.ipp>
+
+#endif
+
+#endif // BOOST_RT_CLA_DUAL_NAME_PARAMETER_HPP_062604GER
diff --git a/ndnboost/test/utils/runtime/cla/dual_name_parameter.ipp b/ndnboost/test/utils/runtime/cla/dual_name_parameter.ipp
new file mode 100644
index 0000000..8fcb04f
--- /dev/null
+++ b/ndnboost/test/utils/runtime/cla/dual_name_parameter.ipp
@@ -0,0 +1,90 @@
+// (C) Copyright Gennadiy Rozental 2005-2008.
+// 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)
+
+// See http://www.boost.org/libs/test for the library home page.
+//
+// File : $RCSfile$
+//
+// Version : $Revision: 49312 $
+//
+// Description : implements model of generic parameter with dual naming
+// ***************************************************************************
+
+#ifndef BOOST_RT_CLA_DUAL_NAME_PARAMETER_IPP_062904GER
+#define BOOST_RT_CLA_DUAL_NAME_PARAMETER_IPP_062904GER
+
+// Boost.Runtime.Parameter
+#include <ndnboost/test/utils/runtime/config.hpp>
+#include <ndnboost/test/utils/runtime/validation.hpp>
+
+#include <ndnboost/test/utils/runtime/cla/dual_name_parameter.hpp>
+
+namespace ndnboost {
+
+namespace BOOST_RT_PARAM_NAMESPACE {
+
+namespace cla {
+
+// ************************************************************************** //
+// ************** dual_name_policy ************** //
+// ************************************************************************** //
+
+BOOST_RT_PARAM_INLINE
+dual_name_policy::dual_name_policy()
+{
+ m_primary.accept_modifier( prefix = BOOST_RT_PARAM_CSTRING_LITERAL( "--" ) );
+ m_secondary.accept_modifier( prefix = BOOST_RT_PARAM_CSTRING_LITERAL( "-" ) );
+}
+
+//____________________________________________________________________________//
+
+namespace {
+
+template<typename K>
+inline void
+split( string_name_policy& snp, char_name_policy& cnp, cstring src, K const& k )
+{
+ cstring::iterator sep = std::find( src.begin(), src.end(), BOOST_RT_PARAM_LITERAL( '|' ) );
+
+ if( sep != src.begin() )
+ snp.accept_modifier( k = cstring( src.begin(), sep ) );
+
+ if( sep != src.end() )
+ cnp.accept_modifier( k = cstring( sep+1, src.end() ) );
+}
+
+} // local namespace
+
+BOOST_RT_PARAM_INLINE void
+dual_name_policy::set_prefix( cstring src )
+{
+ split( m_primary, m_secondary, src, prefix );
+}
+
+//____________________________________________________________________________//
+
+BOOST_RT_PARAM_INLINE void
+dual_name_policy::set_name( cstring src )
+{
+ split( m_primary, m_secondary, src, name );
+}
+
+//____________________________________________________________________________//
+
+BOOST_RT_PARAM_INLINE void
+dual_name_policy::set_separator( cstring src )
+{
+ split( m_primary, m_secondary, src, separator );
+}
+
+//____________________________________________________________________________//
+
+} // namespace cla
+
+} // namespace BOOST_RT_PARAM_NAMESPACE
+
+} // namespace ndnboost
+
+#endif // BOOST_RT_CLA_DUAL_NAME_PARAMETER_IPP_062904GER
diff --git a/ndnboost/test/utils/runtime/cla/fwd.hpp b/ndnboost/test/utils/runtime/cla/fwd.hpp
new file mode 100644
index 0000000..4065e9b
--- /dev/null
+++ b/ndnboost/test/utils/runtime/cla/fwd.hpp
@@ -0,0 +1,55 @@
+// (C) Copyright Gennadiy Rozental 2005-2008.
+// 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)
+
+// See http://www.boost.org/libs/test for the library home page.
+//
+// File : $RCSfile$
+//
+// Version : $Revision: 49312 $
+//
+// Description : cla subsystem forward declarations
+// ***************************************************************************
+
+#ifndef BOOST_RT_CLA_FWD_HPP_062604GER
+#define BOOST_RT_CLA_FWD_HPP_062604GER
+
+// Boost.Runtime.Parameter
+#include <ndnboost/test/utils/runtime/config.hpp>
+
+// Boost
+#include <ndnboost/shared_ptr.hpp>
+
+namespace ndnboost {
+
+namespace BOOST_RT_PARAM_NAMESPACE {
+
+namespace cla {
+
+class parser;
+class parameter;
+typedef shared_ptr<parameter> parameter_ptr;
+class naming_policy;
+typedef shared_ptr<naming_policy> naming_policy_ptr;
+class argv_traverser;
+
+namespace rt_cla_detail {
+
+template<typename T> class const_generator;
+template<typename T> class ref_generator;
+
+template<typename T> class assigner;
+
+class named_parameter_base;
+class positional_parameter_base;
+
+} // namespace rt_cla_detail
+
+} // namespace cla
+
+} // namespace BOOST_RT_PARAM_NAMESPACE
+
+} // namespace ndnboost
+
+#endif // BOOST_RT_CLA_FWD_HPP_062604GER
diff --git a/ndnboost/test/utils/runtime/cla/id_policy.hpp b/ndnboost/test/utils/runtime/cla/id_policy.hpp
new file mode 100644
index 0000000..fb29cb7
--- /dev/null
+++ b/ndnboost/test/utils/runtime/cla/id_policy.hpp
@@ -0,0 +1,145 @@
+// (C) Copyright Gennadiy Rozental 2005-2008.
+// 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)
+
+// See http://www.boost.org/libs/test for the library home page.
+//
+// File : $RCSfile$
+//
+// Version : $Revision: 57992 $
+//
+// Description : some generic identification policies definition
+// ***************************************************************************
+
+#ifndef BOOST_RT_CLA_ID_POLICY_HPP_062604GER
+#define BOOST_RT_CLA_ID_POLICY_HPP_062604GER
+
+// Boost.Runtime.Parameter
+#include <ndnboost/test/utils/runtime/config.hpp>
+
+#include <ndnboost/test/utils/runtime/cla/fwd.hpp>
+#include <ndnboost/test/utils/runtime/cla/modifier.hpp>
+#include <ndnboost/test/utils/runtime/cla/argv_traverser.hpp>
+
+#include <ndnboost/test/utils/runtime/cla/iface/id_policy.hpp>
+
+// Boost.Test
+#include <ndnboost/test/utils/class_properties.hpp>
+#include <ndnboost/test/utils/rtti.hpp>
+
+namespace ndnboost {
+
+namespace BOOST_RT_PARAM_NAMESPACE {
+
+namespace cla {
+
+// ************************************************************************** //
+// ************** naming_policy_base ************** //
+// ************************************************************************** //
+// model: <prefix> <name> <separtor>
+
+class basic_naming_policy : public identification_policy {
+public:
+ // Public properties
+ unit_test::readwrite_property<dstring> p_prefix;
+ unit_test::readwrite_property<dstring> p_name;
+ unit_test::readwrite_property<dstring> p_separator;
+
+ // Policy interface
+ virtual bool responds_to( cstring name ) const { return p_name == name; }
+ virtual cstring id_2_report() const { return p_name.get(); }
+ virtual void usage_info( format_stream& fs ) const;
+ virtual bool matching( parameter const& p, argv_traverser& tr, bool primary ) const;
+
+ // Accept modifier
+ template<typename Modifier>
+ void accept_modifier( Modifier const& m )
+ {
+ nfp::optionally_assign( p_prefix.value, m, prefix );
+ nfp::optionally_assign( p_name.value, m, name );
+ nfp::optionally_assign( p_separator.value, m, separator );
+ }
+
+protected:
+ explicit basic_naming_policy( rtti::id_t dyn_type )
+ : identification_policy( dyn_type )
+ {}
+ BOOST_RT_PARAM_UNNEEDED_VIRTUAL ~basic_naming_policy() {}
+
+ // Naming policy interface
+ virtual bool match_prefix( argv_traverser& tr ) const;
+ virtual bool match_name( argv_traverser& tr ) const;
+ virtual bool match_separator( argv_traverser& tr, bool optional_value ) const;
+};
+
+// ************************************************************************** //
+// ************** dual_id_policy ************** //
+// ************************************************************************** //
+
+template<typename MostDerived,typename PrimaryId,typename SecondId>
+class dual_id_policy : public identification_policy {
+public:
+ // Constructor
+ dual_id_policy()
+ : identification_policy( rtti::type_id<MostDerived>() )
+ , m_primary()
+ , m_secondary()
+ {}
+
+ // Policy interface
+ virtual bool responds_to( cstring name ) const
+ {
+ return m_primary.responds_to( name ) || m_secondary.responds_to( name );
+ }
+ virtual bool conflict_with( identification_policy const& id_p ) const
+ {
+ return id_p.conflict_with( m_primary ) || id_p.conflict_with( m_secondary );
+ }
+ virtual cstring id_2_report() const
+ {
+ return m_primary.id_2_report();
+ }
+ virtual void usage_info( format_stream& fs ) const
+ {
+ fs << BOOST_RT_PARAM_LITERAL( '{' );
+ m_primary.usage_info( fs );
+ fs << BOOST_RT_PARAM_LITERAL( '|' );
+ m_secondary.usage_info( fs );
+ fs << BOOST_RT_PARAM_LITERAL( '}' );
+ }
+ virtual bool matching( parameter const& p, argv_traverser& tr, bool primary ) const
+ {
+ return m_primary.matching( p, tr, primary ) || m_secondary.matching( p, tr, primary );
+ }
+
+ // Accept modifier
+ template<typename Modifier>
+ void accept_modifier( Modifier const& m )
+ {
+ m_primary.accept_modifier( m );
+ m_secondary.accept_modifier( m );
+ }
+
+protected:
+ BOOST_RT_PARAM_UNNEEDED_VIRTUAL ~dual_id_policy() {}
+
+ // Data members
+ PrimaryId m_primary;
+ SecondId m_secondary;
+};
+
+} // namespace cla
+
+} // namespace BOOST_RT_PARAM_NAMESPACE
+
+} // namespace ndnboost
+
+#ifndef BOOST_RT_PARAM_OFFLINE
+
+# define BOOST_RT_PARAM_INLINE inline
+# include <ndnboost/test/utils/runtime/cla/id_policy.ipp>
+
+#endif
+
+#endif // BOOST_RT_CLA_ID_POLICY_HPP_062604GER
diff --git a/ndnboost/test/utils/runtime/cla/id_policy.ipp b/ndnboost/test/utils/runtime/cla/id_policy.ipp
new file mode 100644
index 0000000..6d2c2f4
--- /dev/null
+++ b/ndnboost/test/utils/runtime/cla/id_policy.ipp
@@ -0,0 +1,118 @@
+// (C) Copyright Gennadiy Rozental 2005-2008.
+// 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)
+
+// See http://www.boost.org/libs/test for the library home page.
+//
+// File : $RCSfile$
+//
+// Version : $Revision: 54633 $
+//
+// Description : some generic identification policies implementation
+// ***************************************************************************
+
+#ifndef BOOST_RT_CLA_ID_POLICY_IPP_062904GER
+#define BOOST_RT_CLA_ID_POLICY_IPP_062904GER
+
+// Boost.Runtime.Parameter
+#include <ndnboost/test/utils/runtime/config.hpp>
+
+#include <ndnboost/test/utils/runtime/cla/id_policy.hpp>
+#include <ndnboost/test/utils/runtime/cla/parameter.hpp>
+
+namespace ndnboost {
+
+namespace BOOST_RT_PARAM_NAMESPACE {
+
+namespace cla {
+
+// ************************************************************************** //
+// ************** basic_naming_policy ************** //
+// ************************************************************************** //
+
+BOOST_RT_PARAM_INLINE void
+basic_naming_policy::usage_info( format_stream& fs ) const
+{
+ fs << p_prefix << p_name << p_separator;
+
+ if( p_separator->empty() )
+ fs << BOOST_RT_PARAM_LITERAL( ' ' );
+}
+
+//____________________________________________________________________________//
+
+BOOST_RT_PARAM_INLINE bool
+basic_naming_policy::match_prefix( argv_traverser& tr ) const
+{
+ if( !tr.match_front( p_prefix.get() ) )
+ return false;
+
+ tr.trim( p_prefix->size() );
+ return true;
+}
+
+//____________________________________________________________________________//
+
+BOOST_RT_PARAM_INLINE bool
+basic_naming_policy::match_name( argv_traverser& tr ) const
+{
+ if( !tr.match_front( p_name.get() ) )
+ return false;
+
+ tr.trim( p_name->size() );
+ return true;
+}
+
+//____________________________________________________________________________//
+
+BOOST_RT_PARAM_INLINE bool
+basic_naming_policy::match_separator( argv_traverser& tr, bool optional_value ) const
+{
+ if( p_separator->empty() ) {
+ if( !tr.token().is_empty() )
+ return false;
+
+ tr.trim( 1 );
+ }
+ else {
+ if( !tr.match_front( p_separator.get() ) ) {
+ // if parameter has optional value separator is optional as well
+ if( optional_value && ( tr.eoi() || tr.match_front( ' ' ) ) ) {
+ return true;
+ }
+ return false;
+ }
+
+ tr.trim( p_separator->size() );
+ }
+
+ return true;
+}
+
+//____________________________________________________________________________//
+
+BOOST_RT_PARAM_INLINE bool
+basic_naming_policy::matching( parameter const& p, argv_traverser& tr, bool ) const
+{
+ if( !match_prefix( tr ) )
+ return false;
+
+ if( !match_name( tr ) )
+ return false;
+
+ if( !match_separator( tr, p.p_optional_value ) )
+ return false;
+
+ return true;
+}
+
+//____________________________________________________________________________//
+
+} // namespace cla
+
+} // namespace BOOST_RT_PARAM_NAMESPACE
+
+} // namespace ndnboost
+
+#endif // BOOST_RT_CLA_ID_POLICY_IPP_062904GER
diff --git a/ndnboost/test/utils/runtime/cla/iface/argument_factory.hpp b/ndnboost/test/utils/runtime/cla/iface/argument_factory.hpp
new file mode 100644
index 0000000..84c1e40
--- /dev/null
+++ b/ndnboost/test/utils/runtime/cla/iface/argument_factory.hpp
@@ -0,0 +1,51 @@
+// (C) Copyright Gennadiy Rozental 2005-2008.
+// 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)
+
+// See http://www.boost.org/libs/test for the library home page.
+//
+// File : $RCSfile$
+//
+// Version : $Revision: 54633 $
+//
+// Description : defines interface for argument_factory
+// ***************************************************************************
+
+#ifndef BOOST_RT_CLA_IFACE_ARGUMENT_FACTORY_HPP_062604GER
+#define BOOST_RT_CLA_IFACE_ARGUMENT_FACTORY_HPP_062604GER
+
+// Boost.Runtime.Parameter
+#include <ndnboost/test/utils/runtime/config.hpp>
+#include <ndnboost/test/utils/runtime/fwd.hpp>
+
+#include <ndnboost/test/utils/runtime/cla/fwd.hpp>
+
+namespace ndnboost {
+
+namespace BOOST_RT_PARAM_NAMESPACE {
+
+namespace cla {
+
+// ************************************************************************** //
+// ************** argument_factory ************** //
+// ************************************************************************** //
+// another name can be argument production policy
+
+class argument_factory {
+public:
+ // Argument factory interface
+ virtual argument_ptr produce_using( parameter& p, argv_traverser& tr ) = 0; /// produce argument based on input
+ virtual argument_ptr produce_using( parameter& p, parser const& ) = 0; /// produce argument based on internal generator and/or values of other parameters
+ virtual void argument_usage_info( format_stream& fs ) = 0; /// argument value format information
+protected:
+ BOOST_TEST_PROTECTED_VIRTUAL ~argument_factory() {}
+};
+
+} // namespace ndnboost
+
+} // namespace BOOST_RT_PARAM_NAMESPACE
+
+} // namespace cla
+
+#endif // BOOST_RT_CLA_IFACE_ARGUMENT_FACTORY_HPP_062604GER
diff --git a/ndnboost/test/utils/runtime/cla/iface/id_policy.hpp b/ndnboost/test/utils/runtime/cla/iface/id_policy.hpp
new file mode 100644
index 0000000..338f8d5
--- /dev/null
+++ b/ndnboost/test/utils/runtime/cla/iface/id_policy.hpp
@@ -0,0 +1,73 @@
+// (C) Copyright Gennadiy Rozental 2005-2008.
+// 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)
+
+// See http://www.boost.org/libs/test for the library home page.
+//
+// File : $RCSfile$
+//
+// Version : $Revision: 57992 $
+//
+// Description : defines interface for identification_policy
+// ***************************************************************************
+
+#ifndef BOOST_RT_CLA_IFACE_ID_POLICY_HPP_062604GER
+#define BOOST_RT_CLA_IFACE_ID_POLICY_HPP_062604GER
+
+// Boost.Runtime.Parameter
+#include <ndnboost/test/utils/runtime/config.hpp>
+
+#include <ndnboost/test/utils/runtime/cla/fwd.hpp>
+
+// Boost.Test
+#include <ndnboost/test/utils/class_properties.hpp>
+#include <ndnboost/test/utils/rtti.hpp>
+
+namespace ndnboost {
+
+namespace BOOST_RT_PARAM_NAMESPACE {
+
+namespace cla {
+
+// ************************************************************************** //
+// ************** identification_policy ************** //
+// ************************************************************************** //
+
+#ifdef BOOST_MSVC
+# pragma warning(push)
+# pragma warning(disable:4244)
+#endif
+
+class identification_policy {
+public:
+ // Public properties
+ unit_test::readwrite_property<rtti::id_t> p_type_id;
+
+ // Policy interface
+ virtual bool responds_to( cstring name ) const = 0;
+ virtual cstring id_2_report() const = 0;
+ virtual void usage_info( format_stream& fs ) const = 0;
+ virtual bool matching( parameter const& p, argv_traverser& tr, bool primary ) const = 0;
+
+ virtual bool conflict_with( identification_policy const& ) const = 0;
+
+protected:
+ // Constructor
+ explicit identification_policy( rtti::id_t dyn_type )
+ : p_type_id( dyn_type )
+ {}
+ BOOST_TEST_PROTECTED_VIRTUAL ~identification_policy() {}
+};
+
+#ifdef BOOST_MSVC
+# pragma warning(pop)
+#endif
+
+} // namespace cla
+
+} // namespace BOOST_RT_PARAM_NAMESPACE
+
+} // namespace ndnboost
+
+#endif // BOOST_RT_CLA_IFACE_ID_POLICY_HPP_062604GER
diff --git a/ndnboost/test/utils/runtime/cla/modifier.hpp b/ndnboost/test/utils/runtime/cla/modifier.hpp
new file mode 100644
index 0000000..32719ab
--- /dev/null
+++ b/ndnboost/test/utils/runtime/cla/modifier.hpp
@@ -0,0 +1,69 @@
+// (C) Copyright Gennadiy Rozental 2005-2008.
+// 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)
+
+// See http://www.boost.org/libs/test for the library home page.
+//
+// File : $RCSfile$
+//
+// Version : $Revision: 54633 $
+//
+// Description : parameter modifiers
+// ***************************************************************************
+
+#ifndef BOOST_RT_CLA_MODIFIER_HPP_062604GER
+#define BOOST_RT_CLA_MODIFIER_HPP_062604GER
+
+// Boost.Runtime.Parameter
+#include <ndnboost/test/utils/runtime/config.hpp>
+
+// Boost.Test
+#include <ndnboost/test/utils/named_params.hpp>
+
+namespace ndnboost {
+
+namespace BOOST_RT_PARAM_NAMESPACE {
+
+namespace cla {
+
+// ************************************************************************** //
+// ************** environment variable modifiers ************** //
+// ************************************************************************** //
+
+namespace {
+
+nfp::typed_keyword<bool,struct optional_t> optional_m;
+nfp::named_parameter<bool,optional_t,bool> optional( true );
+nfp::typed_keyword<bool,struct required_t> required_m;
+nfp::named_parameter<bool,required_t,bool> required( true );
+nfp::typed_keyword<bool,struct multiplicable_t> multiplicable_m;
+nfp::named_parameter<bool,multiplicable_t,bool> multiplicable( true );
+nfp::typed_keyword<bool,struct guess_name_t> guess_name_m;
+nfp::named_parameter<bool,guess_name_t,bool> guess_name( true );
+nfp::typed_keyword<bool,struct ignore_mismatch_t> ignore_mismatch_m;
+nfp::named_parameter<bool,ignore_mismatch_t,bool> ignore_mismatch( true );
+nfp::typed_keyword<bool,struct optional_value_t> optional_value_m;
+nfp::named_parameter<bool,optional_value_t,bool> optional_value( true );
+
+nfp::typed_keyword<char_type,struct input_separator_t> input_separator;
+nfp::typed_keyword<cstring,struct prefix_t> prefix;
+nfp::typed_keyword<cstring,struct name_t> name;
+nfp::typed_keyword<cstring,struct separator_t> separator;
+nfp::typed_keyword<cstring,struct description_t> description;
+nfp::typed_keyword<cstring,struct refer_to_t> default_refer_to;
+
+nfp::keyword<struct default_value_t> default_value;
+nfp::keyword<struct handler_t> handler;
+nfp::keyword<struct interpreter_t> interpreter;
+nfp::keyword<struct assign_to_t> assign_to;
+
+} // local namespace
+
+} // namespace cla
+
+} // namespace BOOST_RT_PARAM_NAMESPACE
+
+} // namespace ndnboost
+
+#endif // BOOST_RT_CLA_MODIFIER_HPP_062604GER
diff --git a/ndnboost/test/utils/runtime/cla/named_parameter.hpp b/ndnboost/test/utils/runtime/cla/named_parameter.hpp
new file mode 100644
index 0000000..28f03b4
--- /dev/null
+++ b/ndnboost/test/utils/runtime/cla/named_parameter.hpp
@@ -0,0 +1,93 @@
+// (C) Copyright Gennadiy Rozental 2005-2008.
+// 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)
+
+// See http://www.boost.org/libs/test for the library home page.
+//
+// File : $RCSfile$
+//
+// Version : $Revision: 49312 $
+//
+// Description : defines model of named parameter
+// ***************************************************************************
+
+#ifndef BOOST_RT_CLA_NAMED_PARAMETER_HPP_062604GER
+#define BOOST_RT_CLA_NAMED_PARAMETER_HPP_062604GER
+
+// Boost.Runtime.Parameter
+#include <ndnboost/test/utils/runtime/config.hpp>
+
+#include <ndnboost/test/utils/runtime/cla/basic_parameter.hpp>
+#include <ndnboost/test/utils/runtime/cla/id_policy.hpp>
+
+namespace ndnboost {
+
+namespace BOOST_RT_PARAM_NAMESPACE {
+
+namespace cla {
+
+// ************************************************************************** //
+// ************** string_name_policy ************** //
+// ************************************************************************** //
+
+class string_name_policy : public basic_naming_policy {
+public:
+ // Constructor
+ string_name_policy();
+ BOOST_RT_PARAM_UNNEEDED_VIRTUAL ~string_name_policy() {}
+
+ // policy interface
+ virtual bool responds_to( cstring name ) const;
+ virtual bool conflict_with( identification_policy const& ) const;
+
+ // Accept modifier
+ template<typename Modifier>
+ void accept_modifier( Modifier const& m )
+ {
+ basic_naming_policy::accept_modifier( m );
+
+ if( m.has( guess_name_m ) )
+ m_guess_name = true;
+ }
+
+private:
+ // Naming policy interface
+ virtual bool match_name( argv_traverser& tr ) const;
+
+ // Data members
+ bool m_guess_name;
+};
+
+// ************************************************************************** //
+// ************** runtime::cla::named_parameter ************** //
+// ************************************************************************** //
+
+template<typename T>
+class named_parameter_t : public basic_parameter<T,string_name_policy> {
+ typedef basic_parameter<T,string_name_policy> base;
+public:
+ // Constructors
+ explicit named_parameter_t( cstring name ) : base( name ) {}
+};
+
+//____________________________________________________________________________//
+
+BOOST_RT_CLA_NAMED_PARAM_GENERATORS( named_parameter )
+
+//____________________________________________________________________________//
+
+} // namespace cla
+
+} // namespace BOOST_RT_PARAM_NAMESPACE
+
+} // namespace ndnboost
+
+#ifndef BOOST_RT_PARAM_OFFLINE
+
+# define BOOST_RT_PARAM_INLINE inline
+# include <ndnboost/test/utils/runtime/cla/named_parameter.ipp>
+
+#endif
+
+#endif // BOOST_RT_CLA_NAMED_PARAMETER_HPP_062604GER
diff --git a/ndnboost/test/utils/runtime/cla/named_parameter.ipp b/ndnboost/test/utils/runtime/cla/named_parameter.ipp
new file mode 100644
index 0000000..1d77018
--- /dev/null
+++ b/ndnboost/test/utils/runtime/cla/named_parameter.ipp
@@ -0,0 +1,129 @@
+// (C) Copyright Gennadiy Rozental 2005-2008.
+// 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)
+
+// See http://www.boost.org/libs/test for the library home page.
+//
+// File : $RCSfile$
+//
+// Version : $Revision: 54633 $
+//
+// Description : implements model of named parameter
+// ***************************************************************************
+
+#ifndef BOOST_RT_CLA_NAMED_PARAMETER_IPP_062904GER
+#define BOOST_RT_CLA_NAMED_PARAMETER_IPP_062904GER
+
+// Boost.Runtime.Parameter
+#include <ndnboost/test/utils/runtime/config.hpp>
+
+#include <ndnboost/test/utils/runtime/cla/named_parameter.hpp>
+#include <ndnboost/test/utils/runtime/cla/char_parameter.hpp>
+
+// Boost.Test
+#include <ndnboost/test/utils/algorithm.hpp>
+
+namespace ndnboost {
+
+namespace BOOST_RT_PARAM_NAMESPACE {
+
+namespace cla {
+
+// ************************************************************************** //
+// ************** string_name_policy ************** //
+// ************************************************************************** //
+
+BOOST_RT_PARAM_INLINE
+string_name_policy::string_name_policy()
+: basic_naming_policy( rtti::type_id<string_name_policy>() )
+, m_guess_name( false )
+{
+ assign_op( p_prefix.value, BOOST_RT_PARAM_CSTRING_LITERAL( "-" ), 0 );
+}
+
+//____________________________________________________________________________//
+
+BOOST_RT_PARAM_INLINE bool
+string_name_policy::responds_to( cstring name ) const
+{
+ std::pair<cstring::iterator,dstring::const_iterator> mm_pos;
+
+ mm_pos = unit_test::mismatch( name.begin(), name.end(), p_name->begin(), p_name->end() );
+
+ return mm_pos.first == name.end() && (m_guess_name || (mm_pos.second == p_name->end()) );
+}
+
+//____________________________________________________________________________//
+
+#ifdef BOOST_MSVC
+# pragma warning(push)
+# pragma warning(disable:4244)
+#endif
+
+BOOST_RT_PARAM_INLINE bool
+string_name_policy::conflict_with( identification_policy const& id ) const
+{
+ if( id.p_type_id == p_type_id ) {
+ string_name_policy const& snp = static_cast<string_name_policy const&>( id );
+
+ if( p_name->empty() || snp.p_name->empty() )
+ return false;
+
+ if( p_prefix != snp.p_prefix )
+ return false;
+
+ std::pair<dstring::const_iterator,dstring::const_iterator> mm_pos =
+ unit_test::mismatch( p_name->begin(), p_name->end(), snp.p_name->begin(), snp.p_name->end() );
+
+ return mm_pos.first != p_name->begin() && // there is common substring
+ ((m_guess_name && (mm_pos.second == snp.p_name->end()) ) || // that match other guy and I am guessing
+ (snp.m_guess_name && (mm_pos.first == p_name->end()) )); // or me and the other guy is
+ }
+
+ if( id.p_type_id == rtti::type_id<char_name_policy>() ) {
+ char_name_policy const& cnp = static_cast<char_name_policy const&>( id );
+
+ return m_guess_name &&
+ (p_prefix == cnp.p_prefix) &&
+ unit_test::first_char( cstring( p_name ) ) == unit_test::first_char( cstring( cnp.p_name ) );
+ }
+
+ return false;
+}
+
+#ifdef BOOST_MSVC
+# pragma warning(pop)
+#endif
+
+//____________________________________________________________________________//
+
+BOOST_RT_PARAM_INLINE bool
+string_name_policy::match_name( argv_traverser& tr ) const
+{
+ if( !m_guess_name )
+ return basic_naming_policy::match_name( tr );
+
+ cstring in = tr.input();
+
+ std::pair<cstring::iterator,dstring::const_iterator> mm_pos;
+
+ mm_pos = unit_test::mismatch( in.begin(), in.end(), p_name->begin(), p_name->end() );
+
+ if( mm_pos.first == in.begin() )
+ return false;
+
+ tr.trim( mm_pos.first - in.begin() );
+
+ return true;
+}
+
+//____________________________________________________________________________//
+
+} // namespace cla
+
+} // namespace BOOST_RT_PARAM_NAMESPACE
+
+} // namespace ndnboost
+
+#endif // BOOST_RT_CLA_NAMED_PARAMETER_IPP_062904GER
diff --git a/ndnboost/test/utils/runtime/cla/parameter.hpp b/ndnboost/test/utils/runtime/cla/parameter.hpp
new file mode 100644
index 0000000..36edbb6
--- /dev/null
+++ b/ndnboost/test/utils/runtime/cla/parameter.hpp
@@ -0,0 +1,150 @@
+// (C) Copyright Gennadiy Rozental 2005-2008.
+// 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)
+
+// See http://www.boost.org/libs/test for the library home page.
+//
+// File : $RCSfile$
+//
+// Version : $Revision: 81913 $
+//
+// Description : defines model of formal parameter
+// ***************************************************************************
+
+#ifndef BOOST_RT_CLA_PARAMETER_HPP_062604GER
+#define BOOST_RT_CLA_PARAMETER_HPP_062604GER
+
+// Boost.Runtime.Parameter
+#include <ndnboost/test/utils/runtime/config.hpp>
+
+#include <ndnboost/test/utils/runtime/fwd.hpp>
+#include <ndnboost/test/utils/runtime/parameter.hpp>
+#include <ndnboost/test/utils/runtime/validation.hpp>
+
+#include <ndnboost/test/utils/runtime/cla/fwd.hpp>
+#include <ndnboost/test/utils/runtime/cla/modifier.hpp>
+#include <ndnboost/test/utils/runtime/cla/iface/argument_factory.hpp>
+#include <ndnboost/test/utils/runtime/cla/iface/id_policy.hpp>
+
+// Boost.Test
+#include <ndnboost/test/utils/rtti.hpp>
+
+namespace ndnboost {
+
+namespace BOOST_RT_PARAM_NAMESPACE {
+
+namespace cla {
+
+// ************************************************************************** //
+// ************** runtime::cla::parameter ************** //
+// ************************************************************************** //
+
+class parameter : public BOOST_RT_PARAM_NAMESPACE::parameter {
+public:
+ parameter( identification_policy& ID, argument_factory& F, bool optional_value = false )
+ : p_optional( false )
+ , p_multiplicable( false )
+ , p_optional_value( optional_value )
+ , m_id_policy( ID )
+ , m_arg_factory( F )
+ {}
+
+ // Destructor
+ virtual ~parameter() {}
+
+ unit_test::readwrite_property<bool> p_optional;
+ unit_test::readwrite_property<bool> p_multiplicable;
+ unit_test::readwrite_property<bool> p_optional_value;
+ unit_test::readwrite_property<dstring> p_description;
+
+ // parameter properties modification
+ template<typename Modifier>
+ void accept_modifier( Modifier const& m )
+ {
+ if( m.has( optional_m ) )
+ p_optional.value = true;
+
+ if( m.has( required_m ) )
+ p_optional.value = false;
+
+ if( m.has( multiplicable_m ) )
+ p_multiplicable.value = true;
+
+ if( m.has( optional_value_m ) )
+ p_optional_value.value = true;
+
+ nfp::optionally_assign( p_description.value, m, description );
+ }
+
+ // access methods
+ bool has_argument() const { return m_actual_argument!=0; }
+ argument const& actual_argument() const { return *m_actual_argument; }
+ argument_ptr actual_argument() { return m_actual_argument; }
+
+
+ // identification interface
+ bool responds_to( cstring name ) const { return m_id_policy.responds_to( name ); }
+ bool conflict_with( parameter const& p ) const
+ {
+ return (id_2_report() == p.id_2_report() && !id_2_report().is_empty()) ||
+ m_id_policy.conflict_with( p.m_id_policy ) ||
+ ((m_id_policy.p_type_id != p.m_id_policy.p_type_id) && p.m_id_policy.conflict_with( m_id_policy ));
+ }
+ cstring id_2_report() const { return m_id_policy.id_2_report(); }
+ void usage_info( format_stream& fs ) const
+ {
+ m_id_policy.usage_info( fs );
+ if( p_optional_value )
+ fs << BOOST_RT_PARAM_LITERAL( '[' );
+
+ m_arg_factory.argument_usage_info( fs );
+
+ if( p_optional_value )
+ fs << BOOST_RT_PARAM_LITERAL( ']' );
+ }
+
+ // argument match/produce based on input
+ bool matching( argv_traverser& tr, bool primary ) const
+ {
+ return m_id_policy.matching( *this, tr, primary );
+ }
+
+ // argument production based on different source
+ void produce_argument( argv_traverser& tr )
+ {
+ m_id_policy.matching( *this, tr, true ); // !! can we save this position somehow
+ m_actual_argument = m_arg_factory.produce_using( *this, tr );
+ }
+ void produce_argument( parser const& p )
+ {
+ m_actual_argument = m_arg_factory.produce_using( *this, p );
+ }
+
+private:
+ //Data members
+ identification_policy& m_id_policy;
+ argument_factory& m_arg_factory;
+ argument_ptr m_actual_argument;
+};
+
+//____________________________________________________________________________//
+
+template<typename Parameter,typename Modifier>
+inline shared_ptr<Parameter>
+operator-( shared_ptr<Parameter> p, Modifier const& m )
+{
+ p->accept_modifier( m );
+
+ return p;
+}
+
+//____________________________________________________________________________//
+
+} // namespace cla
+
+} // namespace BOOST_RT_PARAM_NAMESPACE
+
+} // namespace ndnboost
+
+#endif // BOOST_RT_CLA_PARAMETER_HPP_062604GER
diff --git a/ndnboost/test/utils/runtime/cla/parser.hpp b/ndnboost/test/utils/runtime/cla/parser.hpp
new file mode 100644
index 0000000..d98625c
--- /dev/null
+++ b/ndnboost/test/utils/runtime/cla/parser.hpp
@@ -0,0 +1,153 @@
+// (C) Copyright Gennadiy Rozental 2005-2008.
+// 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)
+
+// See http://www.boost.org/libs/test for the library home page.
+//
+// File : $RCSfile$
+//
+// Version : $Revision: 57992 $
+//
+// Description : defines parser - public interface for CLA parsing and accessing
+// ***************************************************************************
+
+#ifndef BOOST_RT_CLA_PARSER_HPP_062604GER
+#define BOOST_RT_CLA_PARSER_HPP_062604GER
+
+// Boost.Runtime.Parameter
+#include <ndnboost/test/utils/runtime/config.hpp>
+#include <ndnboost/test/utils/runtime/fwd.hpp>
+#include <ndnboost/test/utils/runtime/argument.hpp>
+
+#include <ndnboost/test/utils/runtime/cla/fwd.hpp>
+#include <ndnboost/test/utils/runtime/cla/modifier.hpp>
+#include <ndnboost/test/utils/runtime/cla/argv_traverser.hpp>
+
+// Boost
+#include <ndnboost/optional.hpp>
+
+// STL
+#include <list>
+
+namespace ndnboost {
+
+namespace BOOST_RT_PARAM_NAMESPACE {
+
+namespace cla {
+
+// ************************************************************************** //
+// ************** runtime::cla::parser ************** //
+// ************************************************************************** //
+
+namespace cla_detail {
+
+template<typename Modifier>
+class global_mod_parser {
+public:
+ global_mod_parser( parser& p, Modifier const& m )
+ : m_parser( p )
+ , m_modifiers( m )
+ {}
+
+ template<typename Param>
+ global_mod_parser const&
+ operator<<( shared_ptr<Param> param ) const
+ {
+ param->accept_modifier( m_modifiers );
+
+ m_parser << param;
+
+ return *this;
+ }
+
+private:
+ // Data members;
+ parser& m_parser;
+ Modifier const& m_modifiers;
+};
+
+}
+
+// ************************************************************************** //
+// ************** runtime::cla::parser ************** //
+// ************************************************************************** //
+
+class parser {
+public:
+ typedef std::list<parameter_ptr>::const_iterator param_iterator;
+
+ // Constructor
+ explicit parser( cstring program_name = cstring() );
+
+ // parameter list construction interface
+ parser& operator<<( parameter_ptr param );
+
+ // parser and global parameters modifiers
+ template<typename Modifier>
+ cla_detail::global_mod_parser<Modifier>
+ operator-( Modifier const& m )
+ {
+ nfp::optionally_assign( m_traverser.p_separator.value, m, input_separator );
+ nfp::optionally_assign( m_traverser.p_ignore_mismatch.value, m, ignore_mismatch_m );
+
+ return cla_detail::global_mod_parser<Modifier>( *this, m );
+ }
+
+ // input processing method
+ void parse( int& argc, char_type** argv );
+
+ // parameters access
+ param_iterator first_param() const;
+ param_iterator last_param() const;
+
+ // arguments access
+ const_argument_ptr operator[]( cstring string_id ) const;
+ cstring get( cstring string_id ) const;
+
+ template<typename T>
+ T const& get( cstring string_id ) const
+ {
+ return arg_value<T>( valid_argument( string_id ) );
+ }
+
+ template<typename T>
+ void get( cstring string_id, ndnboost::optional<T>& res ) const
+ {
+ const_argument_ptr actual_arg = (*this)[string_id];
+
+ if( actual_arg )
+ res = arg_value<T>( *actual_arg );
+ else
+ res.reset();
+ }
+
+ // help/usage
+ void usage( out_stream& ostr );
+ void help( out_stream& ostr );
+
+private:
+ argument const& valid_argument( cstring string_id ) const;
+
+ // Data members
+ argv_traverser m_traverser;
+ std::list<parameter_ptr> m_parameters;
+ dstring m_program_name;
+};
+
+//____________________________________________________________________________//
+
+} // namespace cla
+
+} // namespace BOOST_RT_PARAM_NAMESPACE
+
+} // namespace ndnboost
+
+#ifndef BOOST_RT_PARAM_OFFLINE
+
+# define BOOST_RT_PARAM_INLINE inline
+# include <ndnboost/test/utils/runtime/cla/parser.ipp>
+
+#endif
+
+#endif // BOOST_RT_CLA_PARSER_HPP_062604GER
diff --git a/ndnboost/test/utils/runtime/cla/parser.ipp b/ndnboost/test/utils/runtime/cla/parser.ipp
new file mode 100644
index 0000000..5be8503
--- /dev/null
+++ b/ndnboost/test/utils/runtime/cla/parser.ipp
@@ -0,0 +1,258 @@
+// (C) Copyright Gennadiy Rozental 2005-2008.
+// 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)
+
+// See http://www.boost.org/libs/test for the library home page.
+//
+// File : $RCSfile$
+//
+// Version : $Revision: 54633 $
+//
+// Description : implements parser - public interface for CLA parsing and accessing
+// ***************************************************************************
+
+#ifndef BOOST_RT_CLA_PARSER_IPP_062904GER
+#define BOOST_RT_CLA_PARSER_IPP_062904GER
+
+// Boost.Runtime.Parameter
+#include <ndnboost/test/utils/runtime/config.hpp>
+#include <ndnboost/test/utils/runtime/trace.hpp>
+#include <ndnboost/test/utils/runtime/argument.hpp>
+
+#include <ndnboost/test/utils/runtime/cla/argv_traverser.hpp>
+#include <ndnboost/test/utils/runtime/cla/parameter.hpp>
+#include <ndnboost/test/utils/runtime/cla/modifier.hpp>
+#include <ndnboost/test/utils/runtime/cla/validation.hpp>
+#include <ndnboost/test/utils/runtime/cla/parser.hpp>
+
+// Boost.Test
+#include <ndnboost/test/utils/basic_cstring/io.hpp>
+#include <ndnboost/test/utils/foreach.hpp>
+
+// Boost
+#include <ndnboost/lexical_cast.hpp>
+
+namespace ndnboost {
+
+namespace BOOST_RT_PARAM_NAMESPACE {
+
+namespace cla {
+
+// ************************************************************************** //
+// ************** runtime::cla::parser ************** //
+// ************************************************************************** //
+
+BOOST_RT_PARAM_INLINE
+parser::parser( cstring program_name )
+{
+ assign_op( m_program_name, program_name, 0 );
+}
+
+//____________________________________________________________________________//
+
+BOOST_RT_PARAM_INLINE parser::param_iterator
+parser::first_param() const
+{
+ return m_parameters.begin();
+}
+
+//____________________________________________________________________________//
+
+BOOST_RT_PARAM_INLINE parser::param_iterator
+parser::last_param() const
+{
+ return m_parameters.end();
+}
+
+//____________________________________________________________________________//
+
+BOOST_RT_PARAM_INLINE argument const&
+parser::valid_argument( cstring string_id ) const
+{
+ const_argument_ptr arg = (*this)[string_id];
+
+ BOOST_RT_PARAM_VALIDATE_LOGIC( !!arg, "Actual argument for parameter " << string_id << " is not present" );
+
+ return *arg;
+}
+
+//____________________________________________________________________________//
+
+BOOST_RT_PARAM_INLINE parser&
+parser::operator<<( parameter_ptr new_param )
+{
+ BOOST_TEST_FOREACH( parameter_ptr, old_param, m_parameters ) {
+ BOOST_RT_PARAM_VALIDATE_LOGIC( !old_param->conflict_with( *new_param ),
+ BOOST_RT_PARAM_LITERAL( "Definition of parameter " ) << new_param->id_2_report() <<
+ BOOST_RT_PARAM_LITERAL( " conflicts with defintion of parameter " ) << old_param->id_2_report() );
+ }
+
+ m_parameters.push_back( new_param );
+
+ return *this;
+}
+
+//____________________________________________________________________________//
+
+BOOST_RT_PARAM_INLINE void
+parser::parse( int& argc, char_type** argv )
+{
+ if( m_program_name.empty() ) {
+ m_program_name.assign( argv[0] );
+ dstring::size_type pos = m_program_name.find_last_of( BOOST_RT_PARAM_LITERAL( "/\\" ) );
+
+ if( pos != static_cast<dstring::size_type>(cstring::npos) )
+ m_program_name.erase( 0, pos+1 );
+ }
+
+ m_traverser.init( argc, argv );
+
+ try {
+ while( !m_traverser.eoi() ) {
+ parameter_ptr found_param;
+
+ BOOST_RT_PARAM_TRACE( "Total " << m_parameters.size() << " parameters registered" );
+
+ BOOST_TEST_FOREACH( parameter_ptr const&, curr_param, m_parameters ) {
+ BOOST_RT_PARAM_TRACE( "Try parameter " << curr_param->id_2_report() );
+
+ if( curr_param->matching( m_traverser, !found_param ) ) {
+ BOOST_RT_PARAM_TRACE( "Match found" );
+ BOOST_RT_CLA_VALIDATE_INPUT( !found_param, (m_traverser.rollback(),m_traverser), "Ambiguous input" );
+
+ found_param = curr_param;
+ }
+
+ m_traverser.rollback();
+ }
+
+ if( !found_param ) {
+ BOOST_RT_PARAM_TRACE( "No match found" );
+ BOOST_RT_CLA_VALIDATE_INPUT( m_traverser.handle_mismatch(), m_traverser,
+ BOOST_RT_PARAM_LITERAL( "Unexpected input" ) );
+
+ continue;
+ }
+
+ BOOST_RT_PARAM_TRACE( "Parse argument value" );
+ found_param->produce_argument( m_traverser );
+
+ m_traverser.commit();
+ }
+
+ BOOST_TEST_FOREACH( parameter_ptr const&, curr_param, m_parameters ) {
+ if( !curr_param->p_optional && !curr_param->actual_argument() ) {
+ curr_param->produce_argument( *this );
+
+ BOOST_RT_PARAM_VALIDATE_LOGIC( curr_param->actual_argument(),
+ BOOST_RT_PARAM_LITERAL( "Required argument for parameter " ) << curr_param->id_2_report()
+ << BOOST_RT_PARAM_LITERAL( " is missing" ) );
+ }
+ }
+ }
+ catch( bad_lexical_cast const& ) {
+ BOOST_RT_PARAM_REPORT_LOGIC_ERROR(
+ BOOST_RT_PARAM_LITERAL( "String to value convertion error during input parsing" ) );
+ }
+
+ m_traverser.remainder( argc, argv );
+}
+
+//____________________________________________________________________________//
+
+BOOST_RT_PARAM_INLINE const_argument_ptr
+parser::operator[]( cstring string_id ) const
+{
+ parameter_ptr found_param;
+
+ BOOST_TEST_FOREACH( parameter_ptr const&, curr_param, m_parameters ) {
+ if( curr_param->responds_to( string_id ) ) {
+ BOOST_RT_PARAM_VALIDATE_LOGIC( !found_param,
+ BOOST_RT_PARAM_LITERAL( "Ambiguous parameter string id: " ) << string_id );
+
+ found_param = curr_param;
+ }
+ }
+
+ return found_param ? found_param->actual_argument() : argument_ptr();
+}
+
+//____________________________________________________________________________//
+
+BOOST_RT_PARAM_INLINE cstring
+parser::get( cstring string_id ) const
+{
+ return get<cstring>( string_id );
+}
+
+//____________________________________________________________________________//
+
+BOOST_RT_PARAM_INLINE void
+parser::usage( out_stream& ostr )
+{
+ if( m_program_name.empty() )
+ assign_op( m_program_name, BOOST_RT_PARAM_CSTRING_LITERAL( "<program>" ), 0 );
+
+ format_stream fs;
+
+ fs << m_program_name;
+
+ BOOST_TEST_FOREACH( parameter_ptr const&, curr_param, m_parameters ) {
+ fs << BOOST_RT_PARAM_LITERAL( ' ' );
+
+ if( curr_param->p_optional )
+ fs << BOOST_RT_PARAM_LITERAL( '[' );
+
+ curr_param->usage_info( fs );
+
+ if( curr_param->p_optional )
+ fs << BOOST_RT_PARAM_LITERAL( ']' );
+
+ if( curr_param->p_multiplicable ) {
+ fs << BOOST_RT_PARAM_CSTRING_LITERAL( " ... " );
+
+ if( curr_param->p_optional )
+ fs << BOOST_RT_PARAM_LITERAL( '[' );
+
+ curr_param->usage_info( fs );
+
+ if( curr_param->p_optional )
+ fs << BOOST_RT_PARAM_LITERAL( ']' );
+ }
+ }
+
+ ostr << BOOST_RT_PARAM_CSTRING_LITERAL( "Usage:\n" ) << fs.str() << std::endl;
+}
+
+//____________________________________________________________________________//
+
+BOOST_RT_PARAM_INLINE void
+parser::help( out_stream& ostr )
+{
+ usage( ostr );
+
+ bool need_where = true;
+
+ BOOST_TEST_FOREACH( parameter_ptr const&, curr_param, m_parameters ) {
+ if( curr_param->p_description->empty() )
+ continue;
+
+ if( need_where ) {
+ ostr << BOOST_RT_PARAM_CSTRING_LITERAL( "where:\n" );
+ need_where = false;
+ }
+
+ ostr << curr_param->id_2_report() << BOOST_RT_PARAM_CSTRING_LITERAL( " - " ) << curr_param->p_description << std::endl;
+ }
+}
+
+//____________________________________________________________________________//
+
+} // namespace cla
+
+} // namespace BOOST_RT_PARAM_NAMESPACE
+
+} // namespace ndnboost
+
+#endif // BOOST_RT_CLA_PARSER_IPP_062904GER
diff --git a/ndnboost/test/utils/runtime/cla/typed_parameter.hpp b/ndnboost/test/utils/runtime/cla/typed_parameter.hpp
new file mode 100644
index 0000000..b8ad9e4
--- /dev/null
+++ b/ndnboost/test/utils/runtime/cla/typed_parameter.hpp
@@ -0,0 +1,70 @@
+// (C) Copyright Gennadiy Rozental 2005-2008.
+// 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)
+
+// See http://www.boost.org/libs/test for the library home page.
+//
+// File : $RCSfile$
+//
+// Version : $Revision: 54633 $
+//
+// Description : generic typed parameter model
+// ***************************************************************************
+
+#ifndef BOOST_RT_CLA_TYPED_PARAMETER_HPP_062604GER
+#define BOOST_RT_CLA_TYPED_PARAMETER_HPP_062604GER
+
+// Boost.Runtime.Parameter
+#include <ndnboost/test/utils/runtime/config.hpp>
+
+#include <ndnboost/test/utils/runtime/fwd.hpp>
+#include <ndnboost/test/utils/runtime/validation.hpp>
+
+#include <ndnboost/test/utils/runtime/cla/parameter.hpp>
+#include <ndnboost/test/utils/runtime/cla/argument_factory.hpp>
+
+// Boost.Test
+#include <ndnboost/test/utils/rtti.hpp>
+
+namespace ndnboost {
+
+namespace BOOST_RT_PARAM_NAMESPACE {
+
+namespace cla {
+
+// ************************************************************************** //
+// ************** runtime::cla::typed_parameter ************** //
+// ************************************************************************** //
+
+template<typename T>
+class typed_parameter : public cla::parameter {
+public:
+ explicit typed_parameter( identification_policy& ID )
+ : cla::parameter( ID, m_arg_factory, rtti::type_id<T>() == rtti::type_id<bool>() )
+ {}
+
+ // parameter properties modification
+ template<typename Modifier>
+ void accept_modifier( Modifier const& m )
+ {
+ cla::parameter::accept_modifier( m );
+
+ m_arg_factory.accept_modifier( m );
+
+ BOOST_RT_PARAM_VALIDATE_LOGIC( !p_optional || !m_arg_factory.m_value_generator,
+ BOOST_RT_PARAM_LITERAL( "can't define a value generator for optional parameter " ) << id_2_report() );
+ }
+
+private:
+ // Data members
+ typed_argument_factory<T> m_arg_factory;
+};
+
+} // namespace cla
+
+} // namespace BOOST_RT_PARAM_NAMESPACE
+
+} // namespace ndnboost
+
+#endif // BOOST_RT_CLA_TYPED_PARAMETER_HPP_062604GER
diff --git a/ndnboost/test/utils/runtime/cla/validation.hpp b/ndnboost/test/utils/runtime/cla/validation.hpp
new file mode 100644
index 0000000..18c9b77
--- /dev/null
+++ b/ndnboost/test/utils/runtime/cla/validation.hpp
@@ -0,0 +1,55 @@
+// (C) Copyright Gennadiy Rozental 2005-2008.
+// 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)
+
+// See http://www.boost.org/libs/test for the library home page.
+//
+// File : $RCSfile$
+//
+// Version : $Revision: 49312 $
+//
+// Description : input validation helpers definition
+// ***************************************************************************
+
+#ifndef BOOST_RT_CLA_VALIDATION_HPP_062604GER
+#define BOOST_RT_CLA_VALIDATION_HPP_062604GER
+
+// Boost.Runtime.Parameter
+#include <ndnboost/test/utils/runtime/config.hpp>
+
+#include <ndnboost/test/utils/runtime/cla/fwd.hpp>
+
+namespace ndnboost {
+
+namespace BOOST_RT_PARAM_NAMESPACE {
+
+namespace cla {
+
+// ************************************************************************** //
+// ************** runtime::cla::report_input_error ************** //
+// ************************************************************************** //
+
+void report_input_error( argv_traverser const& tr, format_stream& msg );
+
+//____________________________________________________________________________//
+
+#define BOOST_RT_CLA_VALIDATE_INPUT( b, tr, msg ) \
+ if( b ) ; else ::ndnboost::BOOST_RT_PARAM_NAMESPACE::cla::report_input_error( tr, format_stream().ref() << msg )
+
+//____________________________________________________________________________//
+
+} // namespace cla
+
+} // namespace BOOST_RT_PARAM_NAMESPACE
+
+} // namespace ndnboost
+
+#ifndef BOOST_RT_PARAM_OFFLINE
+
+# define BOOST_RT_PARAM_INLINE inline
+# include <ndnboost/test/utils/runtime/cla/validation.ipp>
+
+#endif
+
+#endif // BOOST_RT_CLA_VALIDATION_HPP_062604GER
diff --git a/ndnboost/test/utils/runtime/cla/validation.ipp b/ndnboost/test/utils/runtime/cla/validation.ipp
new file mode 100644
index 0000000..5d295d7
--- /dev/null
+++ b/ndnboost/test/utils/runtime/cla/validation.ipp
@@ -0,0 +1,65 @@
+// (C) Copyright Gennadiy Rozental 2005-2008.
+// 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)
+
+// See http://www.boost.org/libs/test for the library home page.
+//
+// File : $RCSfile$
+//
+// Version : $Revision: 49312 $
+//
+// Description : input validation helpers implementation
+// ***************************************************************************
+
+#ifndef BOOST_RT_CLA_VALIDATION_IPP_070604GER
+#define BOOST_RT_CLA_VALIDATION_IPP_070604GER
+
+// Boost.Runtime.Parameter
+#include <ndnboost/test/utils/runtime/config.hpp>
+
+#include <ndnboost/test/utils/runtime/cla/argv_traverser.hpp>
+#include <ndnboost/test/utils/runtime/cla/validation.hpp>
+#include <ndnboost/test/utils/runtime/validation.hpp> // BOOST_RT_PARAM_NAMESPACE::logic_error
+
+// Boost
+#include <ndnboost/test/utils/basic_cstring/io.hpp>
+
+// STL
+
+namespace ndnboost {
+
+namespace BOOST_RT_PARAM_NAMESPACE {
+
+namespace cla {
+
+// ************************************************************************** //
+// ************** runtime::cla::validation ************** //
+// ************************************************************************** //
+
+BOOST_RT_PARAM_INLINE void
+report_input_error( argv_traverser const& tr, format_stream& msg )
+{
+ if( tr.eoi() )
+ msg << BOOST_RT_PARAM_LITERAL( " at the end of input" );
+ else {
+ msg << BOOST_RT_PARAM_LITERAL( " in the following position: " );
+
+ if( tr.input().size() > 5 )
+ msg << tr.input().substr( 0, 5 ) << BOOST_RT_PARAM_LITERAL( "..." );
+ else
+ msg << tr.input();
+ }
+
+ throw BOOST_RT_PARAM_NAMESPACE::logic_error( msg.str() );
+}
+
+//____________________________________________________________________________//
+
+} // namespace cla
+
+} // namespace BOOST_RT_PARAM_NAMESPACE
+
+} // namespace ndnboost
+
+#endif // BOOST_RT_CLA_VALIDATION_IPP_070604GER
diff --git a/ndnboost/test/utils/runtime/cla/value_generator.hpp b/ndnboost/test/utils/runtime/cla/value_generator.hpp
new file mode 100644
index 0000000..d402977
--- /dev/null
+++ b/ndnboost/test/utils/runtime/cla/value_generator.hpp
@@ -0,0 +1,81 @@
+// (C) Copyright Gennadiy Rozental 2005-2008.
+// 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)
+
+// See http://www.boost.org/libs/test for the library home page.
+//
+// File : $RCSfile$
+//
+// Version : $Revision: 49312 $
+//
+// Description : specific value generators
+// ***************************************************************************
+
+#ifndef BOOST_RT_CLA_VALUE_GENERATOR_HPP_062604GER
+#define BOOST_RT_CLA_VALUE_GENERATOR_HPP_062604GER
+
+// Boost.Runtime.Parameter
+#include <ndnboost/test/utils/runtime/config.hpp>
+
+#include <ndnboost/test/utils/runtime/cla/fwd.hpp>
+#include <ndnboost/test/utils/runtime/cla/parser.hpp>
+
+namespace ndnboost {
+
+namespace BOOST_RT_PARAM_NAMESPACE {
+
+namespace cla {
+
+namespace rt_cla_detail {
+
+// ************************************************************************** //
+// ************** runtime::cla::const_generator ************** //
+// ************************************************************************** //
+
+template<typename T>
+class const_generator {
+public:
+ // Constructor
+ explicit const_generator( T const& t ) : m_const_value( t ) {}
+
+ // generator interface
+ void operator()( parser const&, ndnboost::optional<T>& t ) const { t = m_const_value; }
+
+private:
+ // Data members
+ T m_const_value;
+};
+
+// ************************************************************************** //
+// ************** runtime::cla::ref_generator ************** //
+// ************************************************************************** //
+
+template<typename T>
+class ref_generator {
+public:
+ // Constructor
+ explicit ref_generator( cstring ref_id ) : m_ref_id( ref_id ) {}
+
+ // generator interface
+ void operator()( parser const& p, ndnboost::optional<T>& t ) const
+ {
+ p.get( m_ref_id, t );
+ }
+
+private:
+ // Data members
+ cstring m_ref_id;
+};
+
+//____________________________________________________________________________//
+
+} // namespace rt_cla_detail
+
+} // namespace cla
+
+} // namespace BOOST_RT_PARAM_NAMESPACE
+
+} // namespace ndnboost
+
+#endif // BOOST_RT_CLA_VALUE_GENERATOR_HPP_062604GER
diff --git a/ndnboost/test/utils/runtime/cla/value_handler.hpp b/ndnboost/test/utils/runtime/cla/value_handler.hpp
new file mode 100644
index 0000000..1d792ba
--- /dev/null
+++ b/ndnboost/test/utils/runtime/cla/value_handler.hpp
@@ -0,0 +1,57 @@
+// (C) Copyright Gennadiy Rozental 2005-2008.
+// 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)
+
+// See http://www.boost.org/libs/test for the library home page.
+//
+// File : $RCSfile$
+//
+// Version : $Revision: 49312 $
+//
+// Description : specific value handlers
+// ***************************************************************************
+
+#ifndef BOOST_RT_CLA_VALUE_HANDLER_HPP_062604GER
+#define BOOST_RT_CLA_VALUE_HANDLER_HPP_062604GER
+
+// Boost.Runtime.Parameter
+#include <ndnboost/test/utils/runtime/config.hpp>
+
+#include <ndnboost/test/utils/runtime/cla/fwd.hpp>
+
+namespace ndnboost {
+
+namespace BOOST_RT_PARAM_NAMESPACE {
+
+namespace cla {
+
+namespace rt_cla_detail {
+
+// ************************************************************************** //
+// ************** runtime::cla::assigner ************** //
+// ************************************************************************** //
+
+template<typename T>
+class assigner {
+public:
+ // Constructor
+ explicit assigner( T& loc ) : m_target( loc ) {}
+
+ // value handler implementation
+ void operator()( parameter const&, T& t ) { m_target = t; }
+
+private:
+ // Data members
+ T& m_target;
+};
+
+} // namespace rt_cla_detail
+
+} // namespace cla
+
+} // namespace BOOST_RT_PARAM_NAMESPACE
+
+} // namespace ndnboost
+
+#endif // BOOST_RT_CLA_VALUE_HANDLER_HPP_062604GER
diff --git a/ndnboost/test/utils/runtime/config.hpp b/ndnboost/test/utils/runtime/config.hpp
new file mode 100644
index 0000000..8067a96
--- /dev/null
+++ b/ndnboost/test/utils/runtime/config.hpp
@@ -0,0 +1,156 @@
+// (C) Copyright Gennadiy Rozental 2005-2008.
+// Distributed under 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)
+
+// See http://www.boost.org/libs/test for the library home page.
+//
+// File : $RCSfile$
+//
+// Version : $Revision: 57992 $
+//
+// Description : Runtime.Param library configuration
+// ***************************************************************************
+
+#ifndef BOOST_RT_CONFIG_HPP_062604GER
+#define BOOST_RT_CONFIG_HPP_062604GER
+
+// Boost
+#include <ndnboost/config.hpp>
+#ifdef BOOST_MSVC
+# pragma warning(disable: 4511) // copy constructor could not be generated
+# pragma warning(disable: 4512) // assignment operator could not be generated
+# pragma warning(disable: 4181) // qualifier applied to reference type; ignored
+# pragma warning(disable: 4675) // resolved overload was found by argument-dependent lookup
+#endif
+
+// Boost.Test
+#include <ndnboost/test/detail/config.hpp>
+#include <ndnboost/test/utils/basic_cstring/basic_cstring.hpp>
+#include <ndnboost/test/utils/wrap_stringstream.hpp>
+#include <ndnboost/test/utils/basic_cstring/io.hpp> // operator<<(ndnboost::runtime::cstring)
+
+// STL
+#include <string>
+#include <cstdlib>
+
+//____________________________________________________________________________//
+
+#ifndef BOOST_RT_PARAM_CUSTOM_STRING
+# ifndef BOOST_RT_PARAM_WIDE_STRING
+# define BOOST_RT_PARAM_NAMESPACE runtime
+# else
+# define BOOST_RT_PARAM_NAMESPACE wide_runtime
+# endif
+#endif
+
+#ifdef __SUNPRO_CC
+extern int putenv(char*);
+#endif
+
+namespace ndnboost {
+
+namespace BOOST_RT_PARAM_NAMESPACE {
+
+#ifndef BOOST_RT_PARAM_CUSTOM_STRING
+# ifndef BOOST_RT_PARAM_WIDE_STRING
+
+typedef char char_type;
+typedef std::string dstring;
+typedef unit_test::const_string cstring;
+typedef unit_test::literal_string literal_cstring;
+typedef wrap_stringstream format_stream;
+
+#ifdef BOOST_CLASSIC_IOSTREAMS
+typedef std::ostream out_stream;
+#else
+typedef std::basic_ostream<char_type> out_stream;
+#endif
+
+#ifdef BOOST_MSVC
+#pragma warning(push)
+#pragma warning(disable:4996) // putenv
+#endif
+
+#ifndef UNDER_CE
+#if defined(__COMO__) && 0
+inline void
+putenv_impl( cstring name, cstring value )
+{
+ using namespace std;
+ // !! this may actually fail. What should we do?
+ setenv( name.begin(), value.begin(), 1 );
+}
+#else
+inline void
+putenv_impl( cstring name, cstring value )
+{
+ format_stream fs;
+
+ fs << name << '=' << value;
+
+ // !! this may actually fail. What should we do?
+ // const_cast is used to satisfy putenv interface
+ using namespace std;
+ putenv( const_cast<char*>( fs.str().c_str() ) );
+}
+#endif
+#endif
+
+#ifdef BOOST_MSVC
+#pragma warning(pop)
+#endif
+
+#define BOOST_RT_PARAM_LITERAL( l ) l
+#define BOOST_RT_PARAM_CSTRING_LITERAL( l ) cstring( l, sizeof( l ) - 1 )
+#define BOOST_RT_PARAM_GETENV getenv
+#define BOOST_RT_PARAM_PUTENV ::ndnboost::BOOST_RT_PARAM_NAMESPACE::putenv_impl
+#define BOOST_RT_PARAM_EXCEPTION_INHERIT_STD
+
+//____________________________________________________________________________//
+
+# else
+
+typedef wchar_t char_type;
+typedef std::basic_string<char_type> dstring;
+typedef unit_test::basic_cstring<wchar_t const> cstring;
+typedef const unit_test::basic_cstring<wchar_t const> literal_cstring;
+typedef wrap_wstringstream format_stream;
+typedef std::wostream out_stream;
+
+#ifndef UNDER_CE
+inline void
+putenv_impl( cstring name, cstring value )
+{
+ format_stream fs;
+
+ fs << name << '=' << value;
+
+ // !! this may actually fail. What should we do?
+ // const_cast is used to satisfy putenv interface
+ using namespace std;
+ wputenv( const_cast<wchar_t*>( fs.str().c_str() ) );
+}
+#endif
+
+#define BOOST_RT_PARAM_LITERAL( l ) L ## l
+#define BOOST_RT_PARAM_CSTRING_LITERAL( l ) cstring( L ## l, sizeof( L ## l )/sizeof(wchar_t) - 1 )
+#define BOOST_RT_PARAM_GETENV wgetenv
+#define BOOST_RT_PARAM_PUTENV putenv_impl
+
+# endif
+#endif
+
+#ifdef __GNUC__
+#define BOOST_RT_PARAM_UNNEEDED_VIRTUAL virtual
+#else
+#define BOOST_RT_PARAM_UNNEEDED_VIRTUAL
+#endif
+
+//____________________________________________________________________________//
+
+} // namespace BOOST_RT_PARAM_NAMESPACE
+
+} // namespace ndnboost
+
+#endif // BOOST_RT_CONFIG_HPP_062604GER
diff --git a/ndnboost/test/utils/runtime/env/environment.hpp b/ndnboost/test/utils/runtime/env/environment.hpp
new file mode 100644
index 0000000..b45f10f
--- /dev/null
+++ b/ndnboost/test/utils/runtime/env/environment.hpp
@@ -0,0 +1,172 @@
+// (C) Copyright Gennadiy Rozental 2005-2008.
+// Distributed under 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)
+
+// See http://www.boost.org/libs/test for the library home page.
+//
+// File : $RCSfile$
+//
+// Version : $Revision: 54633 $
+//
+// Description : defines and implements inline model of program environment
+// ***************************************************************************
+
+#ifndef BOOST_RT_ENV_ENVIRONMENT_HPP_062604GER
+#define BOOST_RT_ENV_ENVIRONMENT_HPP_062604GER
+
+#ifdef UNDER_CE
+#error Windows CE does not support environment variables.
+#endif
+
+// Boost.Runtime.Parameter
+#include <ndnboost/test/utils/runtime/config.hpp>
+#include <ndnboost/test/utils/runtime/fwd.hpp>
+#include <ndnboost/test/utils/runtime/argument.hpp>
+#include <ndnboost/test/utils/runtime/interpret_argument_value.hpp>
+
+#include <ndnboost/test/utils/runtime/env/fwd.hpp>
+#include <ndnboost/test/utils/runtime/env/modifier.hpp>
+#include <ndnboost/test/utils/runtime/env/variable.hpp>
+
+// Boost.Test
+#include <ndnboost/test/utils/callback.hpp>
+
+// Boost
+#include <ndnboost/optional.hpp>
+
+namespace ndnboost {
+
+namespace BOOST_RT_PARAM_NAMESPACE {
+
+// ************************************************************************** //
+// ************** runtime::environment implementation ************** //
+// ************************************************************************** //
+
+namespace environment {
+
+namespace rt_env_detail {
+
+template<typename T, typename Modifiers>
+variable_data&
+init_new_var( cstring var_name, Modifiers m = nfp::no_params )
+{
+ rt_env_detail::variable_data& new_vd = new_var_record( var_name );
+
+ cstring str_value = sys_read_var( new_vd.m_var_name );
+
+ if( !str_value.is_empty() ) {
+ try {
+ ndnboost::optional<T> value;
+
+ if( m.has( interpreter ) )
+ m[interpreter]( str_value, value );
+ else
+ interpret_argument_value( str_value, value, 0 );
+
+ if( !!value ) {
+ new_vd.m_value.reset( new typed_argument<T>( new_vd ) );
+
+ arg_value<T>( *new_vd.m_value ) = *value;
+ }
+ }
+ catch( ... ) { // !! could we do that
+ // !! should we report an error?
+ }
+ }
+
+ if( !new_vd.m_value && m.has( default_value ) ) {
+ new_vd.m_value.reset( new typed_argument<T>( new_vd ) );
+
+ nfp::optionally_assign( arg_value<T>( *new_vd.m_value ), m[default_value] );
+ }
+
+ nfp::optionally_assign( new_vd.m_global_id, m, global_id );
+
+ return new_vd;
+}
+
+//____________________________________________________________________________//
+
+} // namespace rt_env_detail
+
+} // namespace environment
+
+// ************************************************************************** //
+// ************** runtime::environment ************** //
+// ************************************************************************** //
+
+namespace environment {
+
+ // variable access
+ variable_base
+ var( cstring var_name );
+
+ //________________________________________________________________________//
+
+ template<typename T>
+ inline variable<T>
+ var( cstring var_name )
+ {
+ rt_env_detail::variable_data* vd = rt_env_detail::find_var_record( var_name );
+
+ return environment::variable<T>( !vd ? rt_env_detail::init_new_var<T>( var_name, nfp::no_params ) : *vd );
+ }
+
+ //________________________________________________________________________//
+
+ template<typename T, typename Modifiers>
+ inline variable<T>
+ var( cstring var_name, Modifiers const& m )
+ {
+ rt_env_detail::variable_data* vd = rt_env_detail::find_var_record( var_name );
+
+ return environment::variable<T>( !vd ? rt_env_detail::init_new_var<T>( var_name, m ) : *vd );
+ }
+
+ //________________________________________________________________________//
+
+ // direct variable value access
+ inline cstring
+ get( cstring var_name )
+ {
+ return environment::var<cstring>( var_name ).value();
+ }
+
+ //________________________________________________________________________//
+
+ template<typename T>
+ inline T const&
+ get( cstring var_name )
+ {
+ return environment::var<T>( var_name ).value();
+ }
+
+ //________________________________________________________________________//
+
+ template<typename T>
+ inline void
+ get( cstring var_name, ndnboost::optional<T>& res )
+ {
+ variable<T> const& v = environment::var<T>( var_name );
+ v.value( res );
+ }
+
+ //________________________________________________________________________//
+
+} // namespace environment
+
+namespace env = environment;
+
+} // namespace BOOST_RT_PARAM_NAMESPACE
+
+} // namespace ndnboost
+
+#ifndef BOOST_RT_PARAM_OFFLINE
+
+#define BOOST_RT_PARAM_INLINE inline
+#include <ndnboost/test/utils/runtime/env/environment.ipp>
+
+#endif
+
+#endif // BOOST_RT_ENV_ENVIRONMENT_HPP_062604GER
diff --git a/ndnboost/test/utils/runtime/env/environment.ipp b/ndnboost/test/utils/runtime/env/environment.ipp
new file mode 100644
index 0000000..f2929de
--- /dev/null
+++ b/ndnboost/test/utils/runtime/env/environment.ipp
@@ -0,0 +1,125 @@
+// (C) Copyright Gennadiy Rozental 2005-2008.
+// Distributed under 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)
+
+// See http://www.boost.org/libs/test for the library home page.
+//
+// File : $RCSfile$
+//
+// Version : $Revision: 57992 $
+//
+// Description : implements model of program environment
+// ***************************************************************************
+
+#ifndef BOOST_RT_ENV_ENVIRONMENT_IPP_062904GER
+#define BOOST_RT_ENV_ENVIRONMENT_IPP_062904GER
+
+// Boost.Runtime.Parameter
+#include <ndnboost/test/utils/runtime/config.hpp>
+#include <ndnboost/test/utils/runtime/validation.hpp>
+
+#include <ndnboost/test/utils/runtime/env/variable.hpp>
+
+// Boost.Test
+#include <ndnboost/test/utils/basic_cstring/compare.hpp>
+#include <ndnboost/test/utils/basic_cstring/io.hpp>
+
+// STL
+#include <map>
+#include <list>
+
+namespace ndnboost {
+
+namespace BOOST_RT_PARAM_NAMESPACE {
+
+namespace environment {
+
+// ************************************************************************** //
+// ************** runtime::environment ************** //
+// ************************************************************************** //
+
+namespace rt_env_detail {
+
+typedef std::map<cstring,rt_env_detail::variable_data> registry;
+typedef std::list<dstring> keys;
+
+BOOST_RT_PARAM_INLINE registry& s_registry() { static registry instance; return instance; }
+BOOST_RT_PARAM_INLINE keys& s_keys() { static keys instance; return instance; }
+
+BOOST_RT_PARAM_INLINE variable_data&
+new_var_record( cstring var_name )
+{
+ // save the name in list of keys
+ s_keys().push_back( dstring() );
+ dstring& key = s_keys().back();
+ assign_op( key, var_name, 0 );
+
+ // create and return new record
+ variable_data& new_var_data = s_registry()[key];
+
+ new_var_data.m_var_name = key;
+
+ return new_var_data;
+}
+
+//____________________________________________________________________________//
+
+BOOST_RT_PARAM_INLINE variable_data*
+find_var_record( cstring var_name )
+{
+ registry::iterator it = s_registry().find( var_name );
+
+ return it == s_registry().end() ? 0 : &(it->second);
+}
+
+//____________________________________________________________________________//
+
+#ifdef BOOST_MSVC
+#pragma warning(push)
+#pragma warning(disable:4996) // getenv
+#endif
+
+BOOST_RT_PARAM_INLINE cstring
+sys_read_var( cstring var_name )
+{
+ using namespace std;
+ return BOOST_RT_PARAM_GETENV( var_name.begin() );
+}
+
+#ifdef BOOST_MSVC
+#pragma warning(pop)
+#endif
+//____________________________________________________________________________//
+
+BOOST_RT_PARAM_INLINE void
+sys_write_var( cstring var_name, format_stream& var_value )
+{
+ BOOST_RT_PARAM_PUTENV( var_name, cstring( var_value.str() ) );
+}
+
+//____________________________________________________________________________//
+
+} // namespace rt_env_detail
+
+BOOST_RT_PARAM_INLINE variable_base
+var( cstring var_name )
+{
+ rt_env_detail::variable_data* vd = rt_env_detail::find_var_record( var_name );
+
+ BOOST_RT_PARAM_VALIDATE_LOGIC( !!vd,
+ BOOST_RT_PARAM_LITERAL( "First access to the environment variable " )
+ << var_name << BOOST_RT_PARAM_LITERAL( " should be typed" ) );
+
+ return variable_base( *vd );
+}
+
+//____________________________________________________________________________//
+
+} // namespace environment
+
+} // namespace BOOST_RT_PARAM_NAMESPACE
+
+} // namespace ndnboost
+
+#endif // BOOST_RT_ENV_ENVIRONMENT_IPP_062904GER
diff --git a/ndnboost/test/utils/runtime/env/fwd.hpp b/ndnboost/test/utils/runtime/env/fwd.hpp
new file mode 100644
index 0000000..b869605
--- /dev/null
+++ b/ndnboost/test/utils/runtime/env/fwd.hpp
@@ -0,0 +1,54 @@
+// (C) Copyright Gennadiy Rozental 2005-2008.
+// Distributed under 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)
+
+// See http://www.boost.org/libs/test for the library home page.
+//
+// File : $RCSfile$
+//
+// Version : $Revision: 54633 $
+//
+// Description : environment subsystem forward declarations
+// ***************************************************************************
+
+#ifndef BOOST_RT_ENV_FWD_HPP_062604GER
+#define BOOST_RT_ENV_FWD_HPP_062604GER
+
+#ifdef UNDER_CE
+#error Windows CE does not support environment variables.
+#endif
+
+// Boost.Runtime.Parameter
+#include <ndnboost/test/utils/runtime/config.hpp>
+
+namespace ndnboost {
+
+namespace BOOST_RT_PARAM_NAMESPACE {
+
+namespace environment {
+
+class variable_base;
+variable_base var( cstring var_name );
+
+namespace rt_env_detail {
+
+struct variable_data;
+
+variable_data& new_var_record( cstring var_name );
+variable_data* find_var_record( cstring var_name );
+
+cstring sys_read_var( cstring var_name );
+void sys_write_var( cstring var_name, format_stream& var_value );
+
+}
+
+template <typename T> class variable;
+
+} // namespace environment
+
+} // namespace BOOST_RT_PARAM_NAMESPACE
+
+} // namespace ndnboost
+
+#endif // BOOST_RT_ENV_FWD_HPP_062604GER
diff --git a/ndnboost/test/utils/runtime/env/modifier.hpp b/ndnboost/test/utils/runtime/env/modifier.hpp
new file mode 100644
index 0000000..a760368
--- /dev/null
+++ b/ndnboost/test/utils/runtime/env/modifier.hpp
@@ -0,0 +1,47 @@
+// (C) Copyright Gennadiy Rozental 2005-2008.
+// 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)
+
+// See http://www.boost.org/libs/test for the library home page.
+//
+// File : $RCSfile$
+//
+// Version : $Revision: 49312 $
+//
+// Description : defines variable modifiers
+// ***************************************************************************
+
+#ifndef BOOST_RT_ENV_MODIFIER_HPP_062604GER
+#define BOOST_RT_ENV_MODIFIER_HPP_062604GER
+
+// Boost.Runtime.Parameter
+#include <ndnboost/test/utils/runtime/config.hpp>
+
+// Boost.Test
+#include <ndnboost/test/utils/named_params.hpp>
+
+namespace ndnboost {
+
+namespace BOOST_RT_PARAM_NAMESPACE {
+
+namespace environment {
+
+// ************************************************************************** //
+// ************** environment variable modifiers ************** //
+// ************************************************************************** //
+
+namespace {
+
+nfp::typed_keyword<cstring,struct global_id_t> global_id;
+nfp::keyword<struct default_value_t> default_value;
+nfp::keyword<struct interpreter_t> interpreter;
+
+} // local namespace
+} // namespace environment
+
+} // namespace BOOST_RT_PARAM_NAMESPACE
+
+} // namespace ndnboost
+
+#endif // BOOST_RT_ENV_MODIFIER_HPP_062604GER
diff --git a/ndnboost/test/utils/runtime/env/variable.hpp b/ndnboost/test/utils/runtime/env/variable.hpp
new file mode 100644
index 0000000..17a4f39
--- /dev/null
+++ b/ndnboost/test/utils/runtime/env/variable.hpp
@@ -0,0 +1,223 @@
+// (C) Copyright Gennadiy Rozental 2005-2008.
+// Distributed under 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)
+
+// See http://www.boost.org/libs/test for the library home page.
+//
+// File : $RCSfile$
+//
+// Version : $Revision: 81913 $
+//
+// Description : defines model of program environment variable
+// ***************************************************************************
+
+#ifndef BOOST_RT_ENV_VARIABLE_HPP_062604GER
+#define BOOST_RT_ENV_VARIABLE_HPP_062604GER
+
+#ifdef UNDER_CE
+#error Windows CE does not support environment variables.
+#endif
+
+// Boost.Runtime.Parameter
+#include <ndnboost/test/utils/runtime/config.hpp>
+#include <ndnboost/test/utils/runtime/fwd.hpp>
+#include <ndnboost/test/utils/runtime/parameter.hpp>
+#include <ndnboost/test/utils/runtime/argument.hpp>
+
+#include <ndnboost/test/utils/runtime/env/fwd.hpp>
+
+// Boost
+#include <ndnboost/optional.hpp>
+
+namespace ndnboost {
+
+namespace BOOST_RT_PARAM_NAMESPACE {
+
+namespace environment {
+
+// ************************************************************************** //
+// ************** runtime::environment::variable_data ************** //
+// ************************************************************************** //
+
+namespace rt_env_detail {
+
+struct variable_data : public runtime::parameter {
+ cstring m_var_name;
+ dstring m_global_id;
+ argument_ptr m_value;
+};
+
+} // namespace rt_env_detail
+
+// ************************************************************************** //
+// ************** runtime::environment::variable_base ************** //
+// ************************************************************************** //
+
+class variable_base {
+public:
+ explicit variable_base( rt_env_detail::variable_data& data ) : m_data( &data ) {}
+
+ // arguments access
+ template<typename T>
+ T const& value() const
+ {
+ return arg_value<T>( *m_data->m_value );
+ }
+
+ template<typename T>
+ void value( ndnboost::optional<T>& res ) const
+ {
+ if( has_value() )
+ res = arg_value<T>( *m_data->m_value );
+ else
+ res.reset();
+ }
+
+ bool has_value() const { return m_data->m_value!=0; }
+ cstring name() const { return m_data->m_var_name; }
+
+protected:
+ // Data members
+ rt_env_detail::variable_data* m_data;
+} ;
+
+// ************************************************************************** //
+// ************** runtime::environment::variable ************** //
+// ************************************************************************** //
+
+template<typename T = cstring>
+class variable : public variable_base {
+public:
+ // Constructors
+ explicit variable( cstring var_name );
+
+ template<typename Modifiers>
+ explicit variable( cstring var_name, Modifiers const& m );
+
+ explicit variable( rt_env_detail::variable_data& data )
+ : variable_base( data ) {}
+
+ // other variable assignment
+ void operator=( variable const& v ) { m_data = v.m_data; }
+
+ // access methods
+ T const& value() const { return variable_base::value<T>(); }
+
+#if BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3206)) || \
+ BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x0593))
+ template<typename T>
+ void value( ndnboost::optional<T>& res ) const { variable_base::value( res ); }
+#else
+ using variable_base::value;
+#endif
+
+ // Value assignment
+ template<typename V>
+ void operator=( V const& v )
+ {
+ if( !has_value() )
+ m_data->m_value.reset( new typed_argument<T>( *m_data ) );
+
+ arg_value<T>( *m_data->m_value ) = v;
+
+ rt_env_detail::sys_write_var( m_data->m_var_name, format_stream().ref() << value() );
+ }
+}; // class variable
+
+//____________________________________________________________________________//
+
+template<typename CharT, typename Tr,typename T>
+inline std::basic_ostream<CharT,Tr>&
+operator<<( std::basic_ostream<CharT,Tr>& os, variable<T> const& v )
+{
+ os << v.name() << '=';
+
+ if( v.has_value() )
+ os << v.value();
+
+ return os;
+}
+
+//____________________________________________________________________________//
+
+template<typename T, typename V>
+inline bool
+operator==( variable<T> ev, V const& v )
+{
+ return ev.has_value() && ev.value() == v;
+}
+
+//____________________________________________________________________________//
+
+template<typename T, typename V>
+inline bool
+operator==( V const& v, variable<T> ev )
+{
+ return ev.has_value() && ev.value() == v;
+}
+
+//____________________________________________________________________________//
+
+template<typename T, typename V>
+inline bool
+operator!=( variable<T> ev, V const& v )
+{
+ return !ev.has_value() || ev.value() != v;
+}
+
+//____________________________________________________________________________//
+
+template<typename T, typename V>
+inline bool
+operator!=( V const& v, variable<T> ev )
+{
+ return !ev.has_value() || ev.value() != v;
+}
+
+//____________________________________________________________________________//
+
+} // namespace environment
+
+} // namespace BOOST_RT_PARAM_NAMESPACE
+
+} // namespace ndnboost
+
+// ************************************************************************** //
+// ************************************************************************** //
+// Implementation
+
+#include <ndnboost/test/utils/runtime/env/environment.hpp>
+
+// ************************************************************************** //
+// ************** runtime::environment::variable ************** //
+// ************************************************************************** //
+
+namespace ndnboost {
+
+namespace BOOST_RT_PARAM_NAMESPACE {
+
+namespace environment {
+
+template<typename T>
+variable<T>::variable( cstring var_name )
+: variable_base( environment::var<T>( var_name ) )
+{}
+
+//____________________________________________________________________________//
+
+template<typename T>
+template<typename Modifiers>
+variable<T>::variable( cstring var_name, Modifiers const& m )
+: variable_base( environment::var<T>( var_name, m ) )
+{}
+
+//____________________________________________________________________________//
+
+} // namespace environment
+
+} // namespace BOOST_RT_PARAM_NAMESPACE
+
+} // namespace ndnboost
+
+#endif // BOOST_RT_ENV_VARIABLE_HPP_062604GER
diff --git a/ndnboost/test/utils/runtime/fwd.hpp b/ndnboost/test/utils/runtime/fwd.hpp
new file mode 100644
index 0000000..3714bfc
--- /dev/null
+++ b/ndnboost/test/utils/runtime/fwd.hpp
@@ -0,0 +1,41 @@
+// (C) Copyright Gennadiy Rozental 2005-2008.
+// Distributed under 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)
+
+// See http://www.boost.org/libs/test for the library home page.
+//
+// File : $RCSfile$
+//
+// Version : $Revision: 49312 $
+//
+// Description : global framework level forward declaration
+// ***************************************************************************
+
+#ifndef BOOST_RT_FWD_HPP_062604GER
+#define BOOST_RT_FWD_HPP_062604GER
+
+// Boost.Runtime.Parameter
+#include <ndnboost/test/utils/runtime/config.hpp>
+
+// Boost
+#include <ndnboost/shared_ptr.hpp>
+
+namespace ndnboost {
+
+namespace BOOST_RT_PARAM_NAMESPACE {
+
+class parameter;
+
+class argument;
+typedef shared_ptr<argument> argument_ptr;
+typedef shared_ptr<argument const> const_argument_ptr;
+
+template<typename T> class value_interpreter;
+template<typename T> class typed_argument;
+
+} // namespace BOOST_RT_PARAM_NAMESPACE
+
+} // namespace ndnboost
+
+#endif // BOOST_RT_FWD_HPP_062604GER
diff --git a/ndnboost/test/utils/runtime/interpret_argument_value.hpp b/ndnboost/test/utils/runtime/interpret_argument_value.hpp
new file mode 100644
index 0000000..4f5a214
--- /dev/null
+++ b/ndnboost/test/utils/runtime/interpret_argument_value.hpp
@@ -0,0 +1,163 @@
+// (C) Copyright Gennadiy Rozental 2005-2008.
+// Distributed under 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)
+
+// See http://www.boost.org/libs/test for the library home page.
+//
+// File : $RCSfile$
+//
+// Version : $Revision: 49312 $
+//
+// Description : default algorithms for string to specific type convertions
+// ***************************************************************************
+
+#ifndef BOOST_RT_INTERPRET_ARGUMENT_VALUE_HPP_062604GER
+#define BOOST_RT_INTERPRET_ARGUMENT_VALUE_HPP_062604GER
+
+// Boost.Runtime.Parameter
+#include <ndnboost/test/utils/runtime/config.hpp>
+#include <ndnboost/test/utils/runtime/trace.hpp>
+
+// Boost.Test
+#include <ndnboost/test/utils/basic_cstring/io.hpp>
+#include <ndnboost/test/utils/basic_cstring/compare.hpp>
+
+// Boost
+#include <ndnboost/optional.hpp>
+#include <ndnboost/lexical_cast.hpp>
+
+// STL
+// !! could we eliminate these includes?
+#include <list>
+
+namespace ndnboost {
+
+namespace BOOST_RT_PARAM_NAMESPACE {
+
+// ************************************************************************** //
+// ************** runtime::interpret_argument_value ************** //
+// ************************************************************************** //
+// returns true if source is used false otherwise
+
+// generic case
+template<typename T>
+struct interpret_argument_value_impl {
+ static bool _( cstring source, ndnboost::optional<T>& res )
+ {
+ BOOST_RT_PARAM_TRACE( "In interpret_argument_value_impl<" << typeid(T).name() << ">" );
+
+ res = lexical_cast<T>( source );
+
+ BOOST_RT_PARAM_TRACE( "String " << source << " is interpreted as " << *res );
+ return true;
+ }
+};
+
+
+//____________________________________________________________________________//
+
+// dstring case
+template<>
+struct interpret_argument_value_impl<dstring> {
+ static bool _( cstring source, ndnboost::optional<dstring>& res )
+ {
+ BOOST_RT_PARAM_TRACE( "In interpret_argument_value_impl<dstring>" );
+
+ res = dstring();
+ assign_op( *res, source, 0 );
+
+ return true;
+ }
+};
+
+//____________________________________________________________________________//
+
+// cstring case
+template<>
+struct interpret_argument_value_impl<cstring> {
+ static bool _( cstring source, ndnboost::optional<cstring>& res )
+ {
+ BOOST_RT_PARAM_TRACE( "In interpret_argument_value_impl<cstring>" );
+
+ res = source;
+
+ return true;
+ }
+};
+
+//____________________________________________________________________________//
+
+// specialization for type bool
+template<>
+struct interpret_argument_value_impl<bool> {
+ static bool _( cstring source, ndnboost::optional<bool>& res )
+ {
+ BOOST_RT_PARAM_TRACE( "In interpret_argument_value_impl<bool>" );
+
+ static literal_cstring YES( BOOST_RT_PARAM_CSTRING_LITERAL( "YES" ) );
+ static literal_cstring Y( BOOST_RT_PARAM_CSTRING_LITERAL( "Y" ) );
+ static literal_cstring NO( BOOST_RT_PARAM_CSTRING_LITERAL( "NO" ) );
+ static literal_cstring N( BOOST_RT_PARAM_CSTRING_LITERAL( "N" ) );
+ static literal_cstring one( BOOST_RT_PARAM_CSTRING_LITERAL( "1" ) );
+ static literal_cstring zero( BOOST_RT_PARAM_CSTRING_LITERAL( "0" ) );
+
+ source.trim();
+
+ if( case_ins_eq( source, YES ) || case_ins_eq( source, Y ) || case_ins_eq( source, one ) ) {
+ res = true;
+ return true;
+ }
+ else if( case_ins_eq( source, NO ) || case_ins_eq( source, N ) || case_ins_eq( source, zero ) ) {
+ res = false;
+ return true;
+ }
+ else {
+ res = true;
+ return false;
+ }
+ }
+};
+
+//____________________________________________________________________________//
+
+template<typename T>
+inline bool
+interpret_argument_value( cstring source, ndnboost::optional<T>& res, long )
+{
+ return interpret_argument_value_impl<T>::_( source, res );
+}
+
+//____________________________________________________________________________//
+
+// specialization for list of values
+template<typename T>
+inline bool
+interpret_argument_value( cstring source, ndnboost::optional<std::list<T> >& res, int )
+{
+ BOOST_RT_PARAM_TRACE( "In interpret_argument_value<std::list<T>>" );
+
+ res = std::list<T>();
+
+ while( !source.is_empty() ) {
+ // !! should we use token_iterator
+ cstring::iterator single_value_end = std::find( source.begin(), source.end(), BOOST_RT_PARAM_LITERAL( ',' ) );
+
+ ndnboost::optional<T> value;
+ interpret_argument_value( cstring( source.begin(), single_value_end ), value, 0 );
+
+ res->push_back( *value );
+
+ source.trim_left( single_value_end + 1 );
+ }
+
+ return true;
+}
+
+//____________________________________________________________________________//
+
+} // namespace BOOST_RT_PARAM_NAMESPACE
+
+} // namespace ndnboost
+
+#endif // BOOST_RT_INTERPRET_ARGUMENT_VALUE_HPP_062604GER
diff --git a/ndnboost/test/utils/runtime/parameter.hpp b/ndnboost/test/utils/runtime/parameter.hpp
new file mode 100644
index 0000000..2f6d1b7
--- /dev/null
+++ b/ndnboost/test/utils/runtime/parameter.hpp
@@ -0,0 +1,38 @@
+// (C) Copyright Gennadiy Rozental 2005-2008.
+// Distributed under 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)
+
+// See http://www.boost.org/libs/test for the library home page.
+//
+// File : $RCSfile$
+//
+// Version : $Revision: 49312 $
+//
+// Description : abstract interface for the formal parameter
+// ***************************************************************************
+
+#ifndef BOOST_RT_PARAMETER_HPP_062604GER
+#define BOOST_RT_PARAMETER_HPP_062604GER
+
+// Boost.Runtime.Parameter
+#include <ndnboost/test/utils/runtime/config.hpp>
+
+namespace ndnboost {
+
+namespace BOOST_RT_PARAM_NAMESPACE {
+
+// ************************************************************************** //
+// ************** runtime::parameter ************** //
+// ************************************************************************** //
+
+class parameter {
+public:
+ virtual ~parameter() {}
+};
+
+} // namespace BOOST_RT_PARAM_NAMESPACE
+
+} // namespace ndnboost
+
+#endif // BOOST_RT_PARAMETER_HPP_062604GER
diff --git a/ndnboost/test/utils/runtime/trace.hpp b/ndnboost/test/utils/runtime/trace.hpp
new file mode 100644
index 0000000..c71eb8e
--- /dev/null
+++ b/ndnboost/test/utils/runtime/trace.hpp
@@ -0,0 +1,30 @@
+// (C) Copyright Gennadiy Rozental 2005-2008.
+// Distributed under 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)
+
+// See http://www.boost.org/libs/test for the library home page.
+//
+// File : $RCSfile$
+//
+// Version : $Revision: 49312 $
+//
+// Description : optional internal tracing
+// ***************************************************************************
+
+#ifndef BOOST_RT_TRACE_HPP_062604GER
+#define BOOST_RT_TRACE_HPP_062604GER
+
+// Boost.Runtime.Parameter
+#include <ndnboost/test/utils/runtime/config.hpp>
+
+#ifdef BOOST_RT_PARAM_DEBUG
+
+#include <iostream>
+
+# define BOOST_RT_PARAM_TRACE( str ) std::cerr << str << std::endl
+#else
+# define BOOST_RT_PARAM_TRACE( str )
+#endif
+
+#endif // BOOST_RT_TRACE_HPP_062604GER
diff --git a/ndnboost/test/utils/runtime/validation.hpp b/ndnboost/test/utils/runtime/validation.hpp
new file mode 100644
index 0000000..e794df9
--- /dev/null
+++ b/ndnboost/test/utils/runtime/validation.hpp
@@ -0,0 +1,82 @@
+// (C) Copyright Gennadiy Rozental 2005-2008.
+// Distributed under 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)
+
+// See http://www.boost.org/libs/test for the library home page.
+//
+// File : $RCSfile$
+//
+// Version : $Revision: 49312 $
+//
+// Description : defines exceptions and validation tools
+// ***************************************************************************
+
+#ifndef BOOST_RT_VALIDATION_HPP_062604GER
+#define BOOST_RT_VALIDATION_HPP_062604GER
+
+// Boost.Runtime.Parameter
+#include <ndnboost/test/utils/runtime/config.hpp>
+
+// Boost.Test
+#include <ndnboost/test/utils/class_properties.hpp>
+
+// Boost
+#include <ndnboost/shared_ptr.hpp>
+
+// STL
+#ifdef BOOST_RT_PARAM_EXCEPTION_INHERIT_STD
+#include <stdexcept>
+#endif
+
+namespace ndnboost {
+
+namespace BOOST_RT_PARAM_NAMESPACE {
+
+// ************************************************************************** //
+// ************** runtime::logic_error ************** //
+// ************************************************************************** //
+
+class logic_error
+#ifdef BOOST_RT_PARAM_EXCEPTION_INHERIT_STD
+: public std::exception
+#endif
+{
+ typedef shared_ptr<dstring> dstring_ptr;
+public:
+ // Constructor // !! could we eliminate shared_ptr
+ explicit logic_error( cstring msg ) : m_msg( new dstring( msg.begin(), msg.size() ) ) {}
+ ~logic_error() throw() {}
+
+ dstring const& msg() const { return *m_msg; }
+ virtual char_type const* what() const throw() { return m_msg->c_str(); }
+
+private:
+ dstring_ptr m_msg;
+};
+
+// ************************************************************************** //
+// ************** runtime::report_logic_error ************** //
+// ************************************************************************** //
+
+inline void
+report_logic_error( format_stream& msg )
+{
+ throw BOOST_RT_PARAM_NAMESPACE::logic_error( msg.str() );
+}
+
+//____________________________________________________________________________//
+
+#define BOOST_RT_PARAM_REPORT_LOGIC_ERROR( msg ) \
+ ndnboost::BOOST_RT_PARAM_NAMESPACE::report_logic_error( format_stream().ref() << msg )
+
+#define BOOST_RT_PARAM_VALIDATE_LOGIC( b, msg ) \
+ if( b ) {} else BOOST_RT_PARAM_REPORT_LOGIC_ERROR( msg )
+
+//____________________________________________________________________________//
+
+} // namespace BOOST_RT_PARAM_NAMESPACE
+
+} // namespace ndnboost
+
+#endif // BOOST_RT_VALIDATION_HPP_062604GER
diff --git a/ndnboost/test/utils/trivial_singleton.hpp b/ndnboost/test/utils/trivial_singleton.hpp
new file mode 100644
index 0000000..6fba5c9
--- /dev/null
+++ b/ndnboost/test/utils/trivial_singleton.hpp
@@ -0,0 +1,74 @@
+// (C) Copyright Gennadiy Rozental 2005-2008.
+// Distributed under 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)
+
+// See http://www.boost.org/libs/test for the library home page.
+//
+// File : $RCSfile$
+//
+// Version : $Revision: 49312 $
+//
+// Description : simple helpers for creating cusom output manipulators
+// ***************************************************************************
+
+#ifndef BOOST_TEST_TRIVIAL_SIGNLETON_HPP_020505GER
+#define BOOST_TEST_TRIVIAL_SIGNLETON_HPP_020505GER
+
+#include <ndnboost/config.hpp>
+#include <ndnboost/detail/workaround.hpp>
+
+#include <ndnboost/noncopyable.hpp>
+
+#include <ndnboost/test/detail/suppress_warnings.hpp>
+
+//____________________________________________________________________________//
+
+namespace ndnboost {
+
+namespace unit_test {
+
+// ************************************************************************** //
+// ************** singleton ************** //
+// ************************************************************************** //
+
+template<typename Derived>
+class singleton : private ndnboost::noncopyable {
+public:
+ static Derived& instance() { static Derived the_inst; return the_inst; }
+protected:
+ singleton() {}
+ ~singleton() {}
+};
+
+} // namespace unit_test
+
+#define BOOST_TEST_SINGLETON_CONS( type ) \
+friend class ndnboost::unit_test::singleton<type>; \
+type() {} \
+/**/
+
+#if BOOST_WORKAROUND(__DECCXX_VER, BOOST_TESTED_AT(60590042))
+
+#define BOOST_TEST_SINGLETON_INST( inst ) \
+template class unit_test::singleton< BOOST_JOIN( inst, _t ) > ; \
+namespace { BOOST_JOIN( inst, _t)& inst = BOOST_JOIN( inst, _t)::instance(); }
+
+#elif defined(__APPLE_CC__) && defined(__GNUC__) && __GNUC__ < 4
+#define BOOST_TEST_SINGLETON_INST( inst ) \
+static BOOST_JOIN( inst, _t)& inst = BOOST_JOIN (inst, _t)::instance();
+
+#else
+
+#define BOOST_TEST_SINGLETON_INST( inst ) \
+namespace { BOOST_JOIN( inst, _t)& inst = BOOST_JOIN( inst, _t)::instance(); }
+
+#endif
+
+} // namespace ndnboost
+
+//____________________________________________________________________________//
+
+#include <ndnboost/test/detail/enable_warnings.hpp>
+
+#endif // BOOST_TEST_TRIVIAL_SIGNLETON_HPP_020505GER
diff --git a/ndnboost/test/utils/wrap_stringstream.hpp b/ndnboost/test/utils/wrap_stringstream.hpp
new file mode 100644
index 0000000..bd112e9
--- /dev/null
+++ b/ndnboost/test/utils/wrap_stringstream.hpp
@@ -0,0 +1,164 @@
+// (C) Copyright Gennadiy Rozental 2002-2008.
+// Distributed under 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)
+
+// See http://www.boost.org/libs/test for the library home page.
+//
+// File : $RCSfile$
+//
+// Version : $Revision: 49312 $
+//
+// Description : wraps strstream and stringstream (depends with one is present)
+// to provide the unified interface
+// ***************************************************************************
+
+#ifndef BOOST_WRAP_STRINGSTREAM_HPP_071894GER
+#define BOOST_WRAP_STRINGSTREAM_HPP_071894GER
+
+// Boost.Test
+#include <ndnboost/test/detail/config.hpp>
+
+// STL
+#ifdef BOOST_NO_STRINGSTREAM
+#include <strstream> // for std::ostrstream
+#else
+#include <sstream> // for std::ostringstream
+#endif // BOOST_NO_STRINGSTREAM
+
+#include <ndnboost/test/detail/suppress_warnings.hpp>
+
+//____________________________________________________________________________//
+
+namespace ndnboost {
+
+// ************************************************************************** //
+// ************** basic_wrap_stringstream ************** //
+// ************************************************************************** //
+
+template<typename CharT>
+class basic_wrap_stringstream {
+public:
+#if defined(BOOST_CLASSIC_IOSTREAMS)
+ typedef std::ostringstream wrapped_stream;
+#elif defined(BOOST_NO_STRINGSTREAM)
+ typedef std::basic_ostrstream<CharT> wrapped_stream;
+#else
+ typedef std::basic_ostringstream<CharT> wrapped_stream;
+#endif // BOOST_NO_STRINGSTREAM
+ // Access methods
+ basic_wrap_stringstream& ref();
+ wrapped_stream& stream();
+ std::basic_string<CharT> const& str();
+
+private:
+ // Data members
+ wrapped_stream m_stream;
+ std::basic_string<CharT> m_str;
+};
+
+//____________________________________________________________________________//
+
+template <typename CharT, typename T>
+inline basic_wrap_stringstream<CharT>&
+operator<<( basic_wrap_stringstream<CharT>& targ, T const& t )
+{
+ targ.stream() << t;
+ return targ;
+}
+
+//____________________________________________________________________________//
+
+template <typename CharT>
+inline typename basic_wrap_stringstream<CharT>::wrapped_stream&
+basic_wrap_stringstream<CharT>::stream()
+{
+ return m_stream;
+}
+
+//____________________________________________________________________________//
+
+template <typename CharT>
+inline basic_wrap_stringstream<CharT>&
+basic_wrap_stringstream<CharT>::ref()
+{
+ return *this;
+}
+
+//____________________________________________________________________________//
+
+template <typename CharT>
+inline std::basic_string<CharT> const&
+basic_wrap_stringstream<CharT>::str()
+{
+
+#ifdef BOOST_NO_STRINGSTREAM
+ m_str.assign( m_stream.str(), m_stream.pcount() );
+ m_stream.freeze( false );
+#else
+ m_str = m_stream.str();
+#endif
+
+ return m_str;
+}
+
+//____________________________________________________________________________//
+
+template <typename CharT>
+inline basic_wrap_stringstream<CharT>&
+operator<<( basic_wrap_stringstream<CharT>& targ, basic_wrap_stringstream<CharT>& src )
+{
+ targ << src.str();
+ return targ;
+}
+
+//____________________________________________________________________________//
+
+#if BOOST_TEST_USE_STD_LOCALE
+
+template <typename CharT>
+inline basic_wrap_stringstream<CharT>&
+operator<<( basic_wrap_stringstream<CharT>& targ, std::ios_base& (BOOST_TEST_CALL_DECL *man)(std::ios_base&) )
+{
+ targ.stream() << man;
+ return targ;
+}
+
+//____________________________________________________________________________//
+
+template<typename CharT,typename Elem,typename Tr>
+inline basic_wrap_stringstream<CharT>&
+operator<<( basic_wrap_stringstream<CharT>& targ, std::basic_ostream<Elem,Tr>& (BOOST_TEST_CALL_DECL *man)(std::basic_ostream<Elem, Tr>&) )
+{
+ targ.stream() << man;
+ return targ;
+}
+
+//____________________________________________________________________________//
+
+template<typename CharT,typename Elem,typename Tr>
+inline basic_wrap_stringstream<CharT>&
+operator<<( basic_wrap_stringstream<CharT>& targ, std::basic_ios<Elem, Tr>& (BOOST_TEST_CALL_DECL *man)(std::basic_ios<Elem, Tr>&) )
+{
+ targ.stream() << man;
+ return targ;
+}
+
+//____________________________________________________________________________//
+
+#endif
+
+// ************************************************************************** //
+// ************** wrap_stringstream ************** //
+// ************************************************************************** //
+
+typedef basic_wrap_stringstream<char> wrap_stringstream;
+typedef basic_wrap_stringstream<wchar_t> wrap_wstringstream;
+
+} // namespace ndnboost
+
+//____________________________________________________________________________//
+
+#include <ndnboost/test/detail/enable_warnings.hpp>
+
+#endif // BOOST_WRAP_STRINGSTREAM_HPP_071894GER
diff --git a/ndnboost/test/utils/xml_printer.hpp b/ndnboost/test/utils/xml_printer.hpp
new file mode 100644
index 0000000..58ecc6b
--- /dev/null
+++ b/ndnboost/test/utils/xml_printer.hpp
@@ -0,0 +1,118 @@
+// (C) Copyright Gennadiy Rozental 2004-2008.
+// Distributed under 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)
+
+// See http://www.boost.org/libs/test for the library home page.
+//
+// File : $RCSfile$
+//
+// Version : $Revision: 57992 $
+//
+// Description : common code used by any agent serving as XML printer
+// ***************************************************************************
+
+#ifndef BOOST_TEST_XML_PRINTER_HPP_071894GER
+#define BOOST_TEST_XML_PRINTER_HPP_071894GER
+
+// Boost.Test
+#include <ndnboost/test/utils/basic_cstring/basic_cstring.hpp>
+#include <ndnboost/test/utils/fixed_mapping.hpp>
+#include <ndnboost/test/utils/custom_manip.hpp>
+#include <ndnboost/test/utils/foreach.hpp>
+#include <ndnboost/test/utils/basic_cstring/io.hpp>
+
+// Boost
+#include <ndnboost/config.hpp>
+
+// STL
+#include <iostream>
+
+#include <ndnboost/test/detail/suppress_warnings.hpp>
+
+//____________________________________________________________________________//
+
+namespace ndnboost {
+
+namespace unit_test {
+
+// ************************************************************************** //
+// ************** xml print helpers ************** //
+// ************************************************************************** //
+
+inline void
+print_escaped( std::ostream& where_to, const_string value )
+{
+ static fixed_mapping<char,char const*> char_type(
+ '<' , "lt",
+ '>' , "gt",
+ '&' , "amp",
+ '\'', "apos" ,
+ '"' , "quot",
+
+ 0
+ );
+
+ BOOST_TEST_FOREACH( char, c, value ) {
+ char const* ref = char_type[c];
+
+ if( ref )
+ where_to << '&' << ref << ';';
+ else
+ where_to << c;
+ }
+}
+
+//____________________________________________________________________________//
+
+inline void
+print_escaped( std::ostream& where_to, std::string const& value )
+{
+ print_escaped( where_to, const_string( value ) );
+}
+
+//____________________________________________________________________________//
+
+template<typename T>
+inline void
+print_escaped( std::ostream& where_to, T const& value )
+{
+ where_to << value;
+}
+
+//____________________________________________________________________________//
+
+typedef custom_manip<struct attr_value_t> attr_value;
+
+template<typename T>
+inline std::ostream&
+operator<<( custom_printer<attr_value> const& p, T const& value )
+{
+ *p << "=\"";
+ print_escaped( *p, value );
+ *p << '"';
+
+ return *p;
+}
+
+//____________________________________________________________________________//
+
+typedef custom_manip<struct cdata_t> cdata;
+
+inline std::ostream&
+operator<<( custom_printer<cdata> const& p, const_string value )
+{
+ return *p << BOOST_TEST_L( "<![CDATA[" ) << value << BOOST_TEST_L( "]]>" );
+}
+
+//____________________________________________________________________________//
+
+} // namespace unit_test
+
+} // namespace ndnboost
+
+//____________________________________________________________________________//
+
+#include <ndnboost/test/detail/enable_warnings.hpp>
+
+#endif // BOOST_TEST_XML_PRINTER_HPP_071894GER