aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2020-10-04 11:05:07 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2020-10-04 11:05:07 +0300
commitebb80e5da4811166268bd943b67e2875eb1e33e4 (patch)
treeab5a29152be117be5f03074c43d425d3c8b6765a
parentadd AppVeyor configuration (diff)
downloadwinapi-utf8-ebb80e5da4811166268bd943b67e2875eb1e33e4.tar.gz
winapi-utf8-ebb80e5da4811166268bd943b67e2875eb1e33e4.zip
clang-format formatting fixes
Diffstat (limited to '')
-rw-r--r--.clang-format4
-rw-r--r--include/winapi/utf8.hpp2
-rw-r--r--src/convert.cpp13
-rw-r--r--test/convert.cpp14
-rw-r--r--test/string.cpp2
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: '^<boost/'
Priority: 3
- - Regex: '.*'
+ - Regex: '^<.*\.h>$'
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<unsigned char>&);
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<unsigned char>& 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<const char*>(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<const wchar_t*>(src);
@@ -89,7 +87,8 @@ std::string narrow(const void* src, std::size_t in_nb) {
std::vector<char> 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<unsigned char>& cs) {
return os;
}
-}
+} // namespace std
namespace {
@@ -56,24 +56,18 @@ std::vector<std::vector<unsigned char>> utf8 = {
from({0xd0, 0x9f, 0xd1, 0x80, 0xd0, 0xb8, 0xd0, 0xb2, 0xd0, 0xb5, 0xd1, 0x82}),
};
-}
+} // namespace
BOOST_TEST_SPECIALIZED_COLLECTION_COMPARE(std::vector<unsigned char>);
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)