added more tests

[SVN r30908]
This commit is contained in:
Arkadiy Vertleyb
2005-09-11 14:59:52 +00:00
parent 2bc33ea912
commit 9bb8a83f24
9 changed files with 91 additions and 5 deletions

View File

@ -18,4 +18,25 @@ test-suite "typeof"
[ compile template_tpl.cpp : <define>BOOST_TYPEOF_NATIVE : template_tpl_native ]
[ compile template_tpl.cpp : <define>BOOST_TYPEOF_COMPLIANT : template_tpl_emulation ]
[ compile modifiers.cpp : <define>BOOST_TYPEOF_NATIVE : modifiers_native ]
[ compile modifiers.cpp : <define>BOOST_TYPEOF_COMPLIANT : modifiers_emulation ]
[ compile function.cpp : <define>BOOST_TYPEOF_NATIVE : function_native ]
[ compile function.cpp : <define>BOOST_TYPEOF_COMPLIANT : function_emulation ]
[ compile function_ptr.cpp : <define>BOOST_TYPEOF_NATIVE : function_ptr_native ]
[ compile function_ptr.cpp : <define>BOOST_TYPEOF_COMPLIANT : function_ptr_emulation ]
[ compile function_ref.cpp : <define>BOOST_TYPEOF_NATIVE : function_ref_native ]
[ compile function_ref.cpp : <define>BOOST_TYPEOF_COMPLIANT : function_ref_emulation ]
[ compile member_function.cpp : <define>BOOST_TYPEOF_NATIVE : member_function_native ]
[ compile member_function.cpp : <define>BOOST_TYPEOF_COMPLIANT : member_function_emulation ]
[ compile data_member.cpp : <define>BOOST_TYPEOF_NATIVE : data_member_native ]
[ compile data_member.cpp : <define>BOOST_TYPEOF_COMPLIANT : data_member_emulation ]
[ compile lvalue.cpp : <define>BOOST_TYPEOF_NATIVE : lvalue_native ]
[ compile lvalue.cpp : <define>BOOST_TYPEOF_COMPLIANT : lvalue_emulation ]
;

7
test/data_member.cpp Executable file
View File

@ -0,0 +1,7 @@
#include "test.hpp"
#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
struct x;
BOOST_TYPEOF_REGISTER_TYPE(x)
BOOST_STATIC_ASSERT(boost::type_of::test<double x::*>::value);

4
test/function.cpp Executable file
View File

@ -0,0 +1,4 @@
#include "test.hpp"
BOOST_STATIC_ASSERT(boost::type_of::test<void()>::value);
BOOST_STATIC_ASSERT(boost::type_of::test<double(bool)>::value);

6
test/function_ptr.cpp Executable file
View File

@ -0,0 +1,6 @@
#include "test.hpp"
BOOST_STATIC_ASSERT(boost::type_of::test<double(*)()>::value);
BOOST_STATIC_ASSERT(boost::type_of::test<double(*)(int, double, short, char*, bool, char, float, long, unsigned short)>::value);
BOOST_STATIC_ASSERT(boost::type_of::test<void(*)()>::value);
BOOST_STATIC_ASSERT(boost::type_of::test<void(*)(int, double, short, char*, bool, char, float, long, unsigned short)>::value);

4
test/function_ref.cpp Executable file
View File

@ -0,0 +1,4 @@
#include "test.hpp"
BOOST_STATIC_ASSERT(boost::type_of::test<void(&)()>::value);
BOOST_STATIC_ASSERT(boost::type_of::test<int(&)(int, short)>::value);

26
test/lvalue.cpp Executable file
View File

@ -0,0 +1,26 @@
#include <boost/typeof/typeof.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/static_assert.hpp>
#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
struct x{};
BOOST_TYPEOF_REGISTER_TYPE(x)
x n;
const x cn = n;
x& rn = n;
const x& rcn = cn;
x f();
const x cf();
x& rf();
const x& rcf();
BOOST_STATIC_ASSERT((boost::is_same<BOOST_LVALUE_TYPEOF(n), x&>::value));
BOOST_STATIC_ASSERT((boost::is_same<BOOST_LVALUE_TYPEOF(cn), const x&>::value));
BOOST_STATIC_ASSERT((boost::is_same<BOOST_LVALUE_TYPEOF(rn), x&>::value));
BOOST_STATIC_ASSERT((boost::is_same<BOOST_LVALUE_TYPEOF(rcn), const x&>::value));
BOOST_STATIC_ASSERT((boost::is_same<BOOST_LVALUE_TYPEOF(f()), x>::value));
BOOST_STATIC_ASSERT((boost::is_same<BOOST_LVALUE_TYPEOF(rf()), x&>::value));
BOOST_STATIC_ASSERT((boost::is_same<BOOST_LVALUE_TYPEOF(rcf()), const x&>::value));
BOOST_STATIC_ASSERT((boost::is_same<BOOST_LVALUE_TYPEOF(cf()), const x&>::value));

6
test/member_function.cpp Executable file
View File

@ -0,0 +1,6 @@
#include "test.hpp"
BOOST_STATIC_ASSERT(boost::type_of::test<double(*)()>::value);
BOOST_STATIC_ASSERT(boost::type_of::test<double(*)(int, double, short, char*, bool, char, float, long, unsigned short)>::value);
BOOST_STATIC_ASSERT(boost::type_of::test<void(*)()>::value);
BOOST_STATIC_ASSERT(boost::type_of::test<void(*)(int, double, short, char*, bool, char, float, long, unsigned short)>::value);

12
test/modifiers.cpp Executable file
View File

@ -0,0 +1,12 @@
#include "test.hpp"
#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
struct x;
BOOST_TYPEOF_REGISTER_TYPE(x)
BOOST_STATIC_ASSERT(boost::type_of::test<x*>::value);
BOOST_STATIC_ASSERT(boost::type_of::test<x&>::value);
BOOST_STATIC_ASSERT(boost::type_of::test<x[20]>::value);
BOOST_STATIC_ASSERT(boost::type_of::test<const x>::value);
BOOST_STATIC_ASSERT(boost::type_of::test<volatile x>::value);
BOOST_STATIC_ASSERT(boost::type_of::test<volatile const x>::value);

View File

@ -11,18 +11,18 @@
namespace boost { namespace type_of {
template<class T>
template<class T, class U>
struct test_wrapper{};
template<class T>
test_wrapper<T> test_helper(test_wrapper<T>*);
test_wrapper<T, T> test_helper(test_wrapper<T, T>*);
template<class T>
struct test
{
enum {value = boost::is_same<
BOOST_TYPEOF_TPL(test_helper(reinterpret_cast<test_wrapper<T>*>(0))),
test_wrapper<T>
BOOST_TYPEOF_TPL(test_helper(reinterpret_cast<test_wrapper<T, T>*>(0))),
test_wrapper<T, T>
>::value
};
};
@ -30,6 +30,6 @@ namespace boost { namespace type_of {
}}
#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
BOOST_TYPEOF_REGISTER_TEMPLATE(boost::type_of::test_wrapper, 1)
BOOST_TYPEOF_REGISTER_TEMPLATE(boost::type_of::test_wrapper, 2)
#endif//BOOST_TYPEOF_TEST_HPP_INCLUDED