Fix upgrading of ID3v2.3 genre with number 0 (Blues)

git-svn-id: svn://anonsvn.kde.org/home/kde/trunk/kdesupport/taglib@1114089 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
This commit is contained in:
Lukáš Lalinský
2010-04-12 18:27:59 +00:00
parent d5eb51e452
commit 19b2341411
5 changed files with 61 additions and 19 deletions

View File

@ -40,6 +40,7 @@ class TestString : public CppUnit::TestFixture
CPPUNIT_TEST(testUTF16DecodeEmptyWithBOM);
CPPUNIT_TEST(testAppendCharDetach);
CPPUNIT_TEST(testAppendStringDetach);
CPPUNIT_TEST(testToInt);
CPPUNIT_TEST_SUITE_END();
public:
@ -165,6 +166,33 @@ public:
CPPUNIT_ASSERT_EQUAL(3, String("foo.bar").rfind("."));
}
void testToInt()
{
bool ok;
CPPUNIT_ASSERT_EQUAL(String("123").toInt(&ok), 123);
CPPUNIT_ASSERT_EQUAL(ok, true);
CPPUNIT_ASSERT_EQUAL(String("-123").toInt(&ok), -123);
CPPUNIT_ASSERT_EQUAL(ok, true);
CPPUNIT_ASSERT_EQUAL(String("abc").toInt(&ok), 0);
CPPUNIT_ASSERT_EQUAL(ok, false);
CPPUNIT_ASSERT_EQUAL(String("1x").toInt(&ok), 1);
CPPUNIT_ASSERT_EQUAL(ok, false);
CPPUNIT_ASSERT_EQUAL(String("").toInt(&ok), 0);
CPPUNIT_ASSERT_EQUAL(ok, false);
CPPUNIT_ASSERT_EQUAL(String("-").toInt(&ok), 0);
CPPUNIT_ASSERT_EQUAL(ok, false);
CPPUNIT_ASSERT_EQUAL(String("123").toInt(), 123);
CPPUNIT_ASSERT_EQUAL(String("-123").toInt(), -123);
CPPUNIT_ASSERT_EQUAL(String("123aa").toInt(), 123);
CPPUNIT_ASSERT_EQUAL(String("-123aa").toInt(), -123);
}
};
CPPUNIT_TEST_SUITE_REGISTRATION(TestString);