Boost logo

Boost-Commit :

From: chochlik_at_[hidden]
Date: 2008-08-13 10:49:51


Author: matus.chochlik
Date: 2008-08-13 10:49:51 EDT (Wed, 13 Aug 2008)
New Revision: 48122
URL: http://svn.boost.org/trac/boost/changeset/48122

Log:
- minor updates to the tests
Added:
   sandbox/mirror/libs/mirror/test/types.hpp (contents, props changed)
   sandbox/mirror/libs/mirror/test/types_ct_02.cpp (contents, props changed)
Text files modified:
   sandbox/mirror/libs/mirror/test/Jamfile.v2 | 1 +
   sandbox/mirror/libs/mirror/test/types_ct_01.cpp | 16 ++++++++++++++++
   2 files changed, 17 insertions(+), 0 deletions(-)

Modified: sandbox/mirror/libs/mirror/test/Jamfile.v2
==============================================================================
--- sandbox/mirror/libs/mirror/test/Jamfile.v2 (original)
+++ sandbox/mirror/libs/mirror/test/Jamfile.v2 2008-08-13 10:49:51 EDT (Wed, 13 Aug 2008)
@@ -21,5 +21,6 @@
          [ compile namespaces_ct_04.cpp ]
          [ compile-fail namespaces_cf_01.cpp ]
          [ compile types_ct_01.cpp ]
+ [ compile types_ct_02.cpp ]
     ;
 

Added: sandbox/mirror/libs/mirror/test/types.hpp
==============================================================================
--- (empty file)
+++ sandbox/mirror/libs/mirror/test/types.hpp 2008-08-13 10:49:51 EDT (Wed, 13 Aug 2008)
@@ -0,0 +1,52 @@
+/**
+ * \file test/types.hpp
+ *
+ * This file is part of the Mirror library testsuite.
+ *
+ * Testing type registration and reflection.
+ *
+ * Copyright 2008 Matus Chochlik. 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)
+ */
+#ifndef BOOST_MIRROR_LIBS_MIRROR_TEST_TYPES_HPP
+#define BOOST_MIRROR_LIBS_MIRROR_TEST_TYPES_HPP
+
+// test namespaces
+#include "./namespaces.hpp"
+
+namespace test {
+namespace feature {
+namespace detail {
+
+struct foo_impl;
+
+} // namespace detail
+
+struct foo;
+
+} // namespace feature
+
+struct bar;
+
+} // namespace test
+
+// type on the global scope
+struct baz;
+
+namespace boost {
+namespace mirror {
+
+//
+// register the nested types
+BOOST_MIRROR_REG_TYPE(::test::feature::detail, foo_impl)
+BOOST_MIRROR_REG_TYPE(::test::feature, foo)
+BOOST_MIRROR_REG_TYPE(::test, bar)
+// register the type defined on the global scope
+BOOST_MIRROR_REG_TYPE_GS(baz)
+
+} // namespace mirror
+} // namespace boost
+
+#endif // include guard
+

Modified: sandbox/mirror/libs/mirror/test/types_ct_01.cpp
==============================================================================
--- sandbox/mirror/libs/mirror/test/types_ct_01.cpp (original)
+++ sandbox/mirror/libs/mirror/test/types_ct_01.cpp 2008-08-13 10:49:51 EDT (Wed, 13 Aug 2008)
@@ -21,6 +21,7 @@
 #include <boost/mirror/meta_type.hpp>
 //
 #include "./namespaces.hpp"
+#include "./types.hpp"
 #include "./test.hpp"
 
 void test_main()
@@ -31,6 +32,9 @@
         //
         typedef BOOST_MIRRORED_TYPE(int) meta_int;
         typedef BOOST_MIRRORED_TYPE(::std::string) meta_std_string;
+ typedef BOOST_MIRRORED_TYPE(::boost::cts::bstring) meta_boost_cts_bstring;
+ typedef BOOST_MIRRORED_TYPE(::test::feature::foo) meta_test_feature_foo;
+ typedef BOOST_MIRRORED_TYPE(baz) meta_baz;
         //
         BOOST_MPL_ASSERT_NOT(( is_same<meta_int, meta_std_string> ));
         BOOST_MPL_ASSERT(( reflects_global_scope<meta_int::scope> ));
