generic_category_test.cpp 890 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. // Copyright 2018 Peter Dimov.
  2. //
  3. // Distributed under the Boost Software License, Version 1.0.
  4. //
  5. // See accompanying file LICENSE_1_0.txt or copy at
  6. // http://www.boost.org/LICENSE_1_0.txt
  7. // See library home page at http://www.boost.org/libs/system
  8. // Avoid spurious VC++ warnings
  9. # define _CRT_SECURE_NO_WARNINGS
  10. #include <boost/system/error_code.hpp>
  11. #include <boost/core/lightweight_test.hpp>
  12. #include <cstring>
  13. //
  14. namespace sys = boost::system;
  15. int main()
  16. {
  17. sys::error_category const & cat = sys::generic_category();
  18. // message
  19. for( int i = -2; i < 1024; ++i )
  20. {
  21. {
  22. BOOST_TEST_CSTR_EQ( cat.message( i ).c_str(), std::strerror( i ) );
  23. }
  24. {
  25. char buffer[ 256 ];
  26. BOOST_TEST_CSTR_EQ( cat.message( i, buffer, sizeof( buffer ) ), std::strerror( i ) );
  27. }
  28. }
  29. return boost::report_errors();
  30. }