diff options
Diffstat (limited to 'libs/fusion/test/sequence')
-rw-r--r-- | libs/fusion/test/sequence/adapt_adt.cpp | 38 | ||||
-rw-r--r-- | libs/fusion/test/sequence/adapt_tpl_adt.cpp | 15 | ||||
-rw-r--r-- | libs/fusion/test/sequence/io.cpp | 2 |
3 files changed, 54 insertions, 1 deletions
diff --git a/libs/fusion/test/sequence/adapt_adt.cpp b/libs/fusion/test/sequence/adapt_adt.cpp index 7386836790..f8762b0380 100644 --- a/libs/fusion/test/sequence/adapt_adt.cpp +++ b/libs/fusion/test/sequence/adapt_adt.cpp @@ -71,6 +71,24 @@ namespace ns int y; }; #endif + + // A sequence that has data members defined in an unrelated namespace + // (std, in this case). This allows testing ADL issues. + class name + { + public: + name() {} + name(const std::string& last, const std::string& first) + : last(last), first(first) {} + + const std::string& get_last() const { return last; } + const std::string& get_first() const { return first; } + void set_last(const std::string& last_) { last = last_; } + void set_first(const std::string& first_) { first = first_; } + private: + std::string last; + std::string first; + }; } BOOST_FUSION_ADAPT_ADT( @@ -87,6 +105,12 @@ BOOST_FUSION_ADAPT_ADT( ) #endif +BOOST_FUSION_ADAPT_ADT( + ns::name, + (const std::string&, const std::string&, obj.get_last(), obj.set_last(val)) + (const std::string&, const std::string&, obj.get_first(), obj.set_first(val)) +) + int main() { @@ -132,6 +156,20 @@ main() } { + fusion::vector<std::string, std::string> v1("Lincoln", "Abraham"); + ns::name v2("Roosevelt", "Franklin"); + ns::name v3("Roosevelt", "Theodore"); + BOOST_TEST(v1 < v2); + BOOST_TEST(v1 <= v2); + BOOST_TEST(v2 > v1); + BOOST_TEST(v2 >= v1); + BOOST_TEST(v2 < v3); + BOOST_TEST(v2 <= v3); + BOOST_TEST(v3 > v2); + BOOST_TEST(v3 >= v2); + } + + { // conversion from ns::point to vector ns::point p(5, 3); fusion::vector<int, long> v(p); diff --git a/libs/fusion/test/sequence/adapt_tpl_adt.cpp b/libs/fusion/test/sequence/adapt_tpl_adt.cpp index 2f0d4c6b50..aeb0f72153 100644 --- a/libs/fusion/test/sequence/adapt_tpl_adt.cpp +++ b/libs/fusion/test/sequence/adapt_tpl_adt.cpp @@ -67,6 +67,7 @@ main() using namespace boost::fusion; typedef ns::point<int, int> point; + typedef ns::point<std::string, std::string> name; std::cout << tuple_open('['); std::cout << tuple_close(']'); @@ -107,6 +108,20 @@ main() } { + boost::fusion::vector<std::string, std::string> v1("Lincoln", "Abraham"); + name v2("Roosevelt", "Franklin"); + name v3("Roosevelt", "Theodore"); + BOOST_TEST(v1 < v2); + BOOST_TEST(v1 <= v2); + BOOST_TEST(v2 > v1); + BOOST_TEST(v2 >= v1); + BOOST_TEST(v2 < v3); + BOOST_TEST(v2 <= v3); + BOOST_TEST(v3 > v2); + BOOST_TEST(v3 >= v2); + } + + { // conversion from point to vector point p(5, 3); boost::fusion::vector<int, long> v(p); diff --git a/libs/fusion/test/sequence/io.cpp b/libs/fusion/test/sequence/io.cpp index 00e88b1348..74e0f30cea 100644 --- a/libs/fusion/test/sequence/io.cpp +++ b/libs/fusion/test/sequence/io.cpp @@ -103,7 +103,7 @@ main() useThisIStringStream is("(100 200 300)"); vector<int, int, int> ti; - BOOST_TEST(bool((is >> ti) != 0)); + BOOST_TEST(bool(is >> ti) != 0); BOOST_TEST(ti == make_vector(100, 200, 300)); // Note that strings are problematic: |