forked from boostorg/core
Add tests for lightweight_test.hpp.
This commit is contained in:
@@ -49,4 +49,12 @@ test-suite "core"
|
|||||||
[ run visit_each_test.cpp ]
|
[ run visit_each_test.cpp ]
|
||||||
|
|
||||||
[ run get_pointer_test.cpp ]
|
[ run get_pointer_test.cpp ]
|
||||||
|
|
||||||
|
[ run lightweight_test_test.cpp ]
|
||||||
|
[ run-fail lightweight_test_fail.cpp ]
|
||||||
|
[ run-fail lightweight_test_fail2.cpp ]
|
||||||
|
[ run-fail lightweight_test_fail3.cpp ]
|
||||||
|
[ run-fail lightweight_test_fail4.cpp ]
|
||||||
|
[ run-fail lightweight_test_fail5.cpp ]
|
||||||
|
[ run-fail lightweight_test_fail6.cpp ]
|
||||||
;
|
;
|
||||||
|
20
test/lightweight_test_fail.cpp
Normal file
20
test/lightweight_test_fail.cpp
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
//
|
||||||
|
// Negative test for BOOST_TEST
|
||||||
|
//
|
||||||
|
// Copyright (c) 2014 Peter Dimov
|
||||||
|
//
|
||||||
|
// 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
|
||||||
|
//
|
||||||
|
|
||||||
|
#include <boost/detail/lightweight_test.hpp>
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
int x = 0;
|
||||||
|
|
||||||
|
BOOST_TEST( x == 1 ); // will fail
|
||||||
|
|
||||||
|
return boost::report_errors();
|
||||||
|
}
|
18
test/lightweight_test_fail2.cpp
Normal file
18
test/lightweight_test_fail2.cpp
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
//
|
||||||
|
// Test for BOOST_ERROR
|
||||||
|
//
|
||||||
|
// Copyright (c) 2014 Peter Dimov
|
||||||
|
//
|
||||||
|
// 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
|
||||||
|
//
|
||||||
|
|
||||||
|
#include <boost/detail/lightweight_test.hpp>
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
BOOST_ERROR( "expected failure" );
|
||||||
|
|
||||||
|
return boost::report_errors();
|
||||||
|
}
|
20
test/lightweight_test_fail3.cpp
Normal file
20
test/lightweight_test_fail3.cpp
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
//
|
||||||
|
// Negative test for BOOST_TEST_EQ
|
||||||
|
//
|
||||||
|
// Copyright (c) 2014 Peter Dimov
|
||||||
|
//
|
||||||
|
// 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
|
||||||
|
//
|
||||||
|
|
||||||
|
#include <boost/detail/lightweight_test.hpp>
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
int x = 0;
|
||||||
|
|
||||||
|
BOOST_TEST_EQ( x, 1 );
|
||||||
|
|
||||||
|
return boost::report_errors();
|
||||||
|
}
|
20
test/lightweight_test_fail4.cpp
Normal file
20
test/lightweight_test_fail4.cpp
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
//
|
||||||
|
// Negative test for BOOST_TEST_NE
|
||||||
|
//
|
||||||
|
// Copyright (c) 2014 Peter Dimov
|
||||||
|
//
|
||||||
|
// 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
|
||||||
|
//
|
||||||
|
|
||||||
|
#include <boost/detail/lightweight_test.hpp>
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
int x = 0;
|
||||||
|
|
||||||
|
BOOST_TEST_NE( x, 0 );
|
||||||
|
|
||||||
|
return boost::report_errors();
|
||||||
|
}
|
26
test/lightweight_test_fail5.cpp
Normal file
26
test/lightweight_test_fail5.cpp
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
//
|
||||||
|
// Negative test for BOOST_TEST_THROWS
|
||||||
|
//
|
||||||
|
// Copyright (c) 2014 Peter Dimov
|
||||||
|
//
|
||||||
|
// 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
|
||||||
|
//
|
||||||
|
|
||||||
|
#include <boost/detail/lightweight_test.hpp>
|
||||||
|
|
||||||
|
struct X
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
void f()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
BOOST_TEST_THROWS( f(), X );
|
||||||
|
|
||||||
|
return boost::report_errors();
|
||||||
|
}
|
27
test/lightweight_test_fail6.cpp
Normal file
27
test/lightweight_test_fail6.cpp
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
//
|
||||||
|
// Negative test for BOOST_TEST_THROWS
|
||||||
|
//
|
||||||
|
// Copyright (c) 2014 Peter Dimov
|
||||||
|
//
|
||||||
|
// 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
|
||||||
|
//
|
||||||
|
|
||||||
|
#include <boost/detail/lightweight_test.hpp>
|
||||||
|
|
||||||
|
struct X
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
void f()
|
||||||
|
{
|
||||||
|
throw 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
BOOST_TEST_THROWS( f(), X );
|
||||||
|
|
||||||
|
return boost::report_errors();
|
||||||
|
}
|
68
test/lightweight_test_test.cpp
Normal file
68
test/lightweight_test_test.cpp
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
//
|
||||||
|
// Test for lightweight_test.hpp
|
||||||
|
//
|
||||||
|
// Copyright (c) 2014 Peter Dimov
|
||||||
|
//
|
||||||
|
// 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
|
||||||
|
//
|
||||||
|
|
||||||
|
#include <boost/detail/lightweight_test.hpp>
|
||||||
|
|
||||||
|
struct X
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
void f( bool x )
|
||||||
|
{
|
||||||
|
if( x )
|
||||||
|
{
|
||||||
|
throw X();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw 5;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
int x = 0;
|
||||||
|
|
||||||
|
// BOOST_TEST
|
||||||
|
|
||||||
|
BOOST_TEST( x == 0 );
|
||||||
|
BOOST_TEST( ++x == 1 );
|
||||||
|
BOOST_TEST( x++ == 1 );
|
||||||
|
BOOST_TEST( x == 2? true: false );
|
||||||
|
BOOST_TEST( x == 2? &x: 0 );
|
||||||
|
|
||||||
|
// BOOST_TEST_EQ
|
||||||
|
|
||||||
|
BOOST_TEST_EQ( x, 2 );
|
||||||
|
BOOST_TEST_EQ( ++x, 3 );
|
||||||
|
BOOST_TEST_EQ( x++, 3 );
|
||||||
|
|
||||||
|
int y = 4;
|
||||||
|
|
||||||
|
BOOST_TEST_EQ( ++x, ++y );
|
||||||
|
BOOST_TEST_EQ( x++, y++ );
|
||||||
|
|
||||||
|
// BOOST_TEST_NE
|
||||||
|
|
||||||
|
BOOST_TEST_NE( ++x, y );
|
||||||
|
BOOST_TEST_NE( &x, &y );
|
||||||
|
|
||||||
|
// BOOST_TEST_THROWS
|
||||||
|
|
||||||
|
BOOST_TEST_THROWS( throw X(), X );
|
||||||
|
BOOST_TEST_THROWS( throw 1, int );
|
||||||
|
|
||||||
|
BOOST_TEST_THROWS( f(true), X );
|
||||||
|
BOOST_TEST_THROWS( f(false), int );
|
||||||
|
|
||||||
|
//
|
||||||
|
|
||||||
|
return boost::report_errors();
|
||||||
|
}
|
Reference in New Issue
Block a user