forked from boostorg/typeof
added more tests
[SVN r31048]
This commit is contained in:
18
test/Jamfile
18
test/Jamfile
@ -19,6 +19,15 @@ 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 template_enum.cpp : <define>BOOST_TYPEOF_NATIVE : template_enum_native ]
|
||||
[ compile template_enum.cpp : <define>BOOST_TYPEOF_COMPLIANT : template_enum_emulation ]
|
||||
|
||||
[ compile template_dependent.cpp : <define>BOOST_TYPEOF_NATIVE : template_dependent_native ]
|
||||
[ compile template_dependent.cpp : <define>BOOST_TYPEOF_COMPLIANT : template_dependent_emulation ]
|
||||
|
||||
[ compile template_multiword.cpp : <define>BOOST_TYPEOF_NATIVE : template_multiword_native ]
|
||||
[ compile template_multiword.cpp : <define>BOOST_TYPEOF_COMPLIANT : template_multiword_emulation ]
|
||||
|
||||
[ compile modifiers.cpp : <define>BOOST_TYPEOF_NATIVE : modifiers_native ]
|
||||
[ compile modifiers.cpp : <define>BOOST_TYPEOF_COMPLIANT : modifiers_emulation ]
|
||||
|
||||
@ -39,4 +48,13 @@ test-suite "typeof"
|
||||
|
||||
[ compile lvalue.cpp : <define>BOOST_TYPEOF_NATIVE : lvalue_native ]
|
||||
[ compile lvalue.cpp : <define>BOOST_TYPEOF_COMPLIANT : lvalue_emulation ]
|
||||
|
||||
[ compile noncopyable.cpp : <define>BOOST_TYPEOF_NATIVE : noncopyable_native ]
|
||||
[ compile noncopyable.cpp : <define>BOOST_TYPEOF_COMPLIANT : noncopyable_emulation ]
|
||||
|
||||
[ compile std.cpp : <define>BOOST_TYPEOF_NATIVE : std_native ]
|
||||
[ compile std.cpp : <define>BOOST_TYPEOF_COMPLIANT : std_emulation ]
|
||||
|
||||
[ link odr1.cpp odr2.cpp : <define>BOOST_TYPEOF_NATIVE : odr_native ]
|
||||
[ link odr1.cpp odr2.cpp : <define>BOOST_TYPEOF_COMPLIANT : odr_emulation ]
|
||||
;
|
||||
|
32
test/noncopyable.cpp
Executable file
32
test/noncopyable.cpp
Executable file
@ -0,0 +1,32 @@
|
||||
#include "test.hpp"
|
||||
#include <boost/noncopyable.hpp>
|
||||
#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();
|
||||
}
|
11
test/odr.hpp
Executable file
11
test/odr.hpp
Executable file
@ -0,0 +1,11 @@
|
||||
#include <boost/typeof/typeof.hpp>
|
||||
|
||||
struct foo
|
||||
{
|
||||
typedef BOOST_TYPEOF(1 + 2.5) type;
|
||||
};
|
||||
|
||||
namespace
|
||||
{
|
||||
typedef foo::type type;
|
||||
}
|
6
test/odr1.cpp
Executable file
6
test/odr1.cpp
Executable file
@ -0,0 +1,6 @@
|
||||
#include "odr.hpp"
|
||||
|
||||
int main()
|
||||
{
|
||||
return 0;
|
||||
}
|
1
test/odr2.cpp
Executable file
1
test/odr2.cpp
Executable file
@ -0,0 +1 @@
|
||||
#include "odr.hpp"
|
65
test/std.cpp
Executable file
65
test/std.cpp
Executable file
@ -0,0 +1,65 @@
|
||||
#include "test.hpp"
|
||||
|
||||
#include <boost/typeof/std/string.hpp>
|
||||
#include <boost/typeof/std/deque.hpp>
|
||||
#include <boost/typeof/std/list.hpp>
|
||||
#include <boost/typeof/std/queue.hpp>
|
||||
#include <boost/typeof/std/stack.hpp>
|
||||
#include <boost/typeof/std/vector.hpp>
|
||||
#include <boost/typeof/std/map.hpp>
|
||||
#include <boost/typeof/std/set.hpp>
|
||||
#include <boost/typeof/std/bitset.hpp>
|
||||
#include <boost/typeof/std/functional.hpp>
|
||||
#include <boost/typeof/std/valarray.hpp>
|
||||
#include <boost/typeof/std/locale.hpp>
|
||||
#include <boost/typeof/std/iostream.hpp>
|
||||
#include <boost/typeof/std/streambuf.hpp>
|
||||
#include <boost/typeof/std/istream.hpp>
|
||||
#include <boost/typeof/std/ostream.hpp>
|
||||
#include <boost/typeof/std/sstream.hpp>
|
||||
#include <boost/typeof/std/fstream.hpp>
|
||||
#include <boost/typeof/std/iterator.hpp>
|
||||
|
||||
using namespace std;
|
||||
|
||||
// STL containers
|
||||
|
||||
BOOST_STATIC_ASSERT(boost::type_of::test<string>::value);
|
||||
BOOST_STATIC_ASSERT(boost::type_of::test<deque<int> >::value);
|
||||
BOOST_STATIC_ASSERT(boost::type_of::test<list<int> >::value);
|
||||
BOOST_STATIC_ASSERT(boost::type_of::test<queue<int> >::value);
|
||||
BOOST_STATIC_ASSERT(boost::type_of::test<stack<int> >::value);
|
||||
BOOST_STATIC_ASSERT(boost::type_of::test<vector<int> >::value);
|
||||
BOOST_STATIC_ASSERT((boost::type_of::test<map<int, int> >::value));
|
||||
BOOST_STATIC_ASSERT((boost::type_of::test<multimap<int, int> >::value));
|
||||
BOOST_STATIC_ASSERT(boost::type_of::test<set<int> >::value);
|
||||
BOOST_STATIC_ASSERT(boost::type_of::test<multiset<int> >::value);
|
||||
BOOST_STATIC_ASSERT(boost::type_of::test<bitset<10> >::value);
|
||||
|
||||
// function objects
|
||||
|
||||
BOOST_STATIC_ASSERT((boost::type_of::test<unary_function<int, int> >::value));
|
||||
BOOST_STATIC_ASSERT((boost::type_of::test<binary_function<int, int, int> >::value));
|
||||
BOOST_STATIC_ASSERT(boost::type_of::test<plus<int> >::value);
|
||||
BOOST_STATIC_ASSERT(boost::type_of::test<minus<int> >::value);
|
||||
BOOST_STATIC_ASSERT(boost::type_of::test<multiplies<int> >::value);
|
||||
BOOST_STATIC_ASSERT(boost::type_of::test<divides<int> >::value);
|
||||
BOOST_STATIC_ASSERT(boost::type_of::test<modulus<int> >::value);
|
||||
BOOST_STATIC_ASSERT(boost::type_of::test<negate<int> >::value);
|
||||
BOOST_STATIC_ASSERT(boost::type_of::test<equal_to<int> >::value);
|
||||
BOOST_STATIC_ASSERT(boost::type_of::test<not_equal_to<int> >::value);
|
||||
BOOST_STATIC_ASSERT(boost::type_of::test<greater<int> >::value);
|
||||
BOOST_STATIC_ASSERT(boost::type_of::test<less<int> >::value);
|
||||
BOOST_STATIC_ASSERT(boost::type_of::test<greater_equal<int> >::value);
|
||||
BOOST_STATIC_ASSERT(boost::type_of::test<less_equal<int> >::value);
|
||||
BOOST_STATIC_ASSERT(boost::type_of::test<logical_and<int> >::value);
|
||||
BOOST_STATIC_ASSERT(boost::type_of::test<logical_or<int> >::value);
|
||||
BOOST_STATIC_ASSERT(boost::type_of::test<logical_not<int> >::value);
|
||||
BOOST_STATIC_ASSERT(boost::type_of::test<unary_negate<negate<int> > >::value);
|
||||
BOOST_STATIC_ASSERT(boost::type_of::test<binary_negate<less<int> > >::value);
|
||||
BOOST_STATIC_ASSERT(boost::type_of::test<binder1st<less<int> > >::value);
|
||||
BOOST_STATIC_ASSERT(boost::type_of::test<binder2nd<less<int> > >::value);
|
||||
|
||||
// valarray
|
||||
|
||||
BOOST_STATIC_ASSERT(boost::type_of::test<valarray<int> >::value);
|
11
test/template_dependent.cpp
Executable file
11
test/template_dependent.cpp
Executable file
@ -0,0 +1,11 @@
|
||||
#include "test.hpp"
|
||||
#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
|
||||
|
||||
template<class T, T n> struct t{};
|
||||
|
||||
BOOST_TYPEOF_REGISTER_TEMPLATE(t,
|
||||
(class)
|
||||
(BOOST_TYPEOF_INTEGRAL(P0))
|
||||
)
|
||||
|
||||
BOOST_STATIC_ASSERT((boost::type_of::test<t<int, 5>()>::value));
|
11
test/template_enum.cpp
Executable file
11
test/template_enum.cpp
Executable file
@ -0,0 +1,11 @@
|
||||
#include "test.hpp"
|
||||
#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
|
||||
|
||||
enum E{ONE, TWO, THREE};
|
||||
template<E e> struct t{};
|
||||
|
||||
BOOST_TYPEOF_REGISTER_TEMPLATE(t,
|
||||
(BOOST_TYPEOF_INTEGRAL(E))
|
||||
)
|
||||
|
||||
BOOST_STATIC_ASSERT(boost::type_of::test<t<TWO>()>::value);
|
10
test/template_multiword.cpp
Executable file
10
test/template_multiword.cpp
Executable file
@ -0,0 +1,10 @@
|
||||
#include "test.hpp"
|
||||
#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
|
||||
|
||||
template<unsigned long int n> struct t{};
|
||||
|
||||
BOOST_TYPEOF_REGISTER_TEMPLATE(t,
|
||||
(BOOST_TYPEOF_INTEGRAL(unsigned long int))
|
||||
)
|
||||
|
||||
BOOST_STATIC_ASSERT((boost::type_of::test<t<5>()>::value));
|
Reference in New Issue
Block a user