windows_error.cpp 888 B

123456789101112131415161718192021222324252627282930313233
  1. #include<__vic/windows/error.h>
  2. #include<__vic/string_utils.h>
  3. #include<windows.h>
  4. #include<iostream>
  5. #include<exception>
  6. #include<cassert>
  7. void run_tests()
  8. {
  9. __vic::windows::error ex1("Out of memory", ERROR_OUTOFMEMORY);
  10. std::cout << ex1.what() << '\n'; assert(!__vic::ends_with(ex1.what(), " \t\r\n"));
  11. __vic::windows::error ex2(ERROR_INVALID_FUNCTION);
  12. std::cout << ex2.what() << '\n'; assert(!__vic::ends_with(ex2.what(), " \t\r\n"));
  13. __vic::windows::error ex3("Current error");
  14. std::cout << ex3.what() << '\n'; assert(!__vic::ends_with(ex3.what(), " \t\r\n"));
  15. __vic::windows::error ex4;
  16. std::cout << ex4.what() << '\n'; assert(!__vic::ends_with(ex4.what(), " \t\r\n"));
  17. }
  18. int main()
  19. {
  20. try
  21. {
  22. run_tests();
  23. return 0;
  24. }
  25. catch(const std::exception &ex)
  26. {
  27. std::cerr << ex.what() << '\n';
  28. }
  29. return 1;
  30. }