BOOST_METAPARSE_STRING.cpp 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. // Copyright Abel Sinkovics (abel@sinkovics.hu) 2016.
  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. #define BOOST_METAPARSE_LIMIT_STRING_SIZE 4
  6. #include <boost/type_traits/is_same.hpp>
  7. #include "common.hpp"
  8. #include "test_case.hpp"
  9. #include "string_macros.hpp"
  10. #include <boost/metaparse/string.hpp>
  11. #ifndef BOOST_METAPARSE_V1_CONFIG_NO_BOOST_METAPARSE_STRING
  12. using boost::metaparse::string;
  13. using boost::is_same;
  14. BOOST_METAPARSE_TEST_CASE(string_macro)
  15. {
  16. BOOST_MPL_ASSERT((
  17. is_same<string<'a', 'b', 'c', 'd'>, BOOST_METAPARSE_STRING("abcd")>
  18. ));
  19. }
  20. #undef BOOST_METAPARSE_LIMIT_STRING_SIZE
  21. #define BOOST_METAPARSE_LIMIT_STRING_SIZE 8
  22. BOOST_METAPARSE_TEST_CASE(string_macro_redefined_length_limit)
  23. {
  24. BOOST_MPL_ASSERT((
  25. is_same<string<'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'>,
  26. BOOST_METAPARSE_STRING("abcdefgh")>
  27. ));
  28. }
  29. #undef BOOST_METAPARSE_LIMIT_STRING_SIZE
  30. #define BOOST_METAPARSE_LIMIT_STRING_SIZE 127
  31. BOOST_METAPARSE_TEST_CASE(creating_long_string_with_macro)
  32. {
  33. BOOST_MPL_ASSERT((
  34. is_same<
  35. string<
  36. BOOST_METAPARSE_TEST_CHARS_100,
  37. BOOST_METAPARSE_TEST_CHARS_10,
  38. BOOST_METAPARSE_TEST_CHARS_10,
  39. '0', '1', '2', '3', '4', '5', '6'
  40. >,
  41. BOOST_METAPARSE_STRING(
  42. BOOST_METAPARSE_TEST_STRING_100
  43. BOOST_METAPARSE_TEST_STRING_10
  44. BOOST_METAPARSE_TEST_STRING_10
  45. "0123456"
  46. )
  47. >
  48. ));
  49. }
  50. #endif