1 //
2 // Negative test for BOOST_TEST_ALL_EQ
3 //
4 // Copyright (c) 2017 Bjorn Reese
5 //
6 // Distributed under the Boost Software License, Version 1.0.
7 // See accompanying file LICENSE_1_0.txt or copy at
8 // http://www.boost.org/LICENSE_1_0.txt
9 //
10 
11 #include <vector>
12 #include <set>
13 #include <boost/core/lightweight_test.hpp>
14 
main()15 int main()
16 {
17     int test_cases = 0;
18 
19     // Array
20 
21     {
22         int x[] = { 1 };
23         int y[] = { 1, 2 };
24         BOOST_TEST_ALL_EQ( x, x + sizeof(x)/sizeof(x[0]), y, y + sizeof(y)/sizeof(y[0]) );
25         ++test_cases;
26     }
27 
28     {
29         int x[] = { 1, 2 };
30         int y[] = { 1 };
31         BOOST_TEST_ALL_EQ( x, x + sizeof(x)/sizeof(x[0]), y, y + sizeof(y)/sizeof(y[0]) );
32         ++test_cases;
33     }
34 
35     {
36         int x[] = { 2 };
37         int y[] = { 1, 2 };
38         BOOST_TEST_ALL_EQ( x, x + sizeof(x)/sizeof(x[0]), y, y + sizeof(y)/sizeof(y[0]) );
39         ++test_cases;
40     }
41 
42     {
43         int x[] = { 1, 2, 3, 4 };
44         int y[] = { 1, 3, 2, 4 };
45         BOOST_TEST_ALL_EQ( x, x + sizeof(x)/sizeof(x[0]), y, y + sizeof(y)/sizeof(y[0]) );
46         ++test_cases;
47     }
48 
49     // Vector
50 
51     {
52         std::vector<int> x, y;
53         x.push_back( 1 );
54         BOOST_TEST_ALL_EQ( x.begin(), x.end(), y.begin(), y.end() );
55         ++test_cases;
56     }
57 
58     {
59         std::vector<int> x, y;
60         y.push_back( 1 );
61         BOOST_TEST_ALL_EQ( x.begin(), x.end(), y.begin(), y.end() );
62         ++test_cases;
63     }
64 
65     {
66         std::vector<int> x, y;
67         x.push_back( 1 ); x.push_back( 2 ); x.push_back( 3 ); x.push_back( 4 );
68         y.push_back( 1 ); y.push_back( 3 ); y.push_back( 2 ); y.push_back( 4 );
69         BOOST_TEST_ALL_EQ( x.begin(), x.end(), y.begin(), y.end() );
70         ++test_cases;
71     }
72 
73     {
74         std::vector<float> x, y;
75         x.push_back( 1.0f ); x.push_back( 2.0f ); x.push_back( 3.0f ); x.push_back( 4.0f );
76         y.push_back( 4.0f ); y.push_back( 2.0f ); y.push_back( 3.0f ); y.push_back( 1.0f );
77         BOOST_TEST_ALL_EQ( x.begin(), x.end(), y.begin(), y.end() );
78         ++test_cases;
79     }
80 
81     {
82         std::vector<int> x, y;
83         x.push_back( 1 ); x.push_back( 2 ); x.push_back( 3 );
84         y.push_back( 1 ); y.push_back( 3 ); y.push_back( 2 ); y.push_back( 4 );
85         BOOST_TEST_ALL_EQ( x.begin(), x.end(), y.begin(), y.end() );
86         ++test_cases;
87     }
88 
89     {
90         std::vector<int> x, y;
91         x.push_back( 1 ); x.push_back( 2 ); x.push_back( 3 ); x.push_back( 4 );
92         y.push_back( 1 ); y.push_back( 3 ); y.push_back( 2 );;
93         BOOST_TEST_ALL_EQ( x.begin(), x.end(), y.begin(), y.end() );
94         ++test_cases;
95     }
96 
97     // Set
98 
99     {
100         std::set<int> x, y;
101         x.insert(1);
102         y.insert(1); y.insert(3);
103         BOOST_TEST_ALL_EQ( x.begin(), x.end(), y.begin(), y.end() );
104         ++test_cases;
105     }
106 
107     {
108         std::set<int> x, y;
109         x.insert(1); x.insert(2);
110         y.insert(1);
111         BOOST_TEST_ALL_EQ( x.begin(), x.end(), y.begin(), y.end() );
112         ++test_cases;
113     }
114 
115     {
116         std::set<int> x, y;
117         x.insert(1); x.insert(2);
118         y.insert(1); y.insert(3);
119         BOOST_TEST_ALL_EQ( x.begin(), x.end(), y.begin(), y.end() );
120         ++test_cases;
121     }
122 
123     return boost::report_errors() == test_cases;
124 }
125