@@ -38,96 +38,90 @@ void make_endpoints_test (bool local, std::string_view host, std::string_view po
3838
3939 chops::net::endpoints_resolver<Protocol> resolver (wk.get_io_context ());
4040
41- GIVEN (" An executor work guard, host, and port strings" ) {
42- WHEN (" sync overload of make_endpoints is called" ) {
43- THEN (" a sequence of endpoints is returned or an error returned" ) {
44- INFO (" -- Host: " << host);
45- auto results = resolver.make_endpoints (local, host, port);
46- if (expected_good) {
47- REQUIRE (results);
48- INFO (" -- Num endpoints: " << results->size ());
49- REQUIRE_FALSE (results->empty ());
50- }
51- else {
52- REQUIRE_FALSE (results);
53- INFO (" Error code: " << results.error ());
54- }
55- }
41+ SECTION (" Sync overload, seq of endpoints returned" ) {
42+ INFO (" -- Host: " << host);
43+ auto results = resolver.make_endpoints (local, host, port);
44+ if (expected_good) {
45+ REQUIRE (results);
46+ INFO (" -- Num endpoints: " << results->size ());
47+ REQUIRE_FALSE (results->empty ());
48+ }
49+ else {
50+ REQUIRE_FALSE (results);
51+ INFO (" Error code: " << results.error ());
5652 }
57- AND_WHEN (" async overload of make_endpoints is called" ) {
58- THEN (" a sequence of endpoints is returned through a function object callback" ) {
59-
60- INFO (" -- Host: " << host);
61- std::promise<prom_ret> res_prom;
62- auto fut = res_prom.get_future ();
63- resolver.make_endpoints (local, host, port,
64- [p = std::move (res_prom)] (const std::error_code& err, results_t res) mutable {
65- p.set_value (prom_ret (err, res));
66- }
67- );
68- auto a = fut.get ();
69- if (expected_good) {
70- REQUIRE_FALSE (a.first );
71- INFO (" -- Num endpoints: " << a.second .size ());
72- REQUIRE_FALSE (a.second .empty ());
73- }
74- else {
75- REQUIRE (a.first );
76- INFO (" Error val: " << a.first );
77- REQUIRE (a.second .empty ());
78- }
53+ }
54+ SECTION (" Async overload, seq endpoints returned" ) {
55+ INFO (" -- Host: " << host);
56+ std::promise<prom_ret> res_prom;
57+ auto fut = res_prom.get_future ();
58+ resolver.make_endpoints (local, host, port,
59+ [p = std::move (res_prom)] (const std::error_code& err, results_t res) mutable {
60+ p.set_value (prom_ret (err, res));
7961 }
62+ );
63+ auto a = fut.get ();
64+ if (expected_good) {
65+ REQUIRE_FALSE (a.first );
66+ INFO (" -- Num endpoints: " << a.second .size ());
67+ REQUIRE_FALSE (a.second .empty ());
68+ }
69+ else {
70+ REQUIRE (a.first );
71+ INFO (" Error val: " << a.first );
72+ REQUIRE (a.second .empty ());
8073 }
81- } // end given
74+ }
8275
8376 wk.reset ();
8477
8578}
8679
87- SCENARIO ( " Make endpoints remote test, TCP 1" ,
88- " [make_endpoints] [tcp]" ) {
80+ TEST_CASE ( " Make endpoints remote test, TCP 1" ,
81+ " [make_endpoints] [tcp]" ) {
8982
9083 make_endpoints_test<asio::ip::tcp> (false , " www.cnn.com" , " 80" , true );
9184
9285}
9386
94- SCENARIO ( " Make endpoints remote test, TCP 2" ,
95- " [make_endpoints] [tcp]" ) {
87+ TEST_CASE ( " Make endpoints remote test, TCP 2" ,
88+ " [make_endpoints] [tcp]" ) {
9689
9790 make_endpoints_test<asio::ip::tcp> (false , " www.seattletimes.com" , " 80" , true );
9891
9992}
10093
101- SCENARIO ( " Make endpoints local test, TCP 3" ,
102- " [make_endpoints] [tcp]" ) {
94+ TEST_CASE ( " Make endpoints local test, TCP 3" ,
95+ " [make_endpoints] [tcp]" ) {
10396
10497 make_endpoints_test<asio::ip::tcp> (true , " " , " 23000" , true );
10598
10699}
107100
108- SCENARIO ( " Make endpoints remote test, UDP 1" ,
109- " [make_endpoints] [udp]" ) {
101+ TEST_CASE ( " Make endpoints remote test, UDP 1" ,
102+ " [make_endpoints] [udp]" ) {
110103
111104 make_endpoints_test<asio::ip::udp> (false , " www.cnn.com" , " 80" , true );
112105
113106}
114107
115- SCENARIO ( " Make endpoints remote test, UDP 2" ,
116- " [make_endpoints] [udp]" ) {
108+ TEST_CASE ( " Make endpoints remote test, UDP 2" ,
109+ " [make_endpoints] [udp]" ) {
117110
118111 make_endpoints_test<asio::ip::udp> (false , " www.seattletimes.com" , " 80" , true );
119112
120113}
121114
122- SCENARIO ( " Make endpoints local test, UDP 3" ,
123- " [make_endpoints] [udp]" ) {
115+ TEST_CASE ( " Make endpoints local test, UDP 3" ,
116+ " [make_endpoints] [udp]" ) {
124117
125118 make_endpoints_test<asio::ip::udp> (true , " " , " 23000" , true );
126119
127120}
128121
129122/*
130- SCENARIO ( "Make endpoints remote test, TCP invalid", "[tcp_make_endpoints_invalid]" ) {
123+ TEST_CASE ( "Make endpoints remote test, TCP invalid",
124+ "[tcp_make_endpoints_invalid]" ) {
131125
132126 make_endpoints_test<asio::ip::tcp> (false, "frobozz.blaaaarg", "32555", false);
133127
0 commit comments