Inspection: Variable can be moved to inner scope

This commit is contained in:
Urs Fleisch
2024-01-20 21:25:54 +01:00
parent dfe2aa5253
commit 613355665c
11 changed files with 51 additions and 74 deletions

View File

@ -395,16 +395,13 @@ public:
void testRepeatedSave()
{
ScopedFileCopy copy("silence-1", ".wma");
{
ASF::File f(copy.fileName().c_str());
f.tag()->setTitle(longText(128 * 1024));
f.save();
CPPUNIT_ASSERT_EQUAL(static_cast<offset_t>(297578), f.length());
f.tag()->setTitle(longText(16 * 1024));
f.save();
CPPUNIT_ASSERT_EQUAL(static_cast<offset_t>(68202), f.length());
}
ASF::File f(copy.fileName().c_str());
f.tag()->setTitle(longText(128 * 1024));
f.save();
CPPUNIT_ASSERT_EQUAL(static_cast<offset_t>(297578), f.length());
f.tag()->setTitle(longText(16 * 1024));
f.save();
CPPUNIT_ASSERT_EQUAL(static_cast<offset_t>(68202), f.length());
}
};

View File

@ -445,24 +445,20 @@ public:
void testSaveID3v1()
{
ScopedFileCopy copy("no-tags", ".flac");
FLAC::File f(copy.fileName().c_str());
CPPUNIT_ASSERT(!f.hasID3v1Tag());
CPPUNIT_ASSERT_EQUAL(static_cast<offset_t>(4692), f.length());
ByteVector audioStream;
{
FLAC::File f(copy.fileName().c_str());
CPPUNIT_ASSERT(!f.hasID3v1Tag());
CPPUNIT_ASSERT_EQUAL(static_cast<offset_t>(4692), f.length());
f.seek(0x0100);
ByteVector audioStream = f.readBlock(4436);
f.seek(0x0100);
audioStream = f.readBlock(4436);
f.ID3v1Tag(true)->setTitle("01234 56789 ABCDE FGHIJ");
f.save();
CPPUNIT_ASSERT(f.hasID3v1Tag());
CPPUNIT_ASSERT_EQUAL(static_cast<offset_t>(4820), f.length());
f.ID3v1Tag(true)->setTitle("01234 56789 ABCDE FGHIJ");
f.save();
CPPUNIT_ASSERT(f.hasID3v1Tag());
CPPUNIT_ASSERT_EQUAL(static_cast<offset_t>(4820), f.length());
f.seek(0x0100);
CPPUNIT_ASSERT_EQUAL(audioStream, f.readBlock(4436));
}
f.seek(0x0100);
CPPUNIT_ASSERT_EQUAL(audioStream, f.readBlock(4436));
}
void testUpdateID3v2()

View File

@ -1107,10 +1107,8 @@ public:
PlainFile(newname.c_str()).readBlock(expectedId3v23Data.size());
CPPUNIT_ASSERT_EQUAL(expectedId3v23Data, actualId3v23Data);
}
ScopedFileCopy rareFramesCopy("rare_frames", ".mp3");
{
ScopedFileCopy rareFramesCopy("rare_frames", ".mp3");
MPEG::File f(rareFramesCopy.fileName().c_str());
f.save(MPEG::File::AllTags, File::StripOthers, ID3v2::v3);
f.seek(f.find("TCON") + 11);

View File

@ -562,23 +562,21 @@ public:
void testExtendedHeader()
{
const ScopedFileCopy copy("extended-header", ".mp3");
{
MPEG::File f(copy.fileName().c_str());
CPPUNIT_ASSERT(f.isValid());
CPPUNIT_ASSERT(f.hasID3v2Tag());
ID3v2::Tag *tag = f.ID3v2Tag();
ID3v2::ExtendedHeader *ext = tag->extendedHeader();
CPPUNIT_ASSERT(ext);
CPPUNIT_ASSERT_EQUAL(12U, ext->size());
CPPUNIT_ASSERT_EQUAL(String("Druids"), tag->title());
CPPUNIT_ASSERT_EQUAL(String("Excelsis"), tag->artist());
CPPUNIT_ASSERT_EQUAL(String("Vo Chrieger U Drache"), tag->album());
CPPUNIT_ASSERT_EQUAL(2013U, tag->year());
CPPUNIT_ASSERT_EQUAL(String("Folk/Power Metal"), tag->genre());
CPPUNIT_ASSERT_EQUAL(3U, tag->track());
CPPUNIT_ASSERT_EQUAL(String("2013"),
f.properties().value("ORIGINALDATE").front());
}
MPEG::File f(copy.fileName().c_str());
CPPUNIT_ASSERT(f.isValid());
CPPUNIT_ASSERT(f.hasID3v2Tag());
ID3v2::Tag *tag = f.ID3v2Tag();
ID3v2::ExtendedHeader *ext = tag->extendedHeader();
CPPUNIT_ASSERT(ext);
CPPUNIT_ASSERT_EQUAL(12U, ext->size());
CPPUNIT_ASSERT_EQUAL(String("Druids"), tag->title());
CPPUNIT_ASSERT_EQUAL(String("Excelsis"), tag->artist());
CPPUNIT_ASSERT_EQUAL(String("Vo Chrieger U Drache"), tag->album());
CPPUNIT_ASSERT_EQUAL(2013U, tag->year());
CPPUNIT_ASSERT_EQUAL(String("Folk/Power Metal"), tag->genre());
CPPUNIT_ASSERT_EQUAL(3U, tag->track());
CPPUNIT_ASSERT_EQUAL(String("2013"),
f.properties().value("ORIGINALDATE").front());
}
void testReadStyleFast()