@@ -40,6 +44,18 @@
         //
         BOOST_MPL_ASSERT(( is_same<meta_int::reflected_type, int> ));
         BOOST_MPL_ASSERT(( is_same<meta_std_string::reflected_type, ::std::string> ));
+ BOOST_MPL_ASSERT(( is_same<
+ meta_boost_cts_bstring::reflected_type,
+ ::boost::cts::bstring
+ > ));
+ BOOST_MPL_ASSERT(( is_same<
+ meta_test_feature_foo::reflected_type,
+ ::test::feature::foo
+ > ));
+ BOOST_MPL_ASSERT(( is_same<
+ meta_baz::reflected_type,
+ baz
+ > ));
 }
 
 test_suite* init_unit_test_suite( int argc, char* argv[] )

Added: sandbox/mirror/libs/mirror/test/types_ct_02.cpp
==============================================================================
--- (empty file)
+++ sandbox/mirror/libs/mirror/test/types_ct_02.cpp 2008-08-13 10:49:51 EDT (Wed, 13 Aug 2008)
@@ -0,0 +1,70 @@
+/**
+ * \file test/types_ct_02.cpp
+ *
+ * This file is part of the Mirror library testsuite.
+ *
+ * Testing type registration and reflection.
+ *
+ * Copyright 2008 Matus Chochlik. 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)
+ */
+
+// MPL_ASSERT
+#include <boost/mpl/assert.hpp>
+#include <boost/type_traits/is_same.hpp>
+//
+#include <boost/mirror/meta_namespace.hpp>
+// pre-registered types
+#include <boost/mirror/meta_type.hpp>
+//
+#include "./namespaces.hpp"
+#include "./types.hpp"
+#include "./test.hpp"
+
+void test_main()
+{
+ using ::boost::is_same;
+ // usage without 'using ::boost::mirror'
+ BOOST_MPL_ASSERT(( is_same<
+ BOOST_MIRRORED_TYPE(int)::scope,
+ BOOST_MIRRORED_GLOBAL_SCOPE()
+ > ));
+ BOOST_MPL_ASSERT(( is_same<
+ BOOST_MIRRORED_TYPE(::std::string)::scope,
+ BOOST_MIRRORED_NAMESPACE(::std)
+ > ));
+ BOOST_MPL_ASSERT(( is_same<
+ BOOST_MIRRORED_TYPE(::boost::cts::bstring)::scope,
+ BOOST_MIRRORED_NAMESPACE(::std)
+ > ));
+ BOOST_MPL_ASSERT(( is_same<
+ BOOST_MIRRORED_TYPE_NS(::boost::cts, bstring)::scope,
+ BOOST_MIRRORED_NAMESPACE(::std)
+ > ));
+ BOOST_MPL_ASSERT(( is_same<
+ BOOST_MIRRORED_TYPEDEF(::boost::cts, bstring)::scope,
+ BOOST_MIRRORED_NAMESPACE(::boost::cts)
+ > ));
+ BOOST_MPL_ASSERT(( is_same<
+ BOOST_MIRRORED_TYPEDEF(::boost::cts, bstring)::scope::scope,
+ BOOST_MIRRORED_NAMESPACE(::boost)
+ > ));
+ BOOST_MPL_ASSERT(( is_same<
+ BOOST_MIRRORED_TYPE(::test::feature::detail::foo_impl)::scope,
+ BOOST_MIRRORED_NAMESPACE(::test::feature::detail)
+ > ));
+ BOOST_MPL_ASSERT(( is_same<
+ BOOST_MIRRORED_TYPE(::test::feature::foo)::scope::scope,
+ BOOST_MIRRORED_NAMESPACE(::test)
+ > ));
+}
+
+test_suite* init_unit_test_suite( int argc, char* argv[] )
+{
+ test_suite *test = BOOST_TEST_SUITE("Mirror: types compile test 02");
+ test->add(BOOST_TEST_CASE(&test_main));
+ return test;
+}
+
+


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk