format_test1.cpp 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. // ------------------------------------------------------------------------------
  2. // libs/format/test/format_test1.cpp : test constructing objects and basic parsing
  3. // ------------------------------------------------------------------------------
  4. // Copyright Samuel Krempp 2003. Use, modification, and distribution are
  5. // subject to 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. // See http://www.boost.org/libs/format for library home page
  8. // ------------------------------------------------------------------------------
  9. #include <boost/detail/lightweight_test.hpp>
  10. #include <boost/format.hpp>
  11. int main(int, char* [])
  12. {
  13. using boost::format;
  14. using boost::str;
  15. if(str( format(" %% ") ) != " % ")
  16. BOOST_ERROR("Basic parsing without arguments Failed");
  17. if(str( format("nothing") ) != "nothing")
  18. BOOST_ERROR("Basic parsing without arguments Failed");
  19. if(str( format("%% ") ) != "% ")
  20. BOOST_ERROR("Basic parsing without arguments Failed");
  21. if(str( format(" %%") ) != " %")
  22. BOOST_ERROR("Basic parsing without arguments Failed");
  23. if(str( format(" %n ") ) != " ")
  24. BOOST_ERROR("Basic parsing without arguments Failed");
  25. if(str( format("%n ") ) != " ")
  26. BOOST_ERROR("Basic parsing without arguments Failed");
  27. if(str( format(" %n") ) != " ")
  28. BOOST_ERROR("Basic parsing without arguments Failed");
  29. if(str( format("%%##%%##%%1 %1%00") % "Escaped OK" ) != "%##%##%1 Escaped OK00")
  30. BOOST_ERROR("Basic parsing Failed");
  31. if(str( format("%%##%#x ##%%1 %s00") % 20 % "Escaped OK" ) != "%##0x14 ##%1 Escaped OK00")
  32. BOOST_ERROR("Basic p-parsing Failed") ;
  33. return boost::report_errors();
  34. }