From 8fe642b86c85ec45f27424108d7a5d6fae25fe25 Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Wed, 14 Oct 2020 03:10:23 +0300 Subject: add error-handling functions They are almost exact copies from my pdb-repo project at https://github.com/egor-tensin/pdb-repo/tree/fa2afec5e7af45e7f1440b2d32c2a4e63dad6a62 I'm currently thinking about renaming it to winapi-debug BTW. --- test/CMakeLists.txt | 2 +- test/error.cpp | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 test/error.cpp (limited to 'test') diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 3c23426..4c09bcd 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,6 +1,6 @@ find_package(Boost REQUIRED COMPONENTS unit_test_framework) -add_executable(unit_tests main.cpp handle.cpp) +add_executable(unit_tests main.cpp error.cpp handle.cpp) target_link_libraries(unit_tests PRIVATE winapi_common) target_link_libraries(unit_tests PRIVATE Boost::disable_autolinking Boost::unit_test_framework) set_target_properties(unit_tests PROPERTIES OUTPUT_NAME winapi-common-unit-tests) diff --git a/test/error.cpp b/test/error.cpp new file mode 100644 index 0000000..f70d95d --- /dev/null +++ b/test/error.cpp @@ -0,0 +1,23 @@ +// Copyright (c) 2020 Egor Tensin +// This file is part of the "winapi-common" project. +// For details, see https://github.com/egor-tensin/winapi-common. +// Distributed under the MIT License. + +#include + +#include + +#include + +#include + +BOOST_AUTO_TEST_SUITE(error_tests) + +BOOST_AUTO_TEST_CASE(file_not_found) { + const std::string actual{winapi::error::windows(ERROR_FILE_NOT_FOUND, "CreateFileW").what()}; + BOOST_TEST(actual == + "Function CreateFileW failed with error code 2: The system cannot find the file " + "specified."); +} + +BOOST_AUTO_TEST_SUITE_END() -- cgit v1.2.3