Skip to content

Commit

Permalink
Clean up code in BitInputArchive code
Browse files Browse the repository at this point in the history
  • Loading branch information
rikyoz committed Nov 27, 2023
1 parent e221b88 commit 6e4dd63
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions tests/src/test_bitinputarchive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,13 @@ void require_extracts_to_filesystem( const BitArchiveReader& info, const Expecte
// since the file's type check already includes the check for the file existence.
const auto fileStatus = fs::symlink_status( expectedItem.inArchivePath );
REQUIRE( fileStatus.type() == expectedItem.fileInfo.type );
if ( expectedItem.fileInfo.type == fs::file_type::regular ) {
if ( fs::is_regular_file( fileStatus ) ) {
REQUIRE( crc32( load_file( expectedItem.inArchivePath ) ) == expectedItem.fileInfo.crc32 );
} else if ( expectedItem.fileInfo.type == fs::file_type::symlink ) {
} else if ( fs::is_symlink( fileStatus ) ) {
const auto symlink = fs::read_symlink( expectedItem.inArchivePath );
REQUIRE( crc32( symlink.u8string() ) == expectedItem.fileInfo.crc32 );
}
if ( expectedItem.fileInfo.type != fs::file_type::directory ||
fs::is_empty( expectedItem.inArchivePath ) ) {
if ( !fs::is_directory( fileStatus ) || fs::is_empty( expectedItem.inArchivePath ) ) {
REQUIRE_NOTHROW( fs::remove( expectedItem.inArchivePath ) );
}
}
Expand All @@ -72,9 +71,7 @@ void require_extracts_to_buffers_map( const BitArchiveReader& info, const Expect
REQUIRE( bufferMap.size() == info.filesCount() );
for ( const auto& expectedItem : expectedItems ) {
INFO( "Failed while checking extracted item '" << expectedItem.inArchivePath.u8string() << "'" );
auto expectedPath = expectedItem.inArchivePath;
expectedPath.make_preferred();
const auto& extractedItem = bufferMap.find( path_to_tstring( expectedPath ) );
const auto& extractedItem = bufferMap.find( path_to_tstring( expectedItem.inArchivePath ) );
if ( expectedItem.fileInfo.type != fs::file_type::directory ) {
REQUIRE( extractedItem != bufferMap.end() );
REQUIRE( crc32( extractedItem->second ) == expectedItem.fileInfo.crc32 );
Expand Down

0 comments on commit 6e4dd63

Please sign in to comment.