Skip to content

Commit 453cf59

Browse files
committed
Replace Boost.Test with lightweight_test from Boost.Core. Modified version of #6. Thanks to mloskot for the patch.
1 parent b279a90 commit 453cf59

8 files changed

+55
-62
lines changed

Diff for: test/Jamfile.v2

+5-12
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,17 @@
22
#~ Distributed under the Boost Software License, Version 1.0.
33
#~ (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
44

5-
import testing ;
6-
7-
alias unit_test_framework
8-
: # sources
9-
/boost//unit_test_framework
10-
;
11-
125
test-suite array :
13-
[ run array0.cpp unit_test_framework : : : : array0 ]
6+
[ run array0.cpp ]
147
[ run array1.cpp ]
158
[ run array2.cpp ]
169
[ run array3.cpp ]
1710
[ run array4.cpp ]
1811
[ run array5.cpp ]
19-
[ run array6.cpp unit_test_framework : : : : array6 ]
20-
[ run array7.cpp unit_test_framework : : : : array7 ]
21-
# [ run array_constexpr.cpp unit_test_framework : : : : array_constexpr ]
12+
[ run array6.cpp ]
13+
[ run array7.cpp ]
14+
# [ run array_constexpr.cpp ]
2215
[ compile-fail array_getfail1.cpp ]
2316
[ compile-fail array_getfail2.cpp ]
24-
[ run array_hash.cpp unit_test_framework : : : : array_hash ]
17+
[ run array_hash.cpp ]
2518
;

Diff for: test/array0.cpp

+14-14
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,14 @@
99
#include <iostream>
1010
#include <boost/array.hpp>
1111

12-
#define BOOST_TEST_MAIN
13-
#include <boost/test/unit_test.hpp>
12+
#include <boost/core/lightweight_test_trait.hpp>
1413

1514
namespace {
1615

1716
template< class T >
1817
void BadValue( const T & )
1918
{
20-
BOOST_CHECK ( false );
19+
BOOST_TEST ( false );
2120
}
2221

2322
template< class T >
@@ -33,19 +32,19 @@ void RunTests()
3332

3433
// front/back and operator[] must compile, but calling them is undefined
3534
// Likewise, all tests below should evaluate to false, avoiding undefined behaviour
36-
BOOST_CHECK ( test_case.empty());
37-
BOOST_CHECK ( const_test_case.empty());
35+
BOOST_TEST ( test_case.empty());
36+
BOOST_TEST ( const_test_case.empty());
3837

39-
BOOST_CHECK ( test_case.size() == 0 );
40-
BOOST_CHECK ( const_test_case.size() == 0 );
38+
BOOST_TEST ( test_case.size() == 0 );
39+
BOOST_TEST ( const_test_case.size() == 0 );
4140

4241
// Assert requirements of TR1 6.2.2.4
43-
BOOST_CHECK ( test_case.begin() == test_case.end());
44-
BOOST_CHECK ( test_case.cbegin() == test_case.cend());
45-
BOOST_CHECK ( const_test_case.begin() == const_test_case.end());
46-
BOOST_CHECK ( const_test_case.cbegin() == const_test_case.cend());
42+
BOOST_TEST ( test_case.begin() == test_case.end());
43+
BOOST_TEST ( test_case.cbegin() == test_case.cend());
44+
BOOST_TEST ( const_test_case.begin() == const_test_case.end());
45+
BOOST_TEST ( const_test_case.cbegin() == const_test_case.cend());
4746

48-
BOOST_CHECK ( test_case.begin() != const_test_case.begin() );
47+
BOOST_TEST ( test_case.begin() != const_test_case.begin() );
4948
if( test_case.data() == const_test_case.data() ) {
5049
// Value of data is unspecified in TR1, so no requirement this test pass or fail
5150
// However, it must compile!
@@ -79,11 +78,12 @@ void RunTests()
7978

8079
}
8180

82-
BOOST_AUTO_TEST_CASE( test_main )
81+
int main()
8382
{
8483
RunTests< bool >();
8584
RunTests< void * >();
8685
RunTests< long double >();
8786
RunTests< std::string >();
88-
}
8987

88+
return boost::report_errors();
89+
}

Diff for: test/array6.cpp

+9-8
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010
#include <boost/array.hpp>
1111
#include <algorithm>
1212

13-
#define BOOST_TEST_MAIN
14-
#include <boost/test/unit_test.hpp>
13+
#include <boost/core/lightweight_test_trait.hpp>
1514

