1 // (C) Copyright Raffi Enficiaud 2014.
2 // Distributed under the Boost Software License, Version 1.0.
3 // (See accompanying file LICENSE_1_0.txt or copy at
4 // http://www.boost.org/LICENSE_1_0.txt)
5
6 // See http://www.boost.org/libs/test for the library home page.
7
8 //[example_code
9 #define BOOST_TEST_MODULE boost_test_sequence_per_element
10 #include <boost/test/included/unit_test.hpp>
11 #include <vector>
12 #include <list>
13 namespace tt = boost::test_tools;
14
BOOST_AUTO_TEST_CASE(test_sequence_per_element)15 BOOST_AUTO_TEST_CASE( test_sequence_per_element )
16 {
17 std::vector<int> a{1,2,3};
18 std::vector<long> b{1,5,3};
19 std::list<short> c{1,5,3,4};
20
21 BOOST_TEST(a == b, tt::per_element()); // nok: a[1] != b[1]
22
23 BOOST_TEST(a != b, tt::per_element()); // nok: a[0] == b[0] ...
24 BOOST_TEST(a <= b, tt::per_element()); // ok
25 BOOST_TEST(b < c, tt::per_element()); // nok: size mismatch
26 BOOST_TEST(b >= c, tt::per_element()); // nok: size mismatch
27 BOOST_TEST(b != c, tt::per_element()); // nok: size mismatch
28 }
29
BOOST_AUTO_TEST_CASE(test_compare_c_arrays_element_wise)30 BOOST_AUTO_TEST_CASE( test_compare_c_arrays_element_wise )
31 {
32 int a[] = {1, 2, 3};
33 int b[] = {1, 5, 3};
34 std::vector<long> c{1, 5, 3};
35 BOOST_TEST(a == b, boost::test_tools::per_element());
36 BOOST_TEST(a != b, boost::test_tools::per_element());
37 BOOST_TEST(a < b, boost::test_tools::per_element());
38 BOOST_TEST(b < c, boost::test_tools::per_element());
39 BOOST_TEST(c < a, boost::test_tools::per_element());
40 }
41 //]
42