regression_float_fraction.cpp 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. /*=============================================================================
  2. Copyright (c) 2001-2011 Joel de Guzman
  3. Copyright (c) 2001-2011 Hartmut Kaiser
  4. Copyright (c) 2011 Bryce Lelbach
  5. Use, modification and distribution is subject to the Boost Software
  6. License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  7. http://www.boost.org/LICENSE_1_0.txt)
  8. =============================================================================*/
  9. #include <boost/detail/lightweight_test.hpp>
  10. #include <boost/spirit/include/qi_numeric.hpp>
  11. #include "test.hpp"
  12. int
  13. main()
  14. {
  15. using spirit_test::test_attr;
  16. using boost::spirit::qi::float_;
  17. std::cerr.precision(9);
  18. float f = 0.0f;
  19. // this should pass, but currently doesn't because of the way the real
  20. // parser handles the fractional part of a number
  21. BOOST_TEST(test_attr("123233.4124", float_, f));
  22. BOOST_TEST_EQ(f, 123233.4124f);
  23. BOOST_TEST(test_attr("987654.3219", float_, f));
  24. BOOST_TEST_EQ(f, 987654.3219f);
  25. return boost::report_errors();
  26. }