Fix conversion from PositionInSet to integer
Even though there was already a test verifying that it is not possible.
This commit is contained in:
parent
f687618002
commit
ff1eaadc88
|
@ -192,8 +192,12 @@ int32 TagValue::toInteger() const
|
||||||
ensureHostByteOrder(u16str, m_encoding);
|
ensureHostByteOrder(u16str, m_encoding);
|
||||||
return ConversionUtilities::stringToNumber<int32>(u16str);
|
return ConversionUtilities::stringToNumber<int32>(u16str);
|
||||||
}
|
}
|
||||||
case TagDataType::Integer:
|
|
||||||
case TagDataType::PositionInSet:
|
case TagDataType::PositionInSet:
|
||||||
|
if (m_size == sizeof(PositionInSet)) {
|
||||||
|
return *reinterpret_cast<std::int32_t *>(m_ptr.get());
|
||||||
|
}
|
||||||
|
throw ConversionException("Can not convert assigned data to integer because the data size is not appropriate.");
|
||||||
|
case TagDataType::Integer:
|
||||||
case TagDataType::StandardGenreIndex:
|
case TagDataType::StandardGenreIndex:
|
||||||
if (m_size == sizeof(int32)) {
|
if (m_size == sizeof(int32)) {
|
||||||
return *reinterpret_cast<int32 *>(m_ptr.get());
|
return *reinterpret_cast<int32 *>(m_ptr.get());
|
||||||
|
|
|
@ -116,7 +116,7 @@ void TagValueTests::testPositionInSet()
|
||||||
{
|
{
|
||||||
const TagValue test(PositionInSet(4, 23));
|
const TagValue test(PositionInSet(4, 23));
|
||||||
CPPUNIT_ASSERT_EQUAL(PositionInSet(4, 23), test.toPositionInSet());
|
CPPUNIT_ASSERT_EQUAL(PositionInSet(4, 23), test.toPositionInSet());
|
||||||
CPPUNIT_ASSERT_THROW(test.toInteger(), ConversionException);
|
CPPUNIT_ASSERT_EQUAL(test.toInteger(), 4);
|
||||||
CPPUNIT_ASSERT_EQUAL("4/23"s, test.toString());
|
CPPUNIT_ASSERT_EQUAL("4/23"s, test.toString());
|
||||||
CPPUNIT_ASSERT_THROW(test.toStandardGenreIndex(), ConversionException);
|
CPPUNIT_ASSERT_THROW(test.toStandardGenreIndex(), ConversionException);
|
||||||
CPPUNIT_ASSERT_THROW(test.toDateTime(), ConversionException);
|
CPPUNIT_ASSERT_THROW(test.toDateTime(), ConversionException);
|
||||||
|
|
Loading…
Reference in New Issue