1615
namespace {
1716
template< class T >
@@ -22,38 +21,40 @@ namespace {
2221
test_type test_case; // = { 1, 1, 2, 3, 5 };
2322

2423
arr &aRef = get_c_array ( test_case );
25-
BOOST_CHECK ( &*test_case.begin () == &aRef[0] );
24+
BOOST_TEST ( &*test_case.begin () == &aRef[0] );
2625

2726
const arr &caRef = get_c_array ( test_case );
2827
typename test_type::const_iterator iter = test_case.begin ();
29-
BOOST_CHECK ( &*iter == &caRef[0] );
28+
BOOST_TEST ( &*iter == &caRef[0] );
3029

3130
// Confirm at() throws the std lib defined exception
3231
try {
3332
test_case.at( test_case.size());
34-
BOOST_CHECK(false);
33+
BOOST_TEST(false);
3534
}
3635
catch ( const std::out_of_range & ) {}
3736

3837
try {
3938
test_case.at( test_case.size() + 1);
40-
BOOST_CHECK(false);
39+
BOOST_TEST(false);
4140
}
4241
catch ( const std::out_of_range & ) {}
4342

4443
try {
4544
test_case.at( test_case.size() + 100);
46-
BOOST_CHECK(false);
45+
BOOST_TEST(false);
4746
}
4847
catch ( const std::out_of_range & ) {}
4948
}
5049
}
5150

52-
BOOST_AUTO_TEST_CASE( test_main )
51+
int main ()
5352
{
5453
RunTests< bool >();
5554
RunTests< void * >();
5655
RunTests< long double >();
5756
RunTests< std::string >();
57+
58+
return boost::report_errors();
5859
}
5960

Diff for: test/array7.cpp

+8-9
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@
1313
#include <array>
1414
#endif
1515

16-
#define BOOST_TEST_MAIN
17-
#include <boost/test/unit_test.hpp>
16+
#include <boost/core/lightweight_test_trait.hpp>
1817

