std_single_instance_test.cpp 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. // Copyright 2019 Peter Dimov.
  2. // Distributed under the Boost Software License, Version 1.0.
  3. #include <boost/system/error_code.hpp>
  4. #include <boost/config/pragma_message.hpp>
  5. #include <boost/config/helper_macros.hpp>
  6. #if !defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
  7. BOOST_PRAGMA_MESSAGE( "BOOST_SYSTEM_HAS_SYSTEM_ERROR not defined, test will be skipped" )
  8. int main() {}
  9. #elif defined(STD_SINGLE_INSTANCE_SHARED) && defined(__CYGWIN__)
  10. BOOST_PRAGMA_MESSAGE( "Skipping Windows/DLL test, __CYGWIN__" )
  11. int main() {}
  12. #elif defined(STD_SINGLE_INSTANCE_SHARED) && defined(_WIN32) && !defined(_MSC_VER)
  13. BOOST_PRAGMA_MESSAGE( "Skipping Windows/DLL test, no _MSC_VER" )
  14. int main() {}
  15. #elif defined(STD_SINGLE_INSTANCE_SHARED) && defined(_WIN32) && !defined(_CPPLIB_VER)
  16. BOOST_PRAGMA_MESSAGE( "Skipping Windows/DLL test, no _CPPLIB_VER" )
  17. int main() {}
  18. #elif defined(STD_SINGLE_INSTANCE_SHARED) && defined(_WIN32) && (_MSC_VER < 1900 || _MSC_VER >= 2000)
  19. BOOST_PRAGMA_MESSAGE( "Skipping Windows/DLL test, _MSC_VER is " BOOST_STRINGIZE(_MSC_VER) )
  20. int main() {}
  21. #else
  22. #include <boost/core/lightweight_test.hpp>
  23. #include <system_error>
  24. using namespace boost::system;
  25. namespace lib1
  26. {
  27. std::error_code get_system_code();
  28. std::error_code get_generic_code();
  29. } // namespace lib1
  30. namespace lib2
  31. {
  32. std::error_code get_system_code();
  33. std::error_code get_generic_code();
  34. } // namespace lib2
  35. int main()
  36. {
  37. {
  38. std::error_code e1 = lib1::get_system_code();
  39. std::error_code e2 = lib2::get_system_code();
  40. BOOST_TEST_EQ( e1, e2 );
  41. }
  42. {
  43. std::error_code e1 = lib1::get_generic_code();
  44. std::error_code e2 = lib2::get_generic_code();
  45. BOOST_TEST_EQ( e1, e2 );
  46. }
  47. return boost::report_errors();
  48. }
  49. #endif