From c357f29a5b633e78f9d824737e5504485f55bb15 Mon Sep 17 00:00:00 2001 From: Arkadiy Vertleyb Date: Tue, 20 Sep 2005 01:32:56 +0000 Subject: [PATCH] added more tests [SVN r31048] --- test/Jamfile | 18 ++++++++++ test/noncopyable.cpp | 32 ++++++++++++++++++ test/odr.hpp | 11 +++++++ test/odr1.cpp | 6 ++++ test/odr2.cpp | 1 + test/std.cpp | 65 +++++++++++++++++++++++++++++++++++++ test/template_dependent.cpp | 11 +++++++ test/template_enum.cpp | 11 +++++++ test/template_multiword.cpp | 10 ++++++ 9 files changed, 165 insertions(+) create mode 100755 test/noncopyable.cpp create mode 100755 test/odr.hpp create mode 100755 test/odr1.cpp create mode 100755 test/odr2.cpp create mode 100755 test/std.cpp create mode 100755 test/template_dependent.cpp create mode 100755 test/template_enum.cpp create mode 100755 test/template_multiword.cpp diff --git a/test/Jamfile b/test/Jamfile index f119c29..39409c2 100755 --- a/test/Jamfile +++ b/test/Jamfile @@ -19,6 +19,15 @@ test-suite "typeof" [ compile template_tpl.cpp : BOOST_TYPEOF_NATIVE : template_tpl_native ] [ compile template_tpl.cpp : BOOST_TYPEOF_COMPLIANT : template_tpl_emulation ] + [ compile template_enum.cpp : BOOST_TYPEOF_NATIVE : template_enum_native ] + [ compile template_enum.cpp : BOOST_TYPEOF_COMPLIANT : template_enum_emulation ] + + [ compile template_dependent.cpp : BOOST_TYPEOF_NATIVE : template_dependent_native ] + [ compile template_dependent.cpp : BOOST_TYPEOF_COMPLIANT : template_dependent_emulation ] + + [ compile template_multiword.cpp : BOOST_TYPEOF_NATIVE : template_multiword_native ] + [ compile template_multiword.cpp : BOOST_TYPEOF_COMPLIANT : template_multiword_emulation ] + [ compile modifiers.cpp : BOOST_TYPEOF_NATIVE : modifiers_native ] [ compile modifiers.cpp : BOOST_TYPEOF_COMPLIANT : modifiers_emulation ] @@ -39,4 +48,13 @@ test-suite "typeof" [ compile lvalue.cpp : BOOST_TYPEOF_NATIVE : lvalue_native ] [ compile lvalue.cpp : BOOST_TYPEOF_COMPLIANT : lvalue_emulation ] + + [ compile noncopyable.cpp : BOOST_TYPEOF_NATIVE : noncopyable_native ] + [ compile noncopyable.cpp : BOOST_TYPEOF_COMPLIANT : noncopyable_emulation ] + + [ compile std.cpp : BOOST_TYPEOF_NATIVE : std_native ] + [ compile std.cpp : BOOST_TYPEOF_COMPLIANT : std_emulation ] + + [ link odr1.cpp odr2.cpp : BOOST_TYPEOF_NATIVE : odr_native ] + [ link odr1.cpp odr2.cpp : BOOST_TYPEOF_COMPLIANT : odr_emulation ] ; diff --git a/test/noncopyable.cpp b/test/noncopyable.cpp new file mode 100755 index 0000000..687c782 --- /dev/null +++ b/test/noncopyable.cpp @@ -0,0 +1,32 @@ +#include "test.hpp" +#include +#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP() + +struct x : boost::noncopyable +{ + void foo() {} + void bar() const {} +}; + +BOOST_TYPEOF_REGISTER_TYPE(x) + +x& make_ref() +{ + static x result; + return result; +} + +const x& make_const_ref() +{ + static x result; + return result; +} + +void foo() +{ + BOOST_AUTO(& v1, make_ref()); + v1.foo(); + + BOOST_AUTO(const& v2, make_const_ref()); + v2.bar(); +} diff --git a/test/odr.hpp b/test/odr.hpp new file mode 100755 index 0000000..892a229 --- /dev/null +++ b/test/odr.hpp @@ -0,0 +1,11 @@ +#include + +struct foo +{ + typedef BOOST_TYPEOF(1 + 2.5) type; +}; + +namespace +{ + typedef foo::type type; +} \ No newline at end of file diff --git a/test/odr1.cpp b/test/odr1.cpp new file mode 100755 index 0000000..e21b8b2 --- /dev/null +++ b/test/odr1.cpp @@ -0,0 +1,6 @@ +#include "odr.hpp" + +int main() +{ + return 0; +} diff --git a/test/odr2.cpp b/test/odr2.cpp new file mode 100755 index 0000000..aebd7c3 --- /dev/null +++ b/test/odr2.cpp @@ -0,0 +1 @@ +#include "odr.hpp" diff --git a/test/std.cpp b/test/std.cpp new file mode 100755 index 0000000..1cce1d2 --- /dev/null +++ b/test/std.cpp @@ -0,0 +1,65 @@ +#include "test.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace std; + +// STL containers + +BOOST_STATIC_ASSERT(boost::type_of::test::value); +BOOST_STATIC_ASSERT(boost::type_of::test >::value); +BOOST_STATIC_ASSERT(boost::type_of::test >::value); +BOOST_STATIC_ASSERT(boost::type_of::test >::value); +BOOST_STATIC_ASSERT(boost::type_of::test >::value); +BOOST_STATIC_ASSERT(boost::type_of::test >::value); +BOOST_STATIC_ASSERT((boost::type_of::test >::value)); +BOOST_STATIC_ASSERT((boost::type_of::test >::value)); +BOOST_STATIC_ASSERT(boost::type_of::test >::value); +BOOST_STATIC_ASSERT(boost::type_of::test >::value); +BOOST_STATIC_ASSERT(boost::type_of::test >::value); + +// function objects + +BOOST_STATIC_ASSERT((boost::type_of::test >::value)); +BOOST_STATIC_ASSERT((boost::type_of::test >::value)); +BOOST_STATIC_ASSERT(boost::type_of::test >::value); +BOOST_STATIC_ASSERT(boost::type_of::test >::value); +BOOST_STATIC_ASSERT(boost::type_of::test >::value); +BOOST_STATIC_ASSERT(boost::type_of::test >::value); +BOOST_STATIC_ASSERT(boost::type_of::test >::value); +BOOST_STATIC_ASSERT(boost::type_of::test >::value); +BOOST_STATIC_ASSERT(boost::type_of::test >::value); +BOOST_STATIC_ASSERT(boost::type_of::test >::value); +BOOST_STATIC_ASSERT(boost::type_of::test >::value); +BOOST_STATIC_ASSERT(boost::type_of::test >::value); +BOOST_STATIC_ASSERT(boost::type_of::test >::value); +BOOST_STATIC_ASSERT(boost::type_of::test >::value); +BOOST_STATIC_ASSERT(boost::type_of::test >::value); +BOOST_STATIC_ASSERT(boost::type_of::test >::value); +BOOST_STATIC_ASSERT(boost::type_of::test >::value); +BOOST_STATIC_ASSERT(boost::type_of::test > >::value); +BOOST_STATIC_ASSERT(boost::type_of::test > >::value); +BOOST_STATIC_ASSERT(boost::type_of::test > >::value); +BOOST_STATIC_ASSERT(boost::type_of::test > >::value); + +// valarray + +BOOST_STATIC_ASSERT(boost::type_of::test >::value); diff --git a/test/template_dependent.cpp b/test/template_dependent.cpp new file mode 100755 index 0000000..05223e5 --- /dev/null +++ b/test/template_dependent.cpp @@ -0,0 +1,11 @@ +#include "test.hpp" +#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP() + +template struct t{}; + +BOOST_TYPEOF_REGISTER_TEMPLATE(t, + (class) + (BOOST_TYPEOF_INTEGRAL(P0)) + ) + +BOOST_STATIC_ASSERT((boost::type_of::test()>::value)); diff --git a/test/template_enum.cpp b/test/template_enum.cpp new file mode 100755 index 0000000..a896d15 --- /dev/null +++ b/test/template_enum.cpp @@ -0,0 +1,11 @@ +#include "test.hpp" +#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP() + +enum E{ONE, TWO, THREE}; +template struct t{}; + +BOOST_TYPEOF_REGISTER_TEMPLATE(t, + (BOOST_TYPEOF_INTEGRAL(E)) + ) + +BOOST_STATIC_ASSERT(boost::type_of::test()>::value); diff --git a/test/template_multiword.cpp b/test/template_multiword.cpp new file mode 100755 index 0000000..7e9aadb --- /dev/null +++ b/test/template_multiword.cpp @@ -0,0 +1,10 @@ +#include "test.hpp" +#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP() + +template struct t{}; + +BOOST_TYPEOF_REGISTER_TEMPLATE(t, + (BOOST_TYPEOF_INTEGRAL(unsigned long int)) + ) + +BOOST_STATIC_ASSERT((boost::type_of::test()>::value));