test: fix compiler warnings in test directory (#302)

This commit is contained in:
Alois Klink 2023-09-01 08:22:50 +01:00 committed by GitHub
parent 8830320c60
commit 683883b08a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 12 additions and 12 deletions

View File

@ -28,7 +28,7 @@ void listen(uvw::loop &loop) {
std::cout << "remote: " << remote.ip << " " << remote.port << std::endl; std::cout << "remote: " << remote.ip << " " << remote.port << std::endl;
client->on<uvw::data_event>([](const uvw::data_event &event, uvw::tcp_handle &) { client->on<uvw::data_event>([](const uvw::data_event &event, uvw::tcp_handle &) {
std::cout.write(event.data.get(), event.length) << std::endl; std::cout.write(event.data.get(), static_cast<std::streamsize>(event.length)) << std::endl;
std::cout << "data length: " << event.length << std::endl; std::cout << "data length: " << event.length << std::endl;
}); });
@ -65,7 +65,7 @@ void conn(uvw::loop &loop) {
auto dataTryWrite = std::unique_ptr<char[]>(new char[1]{'a'}); auto dataTryWrite = std::unique_ptr<char[]>(new char[1]{'a'});
int bw = handle.try_write(std::move(dataTryWrite), 1); int bw = handle.try_write(std::move(dataTryWrite), 1);
std::cout << "written: " << ((int)bw) << std::endl; std::cout << "written: " << static_cast<int>(bw) << std::endl;
auto dataWrite = std::unique_ptr<char[]>(new char[2]{'b', 'c'}); auto dataWrite = std::unique_ptr<char[]>(new char[2]{'b', 'c'});
handle.write(std::move(dataWrite), 2); handle.write(std::move(dataWrite), 2);

View File

@ -107,7 +107,7 @@ TEST(FsReq, Stat) {
fsReq->on<uvw::error_event>([](const auto &, auto &) { FAIL(); }); fsReq->on<uvw::error_event>([](const auto &, auto &) { FAIL(); });
fileReq->on<uvw::error_event>([](const auto &, auto &) { FAIL(); }); fileReq->on<uvw::error_event>([](const auto &, auto &) { FAIL(); });
fsReq->on<uvw::fs_event>([&](const auto &event, auto &req) { fsReq->on<uvw::fs_event>([&](const auto &event, auto &) {
if(event.type == uvw::fs_req::fs_type::STAT) { if(event.type == uvw::fs_req::fs_type::STAT) {
ASSERT_FALSE(checkFsStatEvent); ASSERT_FALSE(checkFsStatEvent);
checkFsStatEvent = true; checkFsStatEvent = true;
@ -160,7 +160,7 @@ TEST(FsReq, Lstat) {
fsReq->on<uvw::error_event>([](const auto &, auto &) { FAIL(); }); fsReq->on<uvw::error_event>([](const auto &, auto &) { FAIL(); });
fileReq->on<uvw::error_event>([](const auto &, auto &) { FAIL(); }); fileReq->on<uvw::error_event>([](const auto &, auto &) { FAIL(); });
fsReq->on<uvw::fs_event>([&](const auto &event, auto &req) { fsReq->on<uvw::fs_event>([&](const auto &event, auto &) {
if(event.type == uvw::fs_req::fs_type::LSTAT) { if(event.type == uvw::fs_req::fs_type::LSTAT) {
ASSERT_FALSE(checkFsLstatEvent); ASSERT_FALSE(checkFsLstatEvent);
checkFsLstatEvent = true; checkFsLstatEvent = true;
@ -214,7 +214,7 @@ TEST(FsReq, Rename) {
fsReq->on<uvw::error_event>([](const auto &, auto &) { FAIL(); }); fsReq->on<uvw::error_event>([](const auto &, auto &) { FAIL(); });
fileReq->on<uvw::error_event>([](const auto &, auto &) { FAIL(); }); fileReq->on<uvw::error_event>([](const auto &, auto &) { FAIL(); });
fsReq->on<uvw::fs_event>([&](const auto &event, auto &req) { fsReq->on<uvw::fs_event>([&](const auto &event, auto &) {
if(event.type == uvw::fs_req::fs_type::RENAME) { if(event.type == uvw::fs_req::fs_type::RENAME) {
ASSERT_FALSE(checkFsRenameEvent); ASSERT_FALSE(checkFsRenameEvent);
checkFsRenameEvent = true; checkFsRenameEvent = true;
@ -265,7 +265,7 @@ TEST(FsReq, Access) {
fsReq->on<uvw::error_event>([](const auto &, auto &) { FAIL(); }); fsReq->on<uvw::error_event>([](const auto &, auto &) { FAIL(); });
fileReq->on<uvw::error_event>([](const auto &, auto &) { FAIL(); }); fileReq->on<uvw::error_event>([](const auto &, auto &) { FAIL(); });
fsReq->on<uvw::fs_event>([&](const auto &event, auto &req) { fsReq->on<uvw::fs_event>([&](const auto &event, auto &) {
if(event.type == uvw::fs_req::fs_type::ACCESS) { if(event.type == uvw::fs_req::fs_type::ACCESS) {
ASSERT_FALSE(checkFsAccessEvent); ASSERT_FALSE(checkFsAccessEvent);
checkFsAccessEvent = true; checkFsAccessEvent = true;
@ -315,7 +315,7 @@ TEST(FsReq, Chmod) {
fsReq->on<uvw::error_event>([](const auto &, auto &) { FAIL(); }); fsReq->on<uvw::error_event>([](const auto &, auto &) { FAIL(); });
fileReq->on<uvw::error_event>([](const auto &, auto &) { FAIL(); }); fileReq->on<uvw::error_event>([](const auto &, auto &) { FAIL(); });
fsReq->on<uvw::fs_event>([&](const auto &event, auto &req) { fsReq->on<uvw::fs_event>([&](const auto &event, auto &) {
if(event.type == uvw::fs_req::fs_type::CHMOD) { if(event.type == uvw::fs_req::fs_type::CHMOD) {
ASSERT_FALSE(checkFsChmodEvent); ASSERT_FALSE(checkFsChmodEvent);
checkFsChmodEvent = true; checkFsChmodEvent = true;
@ -365,7 +365,7 @@ TEST(FsReq, Utime) {
fsReq->on<uvw::error_event>([](const auto &, auto &) { FAIL(); }); fsReq->on<uvw::error_event>([](const auto &, auto &) { FAIL(); });
fileReq->on<uvw::error_event>([](const auto &, auto &) { FAIL(); }); fileReq->on<uvw::error_event>([](const auto &, auto &) { FAIL(); });
fsReq->on<uvw::fs_event>([&](const auto &event, auto &req) { fsReq->on<uvw::fs_event>([&](const auto &event, auto &) {
if(event.type == uvw::fs_req::fs_type::UTIME) { if(event.type == uvw::fs_req::fs_type::UTIME) {
ASSERT_FALSE(checkFsUtimeEvent); ASSERT_FALSE(checkFsUtimeEvent);
checkFsUtimeEvent = true; checkFsUtimeEvent = true;
@ -600,7 +600,7 @@ TEST(FsReq, Realpath) {
fsReq->on<uvw::error_event>([](const auto &, auto &) { FAIL(); }); fsReq->on<uvw::error_event>([](const auto &, auto &) { FAIL(); });
fileReq->on<uvw::error_event>([](const auto &, auto &) { FAIL(); }); fileReq->on<uvw::error_event>([](const auto &, auto &) { FAIL(); });
fsReq->on<uvw::fs_event>([&](const auto &event, auto &req) { fsReq->on<uvw::fs_event>([&](const auto &event, auto &) {
if(event.type == uvw::fs_req::fs_type::REALPATH) { if(event.type == uvw::fs_req::fs_type::REALPATH) {
ASSERT_FALSE(checkFsRealpathEvent); ASSERT_FALSE(checkFsRealpathEvent);
ASSERT_NE(event.path, nullptr); ASSERT_NE(event.path, nullptr);

View File

@ -88,7 +88,7 @@ TEST(Loop, Walk) {
ASSERT_EQ(count, 12u); ASSERT_EQ(count, 12u);
loop->run(); loop->run();
loop->walk([&count](auto &handle) { --count; }); loop->walk([&count](auto &) { --count; });
ASSERT_EQ(count, 12u); ASSERT_EQ(count, 12u);

View File

@ -5,8 +5,8 @@ TEST(Thread, Run) {
auto loop = uvw::loop::get_default(); auto loop = uvw::loop::get_default();
auto has_run = std::make_shared<bool>(); auto has_run = std::make_shared<bool>();
auto cb = [](std::shared_ptr<void> data) { auto cb = [](std::shared_ptr<void> data) {
if(auto has_run = std::static_pointer_cast<bool>(data); has_run) { if(auto has_run_ptr = std::static_pointer_cast<bool>(data); has_run_ptr) {
*has_run = true; *has_run_ptr = true;
} }
}; };