Skip to content

Commit

Permalink
Fix clang-tidy warning on non-const constant variables in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rikyoz committed Oct 25, 2023
1 parent 3db27c5 commit 3e21b41
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
6 changes: 3 additions & 3 deletions tests/src/test_bitarchivereader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ TEMPLATE_TEST_CASE( "BitArchiveReader: Reading archives containing encrypted ite
}

SECTION( "Opening the archive with no password should allow reading the archive, but tests() should throw" ) {
BitArchiveReader info( lib, inputArchive, testArchive.format() );
const BitArchiveReader info( lib, inputArchive, testArchive.format() );
REQUIRE( info.hasEncryptedItems() );
REQUIRE( info.isEncrypted() );
REQUIRE_ARCHIVE_CONTENT( info, testArchive );
Expand Down Expand Up @@ -855,7 +855,7 @@ TEMPLATE_TEST_CASE( "BitArchiveReader: Reading an archive with a Unicode file na

const Bit7zLibrary lib{ test::sevenzip_lib_path() };

fs::path arcFileName{ BIT7Z_NATIVE_STRING( "αρχείο.7z" ) };
const fs::path arcFileName{ BIT7Z_NATIVE_STRING( "αρχείο.7z" ) };

TestType inputArchive{};
getInputArchive( arcFileName, inputArchive );
Expand All @@ -871,7 +871,7 @@ TEST_CASE( "BitArchiveReader: Reading an archive with a Unicode file name (bzip2

const Bit7zLibrary lib{ test::sevenzip_lib_path() };

fs::path arcFileName{ BIT7Z_NATIVE_STRING( "クラウド.jpg.bz2" ) };
const fs::path arcFileName{ BIT7Z_NATIVE_STRING( "クラウド.jpg.bz2" ) };
const BitArchiveReader info( lib, path_to_tstring( arcFileName ), BitFormat::BZip2 );
REQUIRE_ITEM_UNICODE( info, "クラウド.jpg" );
}
Expand Down
28 changes: 14 additions & 14 deletions tests/src/test_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ TEMPLATE_TEST_CASE( "util: Clamp cast from any unsigned type to std::uint16_t",
REQUIRE( clamp_cast< std::uint16_t >( TestType{ 42u } ) == std::uint16_t{ 42u } );

TestType maxValue{ std::numeric_limits< TestType >::max() };
std::uint16_t maxDestinationValue{ std::numeric_limits< std::uint16_t >::max() };
const std::uint16_t maxDestinationValue{ std::numeric_limits< std::uint16_t >::max() };
if ( maxValue >= maxDestinationValue ) {
REQUIRE( clamp_cast< std::uint16_t >( maxValue ) == maxDestinationValue );
REQUIRE( clamp_cast< std::uint16_t >( static_cast< TestType >( maxDestinationValue ) ) == maxDestinationValue );
Expand All @@ -207,7 +207,7 @@ TEMPLATE_TEST_CASE( "util: Clamp cast from any unsigned type to std::uint32_t",
REQUIRE( clamp_cast< std::uint32_t >( TestType{ 42u } ) == std::uint32_t{ 42u } );

TestType maxValue{ std::numeric_limits< TestType >::max() };
std::uint32_t maxDestinationValue{ std::numeric_limits< std::uint32_t >::max() };
const std::uint32_t maxDestinationValue{ std::numeric_limits< std::uint32_t >::max() };
if ( maxValue >= maxDestinationValue ) {
REQUIRE( clamp_cast< std::uint32_t >( maxValue ) == maxDestinationValue );
REQUIRE( clamp_cast< std::uint32_t >( static_cast< TestType >( maxDestinationValue ) ) == maxDestinationValue );
Expand Down Expand Up @@ -240,7 +240,7 @@ TEMPLATE_TEST_CASE( "util: Clamp cast from any signed type to std::uint8_t", "[u
REQUIRE( clamp_cast< std::uint8_t >( minValue ) == 0u );

TestType maxValue{ std::numeric_limits< TestType >::max() };
std::uint8_t maxDestinationValue{ std::numeric_limits< std::uint8_t >::max() };
const std::uint8_t maxDestinationValue{ std::numeric_limits< std::uint8_t >::max() };
if ( cmp_greater_equal( maxValue, maxDestinationValue ) ) {
REQUIRE( clamp_cast< std::uint8_t >( maxValue ) == maxDestinationValue );
} else {
Expand All @@ -261,7 +261,7 @@ TEMPLATE_TEST_CASE( "util: Clamp cast from any signed type to std::uint16_t", "[
REQUIRE( clamp_cast< std::uint16_t >( minValue ) == 0u );

TestType maxValue{ std::numeric_limits< TestType >::max() };
std::uint16_t maxDestinationValue{ std::numeric_limits< std::uint16_t >::max() };
const std::uint16_t maxDestinationValue{ std::numeric_limits< std::uint16_t >::max() };
if ( cmp_greater_equal( maxValue, maxDestinationValue ) ) {
REQUIRE( clamp_cast< std::uint16_t >( maxValue ) == maxDestinationValue );
} else {
Expand All @@ -282,7 +282,7 @@ TEMPLATE_TEST_CASE( "util: Clamp cast from any signed type to std::uint32_t", "[
REQUIRE( clamp_cast< std::uint32_t >( minValue ) == 0u );

TestType maxValue{ std::numeric_limits< TestType >::max() };
std::uint32_t maxDestinationValue{ std::numeric_limits< std::uint32_t >::max() };
const std::uint32_t maxDestinationValue{ std::numeric_limits< std::uint32_t >::max() };
if ( cmp_greater_equal( maxValue, maxDestinationValue ) ) {
REQUIRE( clamp_cast< std::uint32_t >( maxValue ) == maxDestinationValue );
} else {
Expand Down Expand Up @@ -324,7 +324,7 @@ TEMPLATE_TEST_CASE( "util: Clamp cast from any unsigned type to std::int16_t", "
REQUIRE( clamp_cast< std::int16_t >( TestType{ 42u } ) == std::int16_t{ 42 } );

TestType maxValue{ std::numeric_limits< TestType >::max() };
std::int16_t maxDestinationValue{ std::numeric_limits< std::int16_t >::max() };
const std::int16_t maxDestinationValue{ std::numeric_limits< std::int16_t >::max() };
if ( cmp_greater_equal( maxValue, maxDestinationValue ) ) {
REQUIRE( clamp_cast< std::int16_t >( maxValue ) == maxDestinationValue );
} else { // widening
Expand All @@ -339,7 +339,7 @@ TEMPLATE_TEST_CASE( "util: Clamp cast from any unsigned type to std::int32_t", "
REQUIRE( clamp_cast< std::int32_t >( TestType{ 42u } ) == std::int32_t{ 42 } );

TestType maxValue{ std::numeric_limits< TestType >::max() };
std::int32_t maxDestinationValue{ std::numeric_limits< std::int32_t >::max() };
const std::int32_t maxDestinationValue{ std::numeric_limits< std::int32_t >::max() };
if ( cmp_greater_equal( maxValue, maxDestinationValue ) ) {
REQUIRE( clamp_cast< std::int32_t >( maxValue ) == maxDestinationValue );
} else { // widening
Expand All @@ -354,7 +354,7 @@ TEMPLATE_TEST_CASE( "util: Clamp cast from any unsigned type to std::int64_t", "
REQUIRE( clamp_cast< std::int64_t >( TestType{ 42u } ) == std::int64_t{ 42 } );

TestType maxValue{ std::numeric_limits< TestType >::max() };
std::int64_t maxDestinationValue{ std::numeric_limits< std::int64_t >::max() };
const std::int64_t maxDestinationValue{ std::numeric_limits< std::int64_t >::max() };
if ( cmp_greater_equal( maxValue, maxDestinationValue ) ) {
REQUIRE( clamp_cast< std::int64_t >( maxValue ) == maxDestinationValue );
} else { // widening
Expand Down Expand Up @@ -389,15 +389,15 @@ TEMPLATE_TEST_CASE( "util: Clamp cast from any signed type to std::int16_t", "[u
REQUIRE( clamp_cast< std::int16_t >( TestType{ -42 } ) == std::int16_t{ -42 } );

TestType minValue{ std::numeric_limits< TestType >::min() };
std::int16_t minDestinationValue{ std::numeric_limits< std::int16_t >::min() };
const std::int16_t minDestinationValue{ std::numeric_limits< std::int16_t >::min() };
if ( minValue <= minDestinationValue ) {
REQUIRE( clamp_cast< std::int16_t >( minValue ) == minDestinationValue );
} else {
REQUIRE( clamp_cast< std::int16_t >( minValue ) == minValue );
}

TestType maxValue{ std::numeric_limits< TestType >::max() };
std::int16_t maxDestinationValue{ std::numeric_limits< std::int16_t >::max() };
const std::int16_t maxDestinationValue{ std::numeric_limits< std::int16_t >::max() };
if ( maxValue >= maxDestinationValue ) {
REQUIRE( clamp_cast< std::int16_t >( maxValue ) == maxDestinationValue );
} else {
Expand All @@ -415,15 +415,15 @@ TEMPLATE_TEST_CASE( "util: Clamp cast from any signed type to std::int32_t", "[u
REQUIRE( clamp_cast< std::int32_t >( TestType{ -42 } ) == std::int32_t{ -42 } );

TestType minValue{ std::numeric_limits< TestType >::min() };
std::int32_t minDestinationValue{ std::numeric_limits< std::int32_t >::min() };
const std::int32_t minDestinationValue{ std::numeric_limits< std::int32_t >::min() };
if ( minValue <= minDestinationValue ) {
REQUIRE( clamp_cast< std::int32_t >( minValue ) == minDestinationValue );
} else {
REQUIRE( clamp_cast< std::int32_t >( minValue ) == minValue );
}

TestType maxValue{ std::numeric_limits< TestType >::max() };
std::int32_t maxDestinationValue{ std::numeric_limits< std::int32_t >::max() };
const std::int32_t maxDestinationValue{ std::numeric_limits< std::int32_t >::max() };
if ( maxValue >= maxDestinationValue ) {
REQUIRE( clamp_cast< std::int32_t >( maxValue ) == maxDestinationValue );
} else {
Expand All @@ -441,15 +441,15 @@ TEMPLATE_TEST_CASE( "util: Clamp cast from std::int64_t to std::int64_t", "[util
REQUIRE( clamp_cast< std::int64_t >( TestType{ -42 } ) == std::int64_t{ -42 } );

TestType minValue{ std::numeric_limits< TestType >::max() };
std::int64_t minDestinationValue{ std::numeric_limits< std::int64_t >::min() };
const std::int64_t minDestinationValue{ std::numeric_limits< std::int64_t >::min() };
if ( minValue <= minDestinationValue ) {
REQUIRE( clamp_cast< std::int64_t >( minValue ) == minDestinationValue );
} else {
REQUIRE( clamp_cast< std::int64_t >( minValue ) == minValue );
}

TestType maxValue{ std::numeric_limits< TestType >::max() };
std::int64_t maxDestinationValue{ std::numeric_limits< std::int64_t >::max() };
const std::int64_t maxDestinationValue{ std::numeric_limits< std::int64_t >::max() };
if ( maxValue >= maxDestinationValue ) {
REQUIRE( clamp_cast< std::int64_t >( maxValue ) == maxDestinationValue );
} else {
Expand Down

0 comments on commit 3e21b41

Please sign in to comment.