• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*=============================================================================
2     Copyright (c) 1999-2003 Jaakko Jarvi
3     Copyright (c) 2001-2011 Joel de Guzman
4 
5     Distributed under the Boost Software License, Version 1.0. (See accompanying
6     file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7 ==============================================================================*/
8 #include <boost/detail/lightweight_test.hpp>
9 #include <boost/fusion/sequence/comparison.hpp>
10 
11 struct not_a_fusion_container {};
12 template <typename T>
operator ==(not_a_fusion_container,T const &)13 inline bool operator==(not_a_fusion_container, T const&) { return true; }
14 template <typename T>
operator !=(not_a_fusion_container,T const &)15 inline bool operator!=(not_a_fusion_container, T const&) { return true; }
16 template <typename T>
operator <(not_a_fusion_container,T const &)17 inline bool operator<(not_a_fusion_container, T const&) { return true; }
18 template <typename T>
operator <=(not_a_fusion_container,T const &)19 inline bool operator<=(not_a_fusion_container, T const&) { return true; }
20 template <typename T>
operator >(not_a_fusion_container,T const &)21 inline bool operator>(not_a_fusion_container, T const&) { return true; }
22 template <typename T>
operator >=(not_a_fusion_container,T const &)23 inline bool operator>=(not_a_fusion_container, T const&) { return true; }
24 
25 void
equality_test()26 equality_test()
27 {
28     using namespace boost::fusion;
29 
30     FUSION_SEQUENCE<int, char> v1(5, 'a');
31     FUSION_SEQUENCE<int, char> v2(5, 'a');
32     BOOST_TEST(v1 == v2);
33 
34     FUSION_SEQUENCE<int, char> v3(5, 'b');
35     FUSION_SEQUENCE<int, char> t4(2, 'a');
36     BOOST_TEST(v1 != v3);
37     BOOST_TEST(v1 != t4);
38     BOOST_TEST(!(v1 != v2));
39 
40     FUSION_SEQUENCE<int, char, bool> v5(5, 'a', true);
41     BOOST_TEST(v1 != v5);
42     BOOST_TEST(!(v1 == v5));
43     BOOST_TEST(v5 != v1);
44     BOOST_TEST(!(v5 == v1));
45 
46     BOOST_TEST(not_a_fusion_container() == v1);
47     BOOST_TEST(not_a_fusion_container() != v1);
48 }
49 
50 void
ordering_test()51 ordering_test()
52 {
53     using namespace boost::fusion;
54 
55     FUSION_SEQUENCE<int, float> v1(4, 3.3f);
56     FUSION_SEQUENCE<short, float> v2(5, 3.3f);
57     FUSION_SEQUENCE<long, double> v3(5, 4.4);
58     BOOST_TEST(v1 < v2);
59     BOOST_TEST(v1 <= v2);
60     BOOST_TEST(v2 > v1);
61     BOOST_TEST(v2 >= v1);
62     BOOST_TEST(v2 < v3);
63     BOOST_TEST(v2 <= v3);
64     BOOST_TEST(v3 > v2);
65     BOOST_TEST(v3 >= v2);
66 
67 #if defined(FUSION_TEST_FAIL)
68     FUSION_SEQUENCE<int, char, bool> v5(5, 'a', true);
69     v1 >= v5;
70 #endif
71 
72     BOOST_TEST(not_a_fusion_container() > v1);
73     BOOST_TEST(not_a_fusion_container() >= v1);
74     BOOST_TEST(not_a_fusion_container() < v1);
75     BOOST_TEST(not_a_fusion_container() <= v1);
76 }
77 
78 
79 
80