From 683883b08a6fdf19edc48d99ac1b901924a574cd Mon Sep 17 00:00:00 2001 From: Alois Klink Date: Fri, 1 Sep 2023 08:22:50 +0100 Subject: [PATCH] test: fix compiler warnings in `test` directory (#302) --- test/main.cpp | 4 ++-- test/uvw/fs_req.cpp | 14 +++++++------- test/uvw/loop.cpp | 2 +- test/uvw/thread.cpp | 4 ++-- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/test/main.cpp b/test/main.cpp index 383d3e08..52ac4471 100644 --- a/test/main.cpp +++ b/test/main.cpp @@ -28,7 +28,7 @@ void listen(uvw::loop &loop) { std::cout << "remote: " << remote.ip << " " << remote.port << std::endl; client->on([](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(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(new char[1]{'a'}); int bw = handle.try_write(std::move(dataTryWrite), 1); - std::cout << "written: " << ((int)bw) << std::endl; + std::cout << "written: " << static_cast(bw) << std::endl; auto dataWrite = std::unique_ptr(new char[2]{'b', 'c'}); handle.write(std::move(dataWrite), 2); diff --git a/test/uvw/fs_req.cpp b/test/uvw/fs_req.cpp index bc64262c..854e2271 100644 --- a/test/uvw/fs_req.cpp +++ b/test/uvw/fs_req.cpp @@ -107,7 +107,7 @@ TEST(FsReq, Stat) { fsReq->on([](const auto &, auto &) { FAIL(); }); fileReq->on([](const auto &, auto &) { FAIL(); }); - fsReq->on([&](const auto &event, auto &req) { + fsReq->on([&](const auto &event, auto &) { if(event.type == uvw::fs_req::fs_type::STAT) { ASSERT_FALSE(checkFsStatEvent); checkFsStatEvent = true; @@ -160,7 +160,7 @@ TEST(FsReq, Lstat) { fsReq->on([](const auto &, auto &) { FAIL(); }); fileReq->on([](const auto &, auto &) { FAIL(); }); - fsReq->on([&](const auto &event, auto &req) { + fsReq->on([&](const auto &event, auto &) { if(event.type == uvw::fs_req::fs_type::LSTAT) { ASSERT_FALSE(checkFsLstatEvent); checkFsLstatEvent = true; @@ -214,7 +214,7 @@ TEST(FsReq, Rename) { fsReq->on([](const auto &, auto &) { FAIL(); }); fileReq->on([](const auto &, auto &) { FAIL(); }); - fsReq->on([&](const auto &event, auto &req) { + fsReq->on([&](const auto &event, auto &) { if(event.type == uvw::fs_req::fs_type::RENAME) { ASSERT_FALSE(checkFsRenameEvent); checkFsRenameEvent = true; @@ -265,7 +265,7 @@ TEST(FsReq, Access) { fsReq->on([](const auto &, auto &) { FAIL(); }); fileReq->on([](const auto &, auto &) { FAIL(); }); - fsReq->on([&](const auto &event, auto &req) { + fsReq->on([&](const auto &event, auto &) { if(event.type == uvw::fs_req::fs_type::ACCESS) { ASSERT_FALSE(checkFsAccessEvent); checkFsAccessEvent = true; @@ -315,7 +315,7 @@ TEST(FsReq, Chmod) { fsReq->on([](const auto &, auto &) { FAIL(); }); fileReq->on([](const auto &, auto &) { FAIL(); }); - fsReq->on([&](const auto &event, auto &req) { + fsReq->on([&](const auto &event, auto &) { if(event.type == uvw::fs_req::fs_type::CHMOD) { ASSERT_FALSE(checkFsChmodEvent); checkFsChmodEvent = true; @@ -365,7 +365,7 @@ TEST(FsReq, Utime) { fsReq->on([](const auto &, auto &) { FAIL(); }); fileReq->on([](const auto &, auto &) { FAIL(); }); - fsReq->on([&](const auto &event, auto &req) { + fsReq->on([&](const auto &event, auto &) { if(event.type == uvw::fs_req::fs_type::UTIME) { ASSERT_FALSE(checkFsUtimeEvent); checkFsUtimeEvent = true; @@ -600,7 +600,7 @@ TEST(FsReq, Realpath) { fsReq->on([](const auto &, auto &) { FAIL(); }); fileReq->on([](const auto &, auto &) { FAIL(); }); - fsReq->on([&](const auto &event, auto &req) { + fsReq->on([&](const auto &event, auto &) { if(event.type == uvw::fs_req::fs_type::REALPATH) { ASSERT_FALSE(checkFsRealpathEvent); ASSERT_NE(event.path, nullptr); diff --git a/test/uvw/loop.cpp b/test/uvw/loop.cpp index d42ab4ce..8d97a134 100644 --- a/test/uvw/loop.cpp +++ b/test/uvw/loop.cpp @@ -88,7 +88,7 @@ TEST(Loop, Walk) { ASSERT_EQ(count, 12u); loop->run(); - loop->walk([&count](auto &handle) { --count; }); + loop->walk([&count](auto &) { --count; }); ASSERT_EQ(count, 12u); diff --git a/test/uvw/thread.cpp b/test/uvw/thread.cpp index 6960bd88..20a02a91 100644 --- a/test/uvw/thread.cpp +++ b/test/uvw/thread.cpp @@ -5,8 +5,8 @@ TEST(Thread, Run) { auto loop = uvw::loop::get_default(); auto has_run = std::make_shared(); auto cb = [](std::shared_ptr data) { - if(auto has_run = std::static_pointer_cast(data); has_run) { - *has_run = true; + if(auto has_run_ptr = std::static_pointer_cast(data); has_run_ptr) { + *has_run_ptr = true; } };