Inspection: Variable can be made constexpr

This commit is contained in:
Urs Fleisch
2024-01-20 17:22:53 +01:00
parent 710522e6e1
commit 5d921c6325
18 changed files with 26 additions and 26 deletions

View File

@ -240,7 +240,7 @@ public:
void testFloatingPointConversion()
{
const double Tolerance = 1.0e-7;
constexpr double Tolerance = 1.0e-7;
const ByteVector pi32le("\xdb\x0f\x49\x40", 4);
CPPUNIT_ASSERT(std::abs(pi32le.toFloat32LE(0) - M_PI) < Tolerance);

View File

@ -648,7 +648,7 @@ public:
CPPUNIT_ASSERT_EQUAL(String("Title"), f.xiphComment(false)->title());
}
const unsigned char expectedHeadData[] = {
constexpr unsigned char expectedHeadData[] = {
'f', 'L', 'a', 'C', 0x00, 0x00, 0x00, 0x22, 0x12, 0x00, 0x12, 0x00,
0x00, 0x00, 0x0e, 0x00, 0x00, 0x10, 0x0a, 0xc4, 0x42, 0xf0, 0x00, 0x02,
0x7a, 0xc0, 0xa1, 0xb1, 0x41, 0xf7, 0x66, 0xe9, 0x84, 0x9a, 0xc3, 0xdb,

View File

@ -636,9 +636,9 @@ public:
const String testComment("Comment");
const String testGenre("Genre");
const String nullString;
const unsigned int testYear = 2020;
const unsigned int testTrack = 1;
const unsigned int zeroUInt = 0;
constexpr unsigned int testYear = 2020;
constexpr unsigned int testTrack = 1;
constexpr unsigned int zeroUInt = 0;
tag->setTitle(testTitle);
CPPUNIT_ASSERT_EQUAL(testTitle, tag->title());

View File

@ -135,7 +135,7 @@ public:
void testAudioPropertiesADTS()
{
const std::array readStyles = {
constexpr std::array readStyles = {
MPEG::Properties::Fast,
MPEG::Properties::Average,
MPEG::Properties::Accurate

View File

@ -96,8 +96,8 @@ public:
String unicode3(L"\u65E5\u672C\u8A9E");
CPPUNIT_ASSERT(*(unicode3.toCWString() + 1) == L'\u672C');
const wchar_t wcSystemOrder[] = {L'\u65E5', L'\u672C', L'\u8A9E', 0};
const wchar_t wcSwappedOrder[] = {L'\uE565', L'\u2C67', L'\u9E8A', 0};
constexpr wchar_t wcSystemOrder[] = {L'\u65E5', L'\u672C', L'\u8A9E', 0};
constexpr wchar_t wcSwappedOrder[] = {L'\uE565', L'\u2C67', L'\u9E8A', 0};
const std::wstring wsSystemOrder = L"\u65e5\u672c\u8a9e";
const std::wstring wsSwappedOrder = L"\ue565\u2c67\u9e8a";
const bool isLe = Utils::systemByteOrder() == Utils::LittleEndian;

View File

@ -316,7 +316,7 @@ public:
{
FileStream stream(copy.fileName().c_str());
stream.seek(0, IOStream::End);
const char garbage[] = "12345678";
constexpr char garbage[] = "12345678";
stream.writeBlock(ByteVector(garbage, sizeof(garbage) - 1));
stream.seek(0);
contentsBeforeModification = stream.readBlock(stream.length());