1918
namespace {
2019

@@ -23,34 +22,32 @@ namespace {
2322
void RunStdTests()
2423
{
2524
typedef boost::array< T, 5 > test_type;
26-
typedef T arr[5];
2725
test_type test_case; // = { 1, 1, 2, 3, 5 };
2826

2927
T &aRef = std::get<0> ( test_case );
30-
BOOST_CHECK ( &*test_case.begin () == &aRef );
28+
BOOST_TEST ( &*test_case.begin () == &aRef );
3129

3230
const T &caRef = std::get<0> ( test_case );
33-
BOOST_CHECK ( &*test_case.cbegin () == &caRef );
31+
BOOST_TEST ( &*test_case.cbegin () == &caRef );
3432
}
3533
#endif
3634

3735
template< class T >
3836
void RunBoostTests()
3937
{
4038
typedef boost::array< T, 5 > test_type;
41-
typedef T arr[5];
4239
test_type test_case; // = { 1, 1, 2, 3, 5 };
4340

4441
T &aRef = boost::get<0> ( test_case );
45-
BOOST_CHECK ( &*test_case.begin () == &aRef );
42+
BOOST_TEST ( &*test_case.begin () == &aRef );
4643

4744
const T &caRef = boost::get<0> ( test_case );
48-
BOOST_CHECK ( &*test_case.cbegin () == &caRef );
45+
BOOST_TEST ( &*test_case.cbegin () == &caRef );
4946
}
5047

5148
}
5249

53-
BOOST_AUTO_TEST_CASE( test_main )
50+
int main()
5451
{
5552
RunBoostTests< bool >();
5653
RunBoostTests< void * >();
@@ -63,5 +60,7 @@ BOOST_AUTO_TEST_CASE( test_main )
6360
RunStdTests< long double >();
6461
RunStdTests< std::string >();
6562
#endif
63+
64+
return boost::report_errors();
6665
}
6766

Diff for: test/array_constexpr.cpp

+2-5
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@
1313
#include <array>
1414
#endif
1515

16-
#define BOOST_TEST_MAIN
17-
#include <boost/test/unit_test.hpp>
18-
1916
#ifndef BOOST_NO_CXX11_CONSTEXPR
2017
constexpr boost::array<int, 10> arr {{ 0,1,2,3,4,5,6,7,8,9 }};
2118
constexpr std::array<int, 10> arr_std {{ 0,1,2,3,4,5,6,7,8,9 }};
@@ -26,7 +23,7 @@ void sink ( T t ) {}
2623
template <typename T, size_t N>
2724
void sink ( boost::array<T,N> &arr ) {}
2825

29-
BOOST_AUTO_TEST_CASE( test_main )
26+
int main()
3027
{
3128
// constexpr int two = arr_std.at (2);
3229
constexpr int three = arr.at (3);
@@ -36,7 +33,7 @@ BOOST_AUTO_TEST_CASE( test_main )
3633
}
3734

3835
#else // no constexpr means no constexpr tests!
39-
BOOST_AUTO_TEST_CASE( test_main )
36+
int main()
4037
{
4138
}
4239
#endif

Diff for: test/array_getfail1.cpp

+5-4
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@
1616
#include <array>
1717
#endif
1818

19-
#define BOOST_TEST_MAIN
20-
#include <boost/test/unit_test.hpp>
19+
#include <boost/core/lightweight_test_trait.hpp>
2120

2221
namespace {
2322

@@ -30,13 +29,13 @@ namespace {
3029
test_type test_case; // = { 1, 1, 2, 3, 5 };
3130

3231
T &aRef = std::get<5> ( test_case ); // should fail to compile
33-
BOOST_CHECK ( &*test_case.begin () == &aRef );
32+
BOOST_TEST ( &*test_case.begin () == &aRef );
3433
}
3534
#endif
3635

3736
}
3837

39-
BOOST_AUTO_TEST_CASE( test_main )
38+
int main()
4039
{
4140
#ifndef BOOST_NO_CXX11_HDR_ARRAY
4241
RunStdTests< bool >();
@@ -46,4 +45,6 @@ BOOST_AUTO_TEST_CASE( test_main )
4645
#else
4746
BOOST_STATIC_ASSERT ( false ); // fail on C++03 systems.
4847
#endif
48+
49+
return boost::report_errors();
4950
}

Diff for: test/array_getfail2.cpp

+7-6
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@
1313
#include <array>
1414
#endif
1515

16-
#define BOOST_TEST_MAIN
17-
#include <boost/test/unit_test.hpp>
16+
#include <boost/core/lightweight_test_trait.hpp>
1817

1918
namespace {
2019

@@ -27,10 +26,10 @@ namespace {
2726
test_type test_case; // = { 1, 1, 2, 3, 5 };
2827

2928
T &aRef = std::get<0> ( test_case );
30-
BOOST_CHECK ( &*test_case.begin () == &aRef );
29+
BOOST_TEST ( &*test_case.begin () == &aRef );
3130

3231
const T &caRef = std::get<0> ( test_case );
33-
BOOST_CHECK ( &*test_case.cbegin () == &caRef );
32+
BOOST_TEST ( &*test_case.cbegin () == &caRef );
3433
}
3534
#endif
3635

@@ -42,12 +41,12 @@ namespace {
4241
test_type test_case; // = { 1, 1, 2, 3, 5 };
4342

4443
T &aRef = boost::get<5> ( test_case );
45-
BOOST_CHECK ( &*test_case.begin () == &aRef );
44+
BOOST_TEST ( &*test_case.begin () == &aRef );
4645
}
4746

4847
}
4948

50-
BOOST_AUTO_TEST_CASE( test_main )
49+
int main()
5150
{
5251
RunBoostTests< bool >();
5352
RunBoostTests< void * >();
@@ -60,5 +59,7 @@ BOOST_AUTO_TEST_CASE( test_main )
6059
RunStdTests< long double >();
6160
RunStdTests< std::string >();
6261
#endif
62+
63+
return boost::report_errors();
6364
}
6465

Diff for: test/array_hash.cpp

+5-4
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@
1111
#include <algorithm>
1212
#include <boost/functional/hash.hpp>
1313

14-
#define BOOST_TEST_MAIN
15-
#include <boost/test/unit_test.hpp>
14+
#include <boost/core/lightweight_test_trait.hpp>
1615

1716
namespace {
1817

@@ -29,15 +28,17 @@ namespace {
2928

3029
std::size_t bhash = boost::hash<barr> () ( test_barr );
3130
std::size_t ahash = boost::hash<arr> () ( test_arr );
32-
BOOST_CHECK ( ahash == bhash );
31+
BOOST_TEST ( ahash == bhash );
3332
}
3433

3534
}
3635

37-
BOOST_AUTO_TEST_CASE( test_main )
36+
int main()
3837
{
3938
RunTests< int >();
4039
RunTests< long >();
4140
RunTests< long double >();
41+
42+
return boost::report_errors();
4243
}
4344

0 commit comments

Comments
 (0)