From ebb80e5da4811166268bd943b67e2875eb1e33e4 Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Sun, 4 Oct 2020 11:05:07 +0300 Subject: clang-format formatting fixes --- .clang-format | 4 +++- include/winapi/utf8.hpp | 2 +- src/convert.cpp | 13 ++++++------- test/convert.cpp | 14 ++++---------- test/string.cpp | 2 +- 5 files changed, 15 insertions(+), 20 deletions(-) diff --git a/.clang-format b/.clang-format index 3b07efb..bf44ecc 100644 --- a/.clang-format +++ b/.clang-format @@ -15,6 +15,8 @@ IncludeCategories: Priority: 2 - Regex: '^$' Priority: 4 + - Regex: '.*' + Priority: 5 ... diff --git a/include/winapi/utf8.hpp b/include/winapi/utf8.hpp index 1eb6963..57b3c53 100644 --- a/include/winapi/utf8.hpp +++ b/include/winapi/utf8.hpp @@ -19,4 +19,4 @@ std::string narrow(const std::wstring&); std::string narrow(const std::vector&); std::string narrow(const void*, std::size_t nb); -} +} // namespace winapi diff --git a/src/convert.cpp b/src/convert.cpp index 6f4f400..33b3222 100644 --- a/src/convert.cpp +++ b/src/convert.cpp @@ -22,7 +22,7 @@ std::runtime_error error(const char* function, DWORD code) { return std::runtime_error{oss.str()}; } -} +} // namespace std::wstring widen(const std::string& src) { return widen(src.c_str(), src.size()); @@ -33,8 +33,7 @@ std::wstring widen(const std::vector& src) { } std::wstring widen(const void* src, std::size_t in_nb) { - const DWORD flags = MB_ERR_INVALID_CHARS - | MB_PRECOMPOSED; + const DWORD flags = MB_ERR_INVALID_CHARS | MB_PRECOMPOSED; const char* in_data = reinterpret_cast(src); @@ -75,8 +74,7 @@ std::string narrow(const void* src, std::size_t in_nb) { const std::size_t in_nch = in_nb / sizeof(WCHAR); - const DWORD flags = WC_ERR_INVALID_CHARS - | WC_NO_BEST_FIT_CHARS; + const DWORD flags = WC_ERR_INVALID_CHARS | WC_NO_BEST_FIT_CHARS; const wchar_t* in_data = reinterpret_cast(src); @@ -89,7 +87,8 @@ std::string narrow(const void* src, std::size_t in_nb) { std::vector out; out.resize(out_nb); - out_nb = ::WideCharToMultiByte(CP_UTF8, flags, in_data, in_nch, out.data(), out.size(), NULL, NULL); + out_nb = + ::WideCharToMultiByte(CP_UTF8, flags, in_data, in_nch, out.data(), out.size(), NULL, NULL); if (out_nb == 0) { throw error("WideCharToMultiByte", GetLastError()); @@ -98,4 +97,4 @@ std::string narrow(const void* src, std::size_t in_nb) { return {out.data(), out.size()}; } -} +} // namespace winapi diff --git a/test/convert.cpp b/test/convert.cpp index abd7173..21882c3 100644 --- a/test/convert.cpp +++ b/test/convert.cpp @@ -27,7 +27,7 @@ ostream& operator<<(ostream& os, const vector& cs) { return os; } -} +} // namespace std namespace { @@ -56,24 +56,18 @@ std::vector> utf8 = { from({0xd0, 0x9f, 0xd1, 0x80, 0xd0, 0xb8, 0xd0, 0xb2, 0xd0, 0xb5, 0xd1, 0x82}), }; -} +} // namespace BOOST_TEST_SPECIALIZED_COLLECTION_COMPARE(std::vector); BOOST_AUTO_TEST_SUITE(convert_tests) -BOOST_DATA_TEST_CASE(test_narrow, - boost::unit_test::data::make(utf16) ^ utf8, - input, - expected) { +BOOST_DATA_TEST_CASE(test_narrow, boost::unit_test::data::make(utf16) ^ utf8, input, expected) { auto actual = from(winapi::narrow(input)); BOOST_TEST(actual == expected, "Expected: " << expected << ", actual: " << actual); } -BOOST_DATA_TEST_CASE(test_widen, - boost::unit_test::data::make(utf8) ^ utf16, - input, - expected) { +BOOST_DATA_TEST_CASE(test_widen, boost::unit_test::data::make(utf8) ^ utf16, input, expected) { auto actual = from(winapi::widen(input)); BOOST_TEST(actual == expected, "Expected: " << expected << ", actual: " << actual); } diff --git a/test/string.cpp b/test/string.cpp index d5e7b3e..010a86f 100644 --- a/test/string.cpp +++ b/test/string.cpp @@ -28,7 +28,7 @@ std::wstring convert(const wchar_t* src) { return std::wstring{src}; } -} +} // namespace BOOST_AUTO_TEST_SUITE(string_tests) -- cgit v1.2.3