Skip to content

Commit 6f364f9

Browse files
Working on warnings and errors in Windows
1 parent 141b662 commit 6f364f9

File tree

2 files changed

+24
-29
lines changed

2 files changed

+24
-29
lines changed

test/net_ip/detail/wp_access_test.cpp

Lines changed: 23 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -22,42 +22,37 @@
2222

2323
#include "net_ip/detail/wp_access.hpp"
2424

25-
SCENARIO ( "Weak pointer access utility functions testing",
26-
"[wp_access]" ) {
25+
using ne_wp = std::weak_ptr<chops::test::net_entity_mock>;
26+
using ne_sp = std::shared_ptr<chops::test::net_entity_mock>;
2727

28-
using ne_wp = std::weak_ptr<chops::test::net_entity_mock>;
29-
using ne_sp = std::shared_ptr<chops::test::net_entity_mock>;
28+
TEST_CASE ( "Weak pointer access utility functions, empty weak ptr",
29+
"[wp_access]" ) {
3030

3131
ne_wp empty_wp;
3232

33-
GIVEN ("An empty weak pointer") {
34-
WHEN ("is_started is called, returning bool") {
35-
THEN ("the return value contains an error") {
36-
auto r = chops::net::detail::wp_access<bool>(empty_wp, [] (ne_sp nesp) { return nesp->is_started(); } );
37-
REQUIRE_FALSE (r);
38-
INFO("Error code: " << r.error());
39-
}
40-
}
41-
AND_WHEN ("the wp_access_void function is called") {
42-
THEN ("the return value contains an error") {
43-
auto r = chops::net::detail::wp_access_void(empty_wp, [] (ne_sp) { return std::error_code(); } );
44-
REQUIRE_FALSE (r);
45-
INFO("Error code: " << r.error());
46-
}
47-
}
48-
} // end given
33+
SECTION ("Check for false when is_started is called on empty weak ptr") {
34+
auto r = chops::net::detail::wp_access<bool>(empty_wp, [] (ne_sp nesp) { return nesp->is_started(); } );
35+
REQUIRE_FALSE (r);
36+
INFO("Error code: " << r.error());
37+
}
4938

39+
SECTION ("Check for error code return on wp_access_void") {
40+
auto r = chops::net::detail::wp_access_void(empty_wp, [] (ne_sp) { return std::error_code(); } );
41+
REQUIRE_FALSE (r);
42+
INFO("Error code: " << r.error());
43+
}
44+
}
45+
46+
TEST_CASE ("Weak pointer pointing to default constructed net_entity_mock") {
5047
auto sp = std::make_shared<chops::test::net_entity_mock>();
5148
ne_wp wp(sp);
5249

53-
GIVEN ("A weak pointer to a default constructed net_entity_mock") {
54-
WHEN ("is_started is called") {
55-
THEN ("the return value is false") {
56-
auto r = chops::net::detail::wp_access<bool>(wp, [] (ne_sp nesp) { return nesp->is_started(); } );
57-
REQUIRE (r);
58-
REQUIRE_FALSE (*r);
59-
}
60-
}
50+
SECTION ("Calling is_started on mock object should return false") {
51+
auto r = chops::net::detail::wp_access<bool>(wp, [] (ne_sp nesp) { return nesp->is_started(); } );
52+
REQUIRE (r);
53+
REQUIRE_FALSE (*r);
54+
}
55+
6156
AND_WHEN ("start is called followed by is_started followed by stop") {
6257
THEN ("all calls succeed") {
6358
auto r1 = chops::net::detail::wp_access_void(wp,

test/shared_test/msg_handling.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ inline chops::mutable_shared_buffer make_body_buf(std::string_view pre,
8686
inline chops::const_shared_buffer make_variable_len_msg(const chops::mutable_shared_buffer& body) {
8787
assert(body.size() < std::numeric_limits<std::uint16_t>::max());
8888
std::byte hdr[2];
89-
auto sz = append_val<std::endian::big, std::uint16_t>(hdr, body.size());
89+
auto sz = append_val<std::endian::big, std::uint16_t>(hdr, static_cast<std::uint16_t>(body.size()));
9090
chops::mutable_shared_buffer msg(hdr, 2);
9191
return chops::const_shared_buffer(std::move(msg.append(body.data(), body.size())));
9292
}

0 commit comments

Comments
 (0)