Skip to content

Commit

Permalink
fix test failure due to file handle cleanup #35
Browse files Browse the repository at this point in the history
  • Loading branch information
timdewhirst committed Mar 14, 2024
1 parent bd58d21 commit 5cc595d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
5 changes: 5 additions & 0 deletions test/image_utils_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ TEST_CASE("image_utils_test - pnm_load_save_test")

g16_image im;
loader->load( is, im );
is.close();

// write data
std::shared_ptr<image_loader> writer{ image_loader_registry::find("image/x-portable-anymap") };
Expand All @@ -79,10 +80,12 @@ TEST_CASE("image_utils_test - pnm_load_save_test")

g16_image reloaded;
loader->load( is, reloaded );
is.close();

{
std::ofstream os( "reloaded.pgm", std::ios_base::trunc | std::ios_base::out | std::ios_base::binary );
writer->save( os, reloaded );
os.close();
}

// and check the two images are equal
Expand Down Expand Up @@ -129,6 +132,7 @@ TEST_CASE("image_utils_test - rgba_join_test")

g16_image im;
loader->load( is, im );
is.close();

g_16 min, max;
std::tie(min, max) = find_image_range( im );
Expand All @@ -147,6 +151,7 @@ TEST_CASE("image_utils_test - rgba_join_test")
std::shared_ptr<image_loader> writer{ image_loader_registry::find("image/x-portable-anymap") };
std::fstream os( "test-rgbjoin.ppm", std::ios_base::trunc | std::ios_base::out | std::ios_base::binary );
writer->save( os, rgba );
os.close();
}

TEST_CASE("image_utils_test - simple_transpose_test")
Expand Down
2 changes: 2 additions & 0 deletions test/test_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ image< ContainedT > load_from_file( const std::string& filename )

image< ContainedT > result;
loader->load( is, result );
is.close();

return result;
}
Expand All @@ -44,6 +45,7 @@ bool save_to_file( const std::string& filename, const ImageT< ContainedT >& im )

std::fstream os( filename, std::ios_base::trunc | std::ios_base::out );
writer->save( os, im );
os.close();

return true;
}
Expand Down

0 comments on commit 5cc595d

Please sign in to comment.