Fix TagValue::toStandardGenreIndex() for empty genre index
This commit is contained in:
parent
dbce74444a
commit
296e5d11b6
|
@ -239,7 +239,7 @@ int TagValue::toStandardGenreIndex() const
|
|||
default:
|
||||
throw ConversionException(argsToString("Can not convert ", tagDataTypeString(m_type), " to genre index."));
|
||||
}
|
||||
if (!Id3Genres::isIndexSupported(index)) {
|
||||
if (!Id3Genres::isEmptyGenre(index) && !Id3Genres::isIndexSupported(index)) {
|
||||
throw ConversionException("The assigned number is not a valid standard genre index.");
|
||||
}
|
||||
return index;
|
||||
|
|
|
@ -84,8 +84,10 @@ void TagValueTests::testInteger()
|
|||
CPPUNIT_ASSERT_EQUAL("42"s, integer.toString());
|
||||
integer.assignInteger(2);
|
||||
CPPUNIT_ASSERT_EQUAL("Country"s, string(Id3Genres::stringFromIndex(integer.toStandardGenreIndex())));
|
||||
integer.assignInteger(255);
|
||||
CPPUNIT_ASSERT_EQUAL(string(), string(Id3Genres::stringFromIndex(integer.toStandardGenreIndex())));
|
||||
integer.assignInteger(Id3Genres::emptyGenreIndex());
|
||||
CPPUNIT_ASSERT_EQUAL(Id3Genres::emptyGenreIndex(), integer.toStandardGenreIndex());
|
||||
integer.clearData();
|
||||
CPPUNIT_ASSERT_EQUAL(Id3Genres::emptyGenreIndex(), integer.toStandardGenreIndex());
|
||||
|
||||
// negative number
|
||||
integer.assignInteger(-25);
|
||||
|
|
Loading…
Reference in New Issue