Next round of MSVC 6/7 fixes.

[SVN r22453]
This commit is contained in:
Peter Dimov
2004-03-07 16:39:15 +00:00
parent 6fbbcd0d3c
commit 807bbfd434
3 changed files with 241 additions and 412 deletions

View File

@@ -44,6 +44,11 @@ public:
{
}
int state() const
{
return state_;
}
int operator()()
{
return state_ += 17041;
@@ -140,38 +145,74 @@ int f8(int & state_, int x1, int x2, int x3, int x4, int x5, int x6, int x7, int
return state_ += x1+x2+x3+x4+x5+x6+x7+x8;
}
template<class F> void test(F f, int r)
template<class F> void test(F f, int a, int b)
{
BOOST_TEST( f() == r );
BOOST_TEST( f() == 2*r );
BOOST_TEST( f() == 3*r );
BOOST_TEST( f() == a + b );
BOOST_TEST( f() == a + 2*b );
BOOST_TEST( f() == a + 3*b );
}
void stateful_function_object_test()
{
test( boost::bind<int>( X() ), 17041 );
test( boost::bind<int>( X(), 1 ), 1 );
test( boost::bind<int>( X(), 1, 2 ), 1+2 );
test( boost::bind<int>( X(), 1, 2, 3 ), 1+2+3 );
test( boost::bind<int>( X(), 1, 2, 3, 4 ), 1+2+3+4 );
test( boost::bind<int>( X(), 1, 2, 3, 4, 5 ), 1+2+3+4+5 );
test( boost::bind<int>( X(), 1, 2, 3, 4, 5, 6 ), 1+2+3+4+5+6 );
test( boost::bind<int>( X(), 1, 2, 3, 4, 5, 6, 7 ), 1+2+3+4+5+6+7 );
test( boost::bind<int>( X(), 1, 2, 3, 4, 5, 6, 7, 8 ), 1+2+3+4+5+6+7+8 );
test( boost::bind<int>( X(), 1, 2, 3, 4, 5, 6, 7, 8, 9 ), 1+2+3+4+5+6+7+8+9 );
test( boost::bind<int>( X() ), 0, 17041 );
test( boost::bind<int>( X(), 1 ), 0, 1 );
test( boost::bind<int>( X(), 1, 2 ), 0, 1+2 );
test( boost::bind<int>( X(), 1, 2, 3 ), 0, 1+2+3 );
test( boost::bind<int>( X(), 1, 2, 3, 4 ), 0, 1+2+3+4 );
test( boost::bind<int>( X(), 1, 2, 3, 4, 5 ), 0, 1+2+3+4+5 );
test( boost::bind<int>( X(), 1, 2, 3, 4, 5, 6 ), 0, 1+2+3+4+5+6 );
test( boost::bind<int>( X(), 1, 2, 3, 4, 5, 6, 7 ), 0, 1+2+3+4+5+6+7 );
test( boost::bind<int>( X(), 1, 2, 3, 4, 5, 6, 7, 8 ), 0, 1+2+3+4+5+6+7+8 );
test( boost::bind<int>( X(), 1, 2, 3, 4, 5, 6, 7, 8, 9 ), 0, 1+2+3+4+5+6+7+8+9 );
X x;
int n = x.state();
test( boost::bind<int>( boost::ref(x) ), n, 17041 );
n += 3*17041;
test( boost::bind<int>( boost::ref(x), 1 ), n, 1 );
n += 3*1;
test( boost::bind<int>( boost::ref(x), 1, 2 ), n, 1+2 );
n += 3*(1+2);
test( boost::bind<int>( boost::ref(x), 1, 2, 3 ), n, 1+2+3 );
n += 3*(1+2+3);
test( boost::bind<int>( boost::ref(x), 1, 2, 3, 4 ), n, 1+2+3+4 );
n += 3*(1+2+3+4);
test( boost::bind<int>( boost::ref(x), 1, 2, 3, 4, 5 ), n, 1+2+3+4+5 );
n += 3*(1+2+3+4+5);
test( boost::bind<int>( boost::ref(x), 1, 2, 3, 4, 5, 6 ), n, 1+2+3+4+5+6 );
n += 3*(1+2+3+4+5+6);
test( boost::bind<int>( boost::ref(x), 1, 2, 3, 4, 5, 6, 7 ), n, 1+2+3+4+5+6+7 );
n += 3*(1+2+3+4+5+6+7);
test( boost::bind<int>( boost::ref(x), 1, 2, 3, 4, 5, 6, 7, 8 ), n, 1+2+3+4+5+6+7+8 );
n += 3*(1+2+3+4+5+6+7+8);
test( boost::bind<int>( boost::ref(x), 1, 2, 3, 4, 5, 6, 7, 8, 9 ), n, 1+2+3+4+5+6+7+8+9 );
n += 3*(1+2+3+4+5+6+7+8+9);
BOOST_TEST( x.state() == n );
}
void stateful_function_test()
{
test( boost::bind( f0, 0 ), 17041 );
test( boost::bind( f1, 0, 1 ), 1 );
test( boost::bind( f2, 0, 1, 2 ), 1+2 );
test( boost::bind( f3, 0, 1, 2, 3 ), 1+2+3 );
test( boost::bind( f4, 0, 1, 2, 3, 4 ), 1+2+3+4 );
test( boost::bind( f5, 0, 1, 2, 3, 4, 5 ), 1+2+3+4+5 );
test( boost::bind( f6, 0, 1, 2, 3, 4, 5, 6 ), 1+2+3+4+5+6 );
test( boost::bind( f7, 0, 1, 2, 3, 4, 5, 6, 7 ), 1+2+3+4+5+6+7 );
test( boost::bind( f8, 0, 1, 2, 3, 4, 5, 6, 7, 8 ), 1+2+3+4+5+6+7+8 );
test( boost::bind( f0, 0 ), 0, 17041 );
test( boost::bind( f1, 0, 1 ), 0, 1 );
test( boost::bind( f2, 0, 1, 2 ), 0, 1+2 );
test( boost::bind( f3, 0, 1, 2, 3 ), 0, 1+2+3 );
test( boost::bind( f4, 0, 1, 2, 3, 4 ), 0, 1+2+3+4 );
test( boost::bind( f5, 0, 1, 2, 3, 4, 5 ), 0, 1+2+3+4+5 );
test( boost::bind( f6, 0, 1, 2, 3, 4, 5, 6 ), 0, 1+2+3+4+5+6 );
test( boost::bind( f7, 0, 1, 2, 3, 4, 5, 6, 7 ), 0, 1+2+3+4+5+6+7 );
test( boost::bind( f8, 0, 1, 2, 3, 4, 5, 6, 7, 8 ), 0, 1+2+3+4+5+6+7+8 );
}
int main()