From 3eec1310829f6ec7f3c40a35d5991b0ebbf273b5 Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Sun, 18 Oct 2020 00:11:25 +0300 Subject: Process: add methods to load resource strings --- test/unit_tests/resource.cpp | 57 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 test/unit_tests/resource.cpp (limited to 'test/unit_tests/resource.cpp') diff --git a/test/unit_tests/resource.cpp b/test/unit_tests/resource.cpp new file mode 100644 index 0000000..894edca --- /dev/null +++ b/test/unit_tests/resource.cpp @@ -0,0 +1,57 @@ +// 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 "resource_ids.h" + +#include +#include + +#include +#include +#include + +using namespace winapi; + +#include +#include + +namespace std { + +ostream& operator<<(ostream& os, unsigned char c) { + return os << boost::format("%|1$02x|") % static_cast(c); +} + +ostream& operator<<(ostream& os, const vector& cs) { + for (auto c : cs) { + os << c; + } + return os; +} + +} // namespace std + +BOOST_TEST_SPECIALIZED_COLLECTION_COMPARE(Buffer); + +BOOST_AUTO_TEST_SUITE(resource_tests) + +BOOST_AUTO_TEST_CASE(get_string) { + BOOST_STATIC_CONSTEXPR auto expected = "This is a test resource string!"; + const auto actual = Process::get_resource_string(IDS_TEST_STRING); + BOOST_TEST(actual == expected); +} + +BOOST_AUTO_TEST_CASE(get_string_wide) { + BOOST_STATIC_CONSTEXPR auto expected = "This is another test string, wide this time."; + const auto actual = Process::get_resource_string(IDS_TEST_STRING_WIDE); + BOOST_TEST(actual == expected); +} + +BOOST_AUTO_TEST_CASE(get_data) { + static const Buffer expected{0xde, 0xad, 0xbe, 0xef}; + const auto actual = Process::get_resource(ID_TEST_DATA).copy(); + BOOST_TEST(actual == expected); +} + +BOOST_AUTO_TEST_SUITE_END() -- cgit v1.2.3