Skip to content

Commit 207a322

Browse files
Working on wp_access Windows errors
1 parent 6f364f9 commit 207a322

File tree

4 files changed

+29
-32
lines changed

4 files changed

+29
-32
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ To build and run the unit test programs:
6464
First clone the `chops-net-ip` repository, then create a build directory in parallel to the `chops-net-ip` directory (this is called "out of source" builds, which is recommended), then `cd` (change directory) into the build directory. The CMake commands:
6565

6666
```
67-
cmake -D CHOPS_NET_IP_BUILD_TESTS:BOOL=ON ../chops_net_ip
67+
cmake -D CHOPS_NET_IP_BUILD_TESTS:BOOL=ON ../chops-net-ip
6868
6969
cmake --build .
7070

include/net_ip/net_entity.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,10 @@ class net_entity {
168168
* Within the function object socket options can be queried or modified or any valid
169169
* socket method called.
170170
*
171-
* @return @c nonstd::expected - socket has been visited on success; on error (if no
171+
* @return @c nonstd::expected - @c bool socket has been visited; on error (if no
172172
* associated IO handler), a @c std::error_code is returned.
173173
*/
174+
174175
template <typename F>
175176
auto visit_socket(F&& func) const ->
176177
nonstd::expected<void, std::error_code> {

test/net_ip/detail/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ set ( test_app_names io_common_test
1414
tcp_acceptor_test
1515
tcp_connector_test
1616
tcp_io_test
17-
udp_entity_io_test
18-
wp_access_test )
17+
udp_entity_io_test
18+
wp_access_test )
1919

2020
include ( ../../../cmake/test_app_creation.cmake )
2121

test/net_ip/detail/wp_access_test.cpp

Lines changed: 24 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -53,35 +53,31 @@ TEST_CASE ("Weak pointer pointing to default constructed net_entity_mock") {
5353
REQUIRE_FALSE (*r);
5454
}
5555

56-
AND_WHEN ("start is called followed by is_started followed by stop") {
57-
THEN ("all calls succeed") {
58-
auto r1 = chops::net::detail::wp_access_void(wp,
59-
[] (ne_sp nesp) { return nesp->start(chops::test::io_state_chg_mock, chops::test::err_func_mock ); }
60-
);
61-
REQUIRE (r1);
62-
auto r2 = chops::net::detail::wp_access<bool>(wp, [] (ne_sp nesp) { return nesp->is_started(); } );
63-
REQUIRE (r2);
64-
REQUIRE(*r2);
65-
auto r3 = chops::net::detail::wp_access_void(wp, [] (ne_sp nesp) { return nesp->stop(); } );
66-
REQUIRE (r3);
67-
auto r4 = chops::net::detail::wp_access<bool>(wp, [] (ne_sp nesp) { return nesp->is_started(); } );
68-
REQUIRE (r4);
69-
REQUIRE_FALSE(*r4);
70-
}
71-
}
72-
AND_WHEN ("visit_io_output is called") {
73-
THEN ("the call succeeds with the correct return value") {
74-
auto r = chops::net::detail::wp_access<std::size_t>(wp,
75-
[] (ne_sp nesp) { return nesp->visit_io_output(
76-
[] (chops::net::basic_io_output<chops::test::io_handler_mock>) { } );
77-
}
78-
);
79-
REQUIRE (r);
80-
REQUIRE (*r == 1u);
81-
}
82-
}
83-
} // end given
56+
SECTION ("Calling start followed by stop should return false for is_started") {
57+
auto r1 = chops::net::detail::wp_access_void(wp,
58+
[] (ne_sp nesp) { return nesp->start(chops::test::io_state_chg_mock, chops::test::err_func_mock ); }
59+
);
60+
REQUIRE (r1);
61+
auto r2 = chops::net::detail::wp_access<bool>(wp, [] (ne_sp nesp) { return nesp->is_started(); } );
62+
REQUIRE (r2);
63+
REQUIRE(*r2);
64+
auto r3 = chops::net::detail::wp_access_void(wp, [] (ne_sp nesp) { return nesp->stop(); } );
65+
REQUIRE (r3);
66+
auto r4 = chops::net::detail::wp_access<bool>(wp, [] (ne_sp nesp) { return nesp->is_started(); } );
67+
REQUIRE (r4);
68+
REQUIRE_FALSE(*r4);
69+
}
8470

71+
SECTION ("When visit_io_output the correct return value should be returned") {
72+
auto r = chops::net::detail::wp_access<std::size_t>(wp,
73+
[] (ne_sp nesp) { return nesp->visit_io_output(
74+
[] (chops::net::basic_io_output<chops::test::io_handler_mock>) { } );
75+
}
76+
);
77+
REQUIRE (r);
78+
REQUIRE (*r == 1u);
79+
}
8580
}
8681

8782

83+

0 commit comments

Comments
 (0)