progress_display_test.cpp 1014 B

12345678910111213141516171819202122232425262728293031323334353637
  1. // Copyright 2019 Peter Dimov.
  2. // Distributed under the Boost Software License, Version 1.0.
  3. #include <boost/timer/progress_display.hpp>
  4. #include <boost/core/lightweight_test.hpp>
  5. #include <sstream>
  6. #include <cstddef>
  7. int main()
  8. {
  9. int n = 17;
  10. std::ostringstream os;
  11. boost::timer::progress_display pd( n, os, "L1:", "L2:", "L3:" );
  12. BOOST_TEST_EQ( os.str(), std::string(
  13. "L1:0% 10 20 30 40 50 60 70 80 90 100%\n"
  14. "L2:|----|----|----|----|----|----|----|----|----|----|\n"
  15. "L3:" ) );
  16. for( int i = 0; i < n; ++i )
  17. {
  18. std::size_t m1 = os.str().size();
  19. ++pd;
  20. std::size_t m2 = os.str().size();
  21. BOOST_TEST_LE( m1, m2 );
  22. }
  23. BOOST_TEST_EQ( os.str(), std::string(
  24. "L1:0% 10 20 30 40 50 60 70 80 90 100%\n"
  25. "L2:|----|----|----|----|----|----|----|----|----|----|\n"
  26. "L3:***************************************************\n" ) );
  27. return boost::report_errors();
  28. }