@@ -16,7 +16,7 @@ TEST_CASE("Construct file unique_resource", "[unique_resource]") {
1616 {
1717 auto file = beman::scope::unique_resource (
1818 fopen (" example.txt" , " w" ), // Acquire the FILE*
19- [](FILE* f) { if (f) {
19+ [close_file_good ](FILE* f) { if (f) {
2020 fclose (f); // Release (cleanup) the resource
2121 close_file_good = true ;
2222 }
@@ -25,6 +25,7 @@ TEST_CASE("Construct file unique_resource", "[unique_resource]") {
2525 if (!file.get ()) {
2626 throw std::runtime_error (" file didn't open" );
2727 }
28+ open_file_good = true ;
2829 }
2930 REQUIRE (open_file_good == true );
3031 REQUIRE (close_file_good == true );
@@ -64,7 +65,7 @@ TEST_CASE("unique_resource does not clean up after release", "[unique_resource]"
6465 [](DummyResource r) { *(r.cleanedUp ) = true ; }
6566 );
6667
67- [[maybe_unused]] auto raw = res.release ();
68+ res.release (); // no cleanup run
6869 }
6970
7071 REQUIRE (cleaned == false );
@@ -126,7 +127,7 @@ TEST_CASE("unique_resource cleans up on exception", "[unique_resource][exception
126127 REQUIRE (cleaned == true );
127128}
128129
129- TEST_CASE (" unique_resource does not clean up if released before exception" , " [unique_resource][exception]" ) {
130+ TEST_CASE (" unique_resource does not clean up if reset before exception" , " [unique_resource][exception]" ) {
130131 bool cleaned = false ;
131132
132133 try {
@@ -135,7 +136,7 @@ TEST_CASE("unique_resource does not clean up if released before exception", "[un
135136 [](DummyResource r) { *(r.cleanedUp ) = true ; }
136137 );
137138
138- [[maybe_unused]] auto raw = res.release (); // disables cleanup
139+ res.reset (); // disables cleanup
139140
140141 throw std::runtime_error (" Throwing after release" );
141142
0 commit comments