11#include " catch/catch.hpp"
22#include " catch_test_common.hpp"
33
4+ #include " cache_expire.h"
5+
6+ extern bool fail_next_connect;
7+ extern bool fail_next_getaddrinfo;
8+ extern bool fail_next_getaddrinfo_empty_res;
9+ extern bool fail_next_malloc;
10+ extern bool fail_next_socket;
11+ extern std::string err_log_lines;
12+
413TEST_CASE (" cache_expire.c" , " [cache_expire]" )
514{
615 int x = 0 ;
@@ -9,8 +18,7 @@ TEST_CASE("cache_expire.c", "[cache_expire]")
918 std::string host (" host" );
1019 std::string uri (" /uri/" );
1120
12- SECTION (" cache_expire_url function" )
13- {
21+ SECTION (" cache_expire_url function" ) {
1422 std::string url (" http://" + host + uri + std::to_string (z) + " /" + std::to_string (x) + " /" + std::to_string (y) + " .png" );
1523
1624 err_log_lines.clear ();
@@ -39,8 +47,7 @@ TEST_CASE("cache_expire.c", "[cache_expire]")
3947 }
4048 }
4149
42- SECTION (" cache_expire function" )
43- {
50+ SECTION (" cache_expire function" ) {
4451 err_log_lines.clear ();
4552
4653 SECTION (" cache_expire" , " should return" ) {
@@ -65,8 +72,7 @@ TEST_CASE("cache_expire.c", "[cache_expire]")
6572 }
6673 }
6774
68- SECTION (" init_cache_expire functiong" )
69- {
75+ SECTION (" init_cache_expire function" ) {
7076 err_log_lines.clear ();
7177
7278 SECTION (" init_cache_expire" , " should return" ) {
@@ -79,14 +85,14 @@ TEST_CASE("cache_expire.c", "[cache_expire]")
7985 std::string htcphost (" nonexistenthost" );
8086 init_cache_expire ((char *)htcphost.c_str ());
8187 REQUIRE_THAT (err_log_lines,
82- Catch::Matchers::Contains (" Failed to lookup HTCP cache host: Address family for hostname not supported" )
83- ||
84- Catch::Matchers::Contains (" Failed to lookup HTCP cache host: Name or service not known" )
85- ||
86- Catch::Matchers::Contains (" Failed to lookup HTCP cache host: Temporary failure in name resolution" )
87- ||
88- Catch::Matchers::Contains (" Failed to lookup HTCP cache host: nodename nor servname provided, or not known" )
89- );
88+ Catch::Matchers::Contains (" Failed to lookup HTCP cache host: Address family for hostname not supported" )
89+ ||
90+ Catch::Matchers::Contains (" Failed to lookup HTCP cache host: Name or service not known" )
91+ ||
92+ Catch::Matchers::Contains (" Failed to lookup HTCP cache host: Temporary failure in name resolution" )
93+ ||
94+ Catch::Matchers::Contains (" Failed to lookup HTCP cache host: nodename nor servname provided, or not known" )
95+ );
9096 }
9197
9298 SECTION (" init_cache_expire with failed socket" , " should return" ) {
@@ -105,10 +111,10 @@ TEST_CASE("cache_expire.c", "[cache_expire]")
105111
106112 init_cache_expire ((char *)htcphost.c_str ());
107113 REQUIRE_THAT (err_log_lines,
108- Catch::Matchers::Contains (" Failed to lookup HTCP cache host: Bad value for ai_flags" )
109- ||
110- Catch::Matchers::Contains (" Failed to lookup HTCP cache host: Unknown error" )
111- );
114+ Catch::Matchers::Contains (" Failed to lookup HTCP cache host: Bad value for ai_flags" )
115+ ||
116+ Catch::Matchers::Contains (" Failed to lookup HTCP cache host: Unknown error" )
117+ );
112118 }
113119
114120 SECTION (" init_cache_expire with empty getaddrinfo response" , " should return" ) {
0 commit comments