Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix compiler warnings in test directory #302

Merged
merged 5 commits into from
Sep 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions test/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ void listen(uvw::loop &loop) {
std::cout << "remote: " << remote.ip << " " << remote.port << std::endl;

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;
});

Expand Down Expand Up @@ -65,7 +65,7 @@ void conn(uvw::loop &loop) {

auto dataTryWrite = std::unique_ptr<char[]>(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<int>(bw) << std::endl;

auto dataWrite = std::unique_ptr<char[]>(new char[2]{'b', 'c'});
handle.write(std::move(dataWrite), 2);
Expand Down
14 changes: 7 additions & 7 deletions test/uvw/fs_req.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ TEST(FsReq, Stat) {
fsReq->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) {
ASSERT_FALSE(checkFsStatEvent);
checkFsStatEvent = true;
Expand Down Expand Up @@ -160,7 +160,7 @@ TEST(FsReq, Lstat) {
fsReq->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) {
ASSERT_FALSE(checkFsLstatEvent);
checkFsLstatEvent = true;
Expand Down Expand Up @@ -214,7 +214,7 @@ TEST(FsReq, Rename) {
fsReq->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) {
ASSERT_FALSE(checkFsRenameEvent);
checkFsRenameEvent = true;
Expand Down Expand Up @@ -265,7 +265,7 @@ TEST(FsReq, Access) {
fsReq->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) {
ASSERT_FALSE(checkFsAccessEvent);
checkFsAccessEvent = true;
Expand Down Expand Up @@ -315,7 +315,7 @@ TEST(FsReq, Chmod) {
fsReq->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) {
ASSERT_FALSE(checkFsChmodEvent);
checkFsChmodEvent = true;
Expand Down Expand Up @@ -365,7 +365,7 @@ TEST(FsReq, Utime) {
fsReq->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) {
ASSERT_FALSE(checkFsUtimeEvent);
checkFsUtimeEvent = true;
Expand Down Expand Up @@ -600,7 +600,7 @@ TEST(FsReq, Realpath) {
fsReq->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) {
ASSERT_FALSE(checkFsRealpathEvent);
ASSERT_NE(event.path, nullptr);
Expand Down
2 changes: 1 addition & 1 deletion test/uvw/loop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
4 changes: 2 additions & 2 deletions test/uvw/thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ TEST(Thread, Run) {
auto loop = uvw::loop::get_default();
auto has_run = std::make_shared<bool>();
auto cb = [](std::shared_ptr<void> data) {
if(auto has_run = std::static_pointer_cast<bool>(data); has_run) {
*has_run = true;
if(auto has_run_ptr = std::static_pointer_cast<bool>(data); has_run_ptr) {
*has_run_ptr = true;
}
};

Expand Down