// Copyright Abel Sinkovics (abel@sinkovics.hu) 2012. // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) #define BOOST_TEST_MODULE string #define BOOST_METAPARSE_LIMIT_STRING_SIZE 64 #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include BOOST_AUTO_TEST_CASE(test_string) { using boost::mpl::equal; using boost::mpl::equal_to; using boost::mpl::char_; using boost::mpl::int_; using boost::mpl::at; using boost::mpl::at_c; using boost::mpl::size; using boost::mpl::back; using boost::mpl::deref; using boost::mpl::advance; using boost::mpl::next; using boost::mpl::prior; using boost::mpl::distance; using boost::mpl::clear; using boost::mpl::empty; using boost::mpl::front; using boost::mpl::is_sequence; using boost::mpl::pop_front; using boost::mpl::pop_back; using boost::mpl::begin; using boost::mpl::end; using boost::mpl::c_str; using boost::mpl::push_front; using boost::mpl::push_back; using namespace boost; // string type /////////////////////// typedef metaparse::string<'H','e','l','l','o'> hello; typedef metaparse::string<> empty_string; typedef begin::type begin_hello; typedef end::type end_hello; // test_value_of_empty_string BOOST_REQUIRE_EQUAL(std::string(), c_str::type::value); // test_value BOOST_REQUIRE_EQUAL(std::string("Hello"), c_str::type::value); // equal_to BOOST_MPL_ASSERT((equal_to)); BOOST_MPL_ASSERT_NOT((equal_to)); // at BOOST_MPL_ASSERT((equal_to, at >::type>)); BOOST_MPL_ASSERT((equal_to, at_c::type>)); // size BOOST_MPL_ASSERT((equal_to, size::type>)); // is_sequence BOOST_MPL_ASSERT((is_sequence)); // front BOOST_MPL_ASSERT((equal_to, front::type>)); // push_front BOOST_MPL_ASSERT(( equal_to< metaparse::string<'x','H','e','l','l','o'>, push_front >::type > )); // back BOOST_MPL_ASSERT((equal_to, back::type>)); // push_back BOOST_MPL_ASSERT(( equal_to< metaparse::string<'H','e','l','l','o', 'x'>, push_back >::type > )); // clear BOOST_MPL_ASSERT((equal_to::type>)); // empty BOOST_MPL_ASSERT_NOT((empty::type)); BOOST_MPL_ASSERT((empty::type)); // string_iterator BOOST_MPL_ASSERT((equal_to)); BOOST_MPL_ASSERT_NOT((equal_to)); BOOST_MPL_ASSERT(( equal_to::type, end::type> )); BOOST_MPL_ASSERT((equal_to, deref::type>)); BOOST_MPL_ASSERT((equal_to >::type>)); BOOST_MPL_ASSERT(( equal_to, deref::type>::type> )); BOOST_MPL_ASSERT((equal_to, deref::type>::type>)); BOOST_MPL_ASSERT((equal_to, distance::type>)); // pop_front BOOST_MPL_ASSERT(( equal_to, pop_front::type> )); // pop_back BOOST_MPL_ASSERT(( equal_to, pop_back::type> )); #if BOOST_METAPARSE_STD >= 2011 // BOOST_METAPARSE_STRING macro /////////////////////// // test_empty_string BOOST_MPL_ASSERT((equal)); // test_string_creation BOOST_MPL_ASSERT((equal)); #endif }