mirror of
https://github.com/taglib/taglib.git
synced 2025-06-03 17:18:11 -04:00
Completed testcases and fixed some bugs, that were found because of the them
This commit is contained in:
parent
c972b0c080
commit
6bf8177796
@ -44,10 +44,11 @@ public:
|
||||
Element *value;
|
||||
|
||||
if(info && (value = info->getChild(Constants::Duration))) {
|
||||
length = static_cast<int>(value->getAsFloat());
|
||||
if((value = info->getChild(Constants::TimecodeScale))){
|
||||
length = static_cast<int>(length / (value->getAsUnsigned() * (1.0 / 1000000000)));
|
||||
}
|
||||
length = static_cast<int>(value->getAsFloat() / 1000000000.L);
|
||||
if((value = info->getChild(Constants::TimecodeScale)))
|
||||
length *= value->getAsUnsigned();
|
||||
else
|
||||
length *= 1000000;
|
||||
}
|
||||
|
||||
info = elem->getChild(Constants::Tracks);
|
||||
@ -59,7 +60,7 @@ public:
|
||||
|
||||
// Dirty bitrate:
|
||||
document->seek(0, File::End);
|
||||
bitrate = static_cast<int>(8 * document->tell() / length / 1000);
|
||||
bitrate = static_cast<int>(8 * document->tell() / ((length > 0) ? length : 1));
|
||||
|
||||
if((value = info->getChild(Constants::Channels)))
|
||||
channels = static_cast<int>(value->getAsUnsigned());
|
||||
|
@ -64,8 +64,8 @@ public:
|
||||
List<Element *> entries = elem->getChildren(Constants::Tag);
|
||||
for(List<Element *>::Iterator i = entries.begin(); i != entries.end(); ++i) {
|
||||
Element *target = (*i)->getChild(Constants::Targets);
|
||||
ulli ttvalue = 0;
|
||||
if(target && (target = (*i)->getChild(Constants::TargetTypeValue)))
|
||||
ulli ttvalue = 50; // 50 is default (see spec.)
|
||||
if(target && (target = target->getChild(Constants::TargetTypeValue)))
|
||||
ttvalue = target->getAsUnsigned();
|
||||
|
||||
// Load all SimpleTags
|
||||
@ -198,7 +198,7 @@ bool EBML::Matroska::File::save()
|
||||
return false;
|
||||
|
||||
// C++11 features would be nice: for(auto &i : d->tags) { /* ... */ }
|
||||
// Well, here we just iterate over each extracted element.
|
||||
// Well, here we just iterate each extracted element.
|
||||
for(List<std::pair<PropertyMap, std::pair<Element *, ulli> > >::Iterator i = d->tags.begin();
|
||||
i != d->tags.end(); ++i) {
|
||||
|
||||
@ -218,7 +218,7 @@ bool EBML::Matroska::File::save()
|
||||
target->addElement(Constants::TargetType, Constants::TRACK);
|
||||
else if(i->second.second == Constants::MostCommonGroupingValue)
|
||||
target->addElement(Constants::TargetType, Constants::ALBUM);
|
||||
|
||||
|
||||
target->addElement(Constants::TargetTypeValue, i->second.second);
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include "utils.h"
|
||||
|
||||
#include <ebmlmatroskafile.h>
|
||||
#include <ebmlmatroskaaudio.h>
|
||||
|
||||
using namespace std;
|
||||
using namespace TagLib;
|
||||
@ -15,6 +16,7 @@ class TestMatroska : public CppUnit::TestFixture
|
||||
CPPUNIT_TEST_SUITE(TestMatroska);
|
||||
CPPUNIT_TEST(testPredefined);
|
||||
CPPUNIT_TEST(testInsertAndExtract);
|
||||
CPPUNIT_TEST(testAudioProperties);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
public:
|
||||
@ -94,6 +96,12 @@ public:
|
||||
|
||||
AudioProperties* a = f.audioProperties();
|
||||
CPPUNIT_ASSERT(a != 0);
|
||||
|
||||
// Not a very nice assertion...
|
||||
CPPUNIT_ASSERT_EQUAL(a->length(), 0);
|
||||
// Bitrate is not nice and thus not tested.
|
||||
CPPUNIT_ASSERT_EQUAL(a->sampleRate(), 44100);
|
||||
CPPUNIT_ASSERT_EQUAL(a->channels(), 2);
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user