From 933654fbae37b3726cfa449d187759fe06f8fcc7 Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Thu, 15 Oct 2020 01:10:15 +0300 Subject: test/ -> test/unit_tests/ --- test/CMakeLists.txt | 13 +------------ test/cmd_line.cpp | 34 ---------------------------------- test/error.cpp | 23 ----------------------- test/handle.cpp | 21 --------------------- test/main.cpp | 7 ------- test/unit_tests/CMakeLists.txt | 12 ++++++++++++ test/unit_tests/cmd_line.cpp | 34 ++++++++++++++++++++++++++++++++++ test/unit_tests/error.cpp | 23 +++++++++++++++++++++++ test/unit_tests/handle.cpp | 21 +++++++++++++++++++++ test/unit_tests/main.cpp | 7 +++++++ 10 files changed, 98 insertions(+), 97 deletions(-) delete mode 100644 test/cmd_line.cpp delete mode 100644 test/error.cpp delete mode 100644 test/handle.cpp delete mode 100644 test/main.cpp create mode 100644 test/unit_tests/CMakeLists.txt create mode 100644 test/unit_tests/cmd_line.cpp create mode 100644 test/unit_tests/error.cpp create mode 100644 test/unit_tests/handle.cpp create mode 100644 test/unit_tests/main.cpp diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 33a6101..bed23ce 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,12 +1 @@ -file(GLOB unit_tests_src "*.cpp") -add_executable(unit_tests ${unit_tests_src}) -target_link_libraries(unit_tests PRIVATE winapi_common) -set_target_properties(unit_tests PROPERTIES OUTPUT_NAME winapi-common-unit-tests) - -find_package(Boost REQUIRED COMPONENTS unit_test_framework) -target_link_libraries(unit_tests PRIVATE Boost::disable_autolinking Boost::unit_test_framework) - -install(TARGETS unit_tests RUNTIME DESTINATION bin) -if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") - install(FILES "$" DESTINATION bin OPTIONAL) -endif() +add_subdirectory(unit_tests) diff --git a/test/cmd_line.cpp b/test/cmd_line.cpp deleted file mode 100644 index 4506304..0000000 --- a/test/cmd_line.cpp +++ /dev/null @@ -1,34 +0,0 @@ -// 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 - -BOOST_AUTO_TEST_SUITE(cmd_line_tests) - -BOOST_AUTO_TEST_CASE(query) { - const auto cmd_line = winapi::CommandLine::query(); - BOOST_TEST(cmd_line.has_argv0()); - BOOST_TEST_MESSAGE(cmd_line.get_argv0()); -} - -BOOST_AUTO_TEST_CASE(escape) { - wchar_t* argv[] = { - L"test.exe", - L"arg1 arg2", - LR"(path\to\file)", - LR"(path\to\dir\)", - LR"(weird\\argument)", - }; - const auto cmd_line = winapi::CommandLine::build_from_main(5, argv); - const auto expected = - R"("test.exe" "arg1 arg2" "path\to\file" "path\to\dir\\" "weird\\argument")"; - BOOST_TEST(cmd_line.join() == expected); -} - -BOOST_AUTO_TEST_SUITE_END() diff --git a/test/error.cpp b/test/error.cpp deleted file mode 100644 index f70d95d..0000000 --- a/test/error.cpp +++ /dev/null @@ -1,23 +0,0 @@ -// 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() diff --git a/test/handle.cpp b/test/handle.cpp deleted file mode 100644 index 13551f4..0000000 --- a/test/handle.cpp +++ /dev/null @@ -1,21 +0,0 @@ -// 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 - -BOOST_AUTO_TEST_SUITE(handle_tests) - -BOOST_AUTO_TEST_CASE(null) { - { winapi::Handle h{NULL}; } - BOOST_TEST(true, "NULL handle closed successfully"); - { winapi::Handle h{INVALID_HANDLE_VALUE}; } - BOOST_TEST(true, "INVALID_HANDLE_VALUE handle closed successfully"); -} - -BOOST_AUTO_TEST_SUITE_END() diff --git a/test/main.cpp b/test/main.cpp deleted file mode 100644 index d7e8d4f..0000000 --- a/test/main.cpp +++ /dev/null @@ -1,7 +0,0 @@ -// 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. - -#define BOOST_TEST_MODULE winapi_common tests -#include diff --git a/test/unit_tests/CMakeLists.txt b/test/unit_tests/CMakeLists.txt new file mode 100644 index 0000000..33a6101 --- /dev/null +++ b/test/unit_tests/CMakeLists.txt @@ -0,0 +1,12 @@ +file(GLOB unit_tests_src "*.cpp") +add_executable(unit_tests ${unit_tests_src}) +target_link_libraries(unit_tests PRIVATE winapi_common) +set_target_properties(unit_tests PROPERTIES OUTPUT_NAME winapi-common-unit-tests) + +find_package(Boost REQUIRED COMPONENTS unit_test_framework) +target_link_libraries(unit_tests PRIVATE Boost::disable_autolinking Boost::unit_test_framework) + +install(TARGETS unit_tests RUNTIME DESTINATION bin) +if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + install(FILES "$" DESTINATION bin OPTIONAL) +endif() diff --git a/test/unit_tests/cmd_line.cpp b/test/unit_tests/cmd_line.cpp new file mode 100644 index 0000000..4506304 --- /dev/null +++ b/test/unit_tests/cmd_line.cpp @@ -0,0 +1,34 @@ +// 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 + +BOOST_AUTO_TEST_SUITE(cmd_line_tests) + +BOOST_AUTO_TEST_CASE(query) { + const auto cmd_line = winapi::CommandLine::query(); + BOOST_TEST(cmd_line.has_argv0()); + BOOST_TEST_MESSAGE(cmd_line.get_argv0()); +} + +BOOST_AUTO_TEST_CASE(escape) { + wchar_t* argv[] = { + L"test.exe", + L"arg1 arg2", + LR"(path\to\file)", + LR"(path\to\dir\)", + LR"(weird\\argument)", + }; + const auto cmd_line = winapi::CommandLine::build_from_main(5, argv); + const auto expected = + R"("test.exe" "arg1 arg2" "path\to\file" "path\to\dir\\" "weird\\argument")"; + BOOST_TEST(cmd_line.join() == expected); +} + +BOOST_AUTO_TEST_SUITE_END() diff --git a/test/unit_tests/error.cpp b/test/unit_tests/error.cpp new file mode 100644 index 0000000..f70d95d --- /dev/null +++ b/test/unit_tests/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() diff --git a/test/unit_tests/handle.cpp b/test/unit_tests/handle.cpp new file mode 100644 index 0000000..13551f4 --- /dev/null +++ b/test/unit_tests/handle.cpp @@ -0,0 +1,21 @@ +// 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 + +BOOST_AUTO_TEST_SUITE(handle_tests) + +BOOST_AUTO_TEST_CASE(null) { + { winapi::Handle h{NULL}; } + BOOST_TEST(true, "NULL handle closed successfully"); + { winapi::Handle h{INVALID_HANDLE_VALUE}; } + BOOST_TEST(true, "INVALID_HANDLE_VALUE handle closed successfully"); +} + +BOOST_AUTO_TEST_SUITE_END() diff --git a/test/unit_tests/main.cpp b/test/unit_tests/main.cpp new file mode 100644 index 0000000..d7e8d4f --- /dev/null +++ b/test/unit_tests/main.cpp @@ -0,0 +1,7 @@ +// 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. + +#define BOOST_TEST_MODULE winapi_common tests +#include -- cgit v1.2.3