Skip to content

Commit d8d423c

Browse files
committed
Add tests for emplace_{back,front}
1 parent 3e0c33f commit d8d423c

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

test/common.ipp

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,34 @@ void cxx11_allocator_test() {
280280
CB_CONTAINER<MyInteger, cxx11_allocator<MyInteger> > cb(10, 0);
281281
generic_test(cb);
282282
}
283+
284+
#endif
285+
#ifndef BOOST_NO_CXX11_VARIADIC_TEMPLATES
286+
void emplace_test(){
287+
CB_CONTAINER<MyInteger> cb(4);
288+
cb.emplace_back(4);
289+
cb.emplace_back(5);
290+
cb.emplace_back(6);
291+
cb.emplace_back(7);
292+
293+
BOOST_CHECK(cb.size() == 4);
294+
BOOST_CHECK(cb.front() == 4);
295+
BOOST_CHECK(cb.back() == 7);
296+
297+
cb.emplace_front(3);
298+
cb.emplace_front(2);
299+
300+
BOOST_CHECK(cb.front() == 2);
301+
BOOST_CHECK(cb.back() == 5);
302+
303+
cb.emplace_front(1);
304+
cb.emplace_front(0);
305+
306+
BOOST_CHECK(cb.size() == 4);
307+
BOOST_CHECK(*cb.begin() == 0);
308+
BOOST_CHECK(cb.front() == 0);
309+
BOOST_CHECK(cb.back() == 3);
310+
}
283311
#endif
284312

285313
void begin_and_end_test() {
@@ -2479,5 +2507,8 @@ void add_common_tests(test_suite* tests) {
24792507
#if !defined(BOOST_CB_NO_CXX11_ALLOCATOR)
24802508
tests->add(BOOST_TEST_CASE(&cxx11_allocator_test));
24812509
#endif
2510+
#ifndef BOOST_NO_CXX11_VARIADIC_TEMPLATES
2511+
tests->add(BOOST_TEST_CASE(&emplace_test));
2512+
#endif
24822513
}
24832514

0 commit comments

Comments
 (0)