Commit 336a80e1 authored by Bart van der Velden's avatar Bart van der Velden

Attempt to make a cleaner unit test fix by omitting the string literals (#65)

parent 60b83f40
......@@ -22,32 +22,31 @@ TagLib::FileName QStringToFileName(const QString& path)
#ifdef WIN32
return reinterpret_cast<const wchar_t*> (path.constData());
#else
QByteArray qba = QFile::encodeName(path);
int size = qstrlen(qba);
char* str = new char[size];
qstrcpy(str, qba.constData());
return str;
return QFile::encodeName(path).constData();
#endif
}
TEST(FileTypeResolverTest, EmptyPath)
{
FileTypeResolver ftr;
File* file = ftr.createFile(QStringToFileName(""));
QString fileName = "";
File* file = ftr.createFile(QStringToFileName(fileName));
EXPECT_EQ(0, file);
}
TEST(FileTypeResolverTest, FileDoesNotExist)
{
FileTypeResolver ftr;
File* file = ftr.createFile(QStringToFileName("ThisDoesNotExist"));
QString fileName = "ThisDoesNotExist";
File* file = ftr.createFile(QStringToFileName(fileName));
EXPECT_EQ(0, file);
}
TEST(FileTypeResolverTest, FileDoesNotExistMp3Ext)
{
FileTypeResolver ftr;
File* file = ftr.createFile(QStringToFileName("ThisDoesNotExist.mp3"));
QString fileName = "ThisDoesNotExist.mp3";
File* file = ftr.createFile(QStringToFileName(fileName));
ASSERT_TRUE(file != 0);
ASSERT_TRUE(dynamic_cast<MPEG::File*>(file) != 0);
ASSERT_FALSE(file->isOpen());
......@@ -56,8 +55,8 @@ TEST(FileTypeResolverTest, FileDoesNotExistMp3Ext)
TEST(FileTypeResolverTest, OggFileExists)
{
FileTypeResolver ftr;
//File* file = ftr.createFile(QFile::encodeName(datapath("test.ogg")).constData());
File* file = ftr.createFile(QStringToFileName(datapath("test.ogg")));
QString fileName = datapath("test.ogg");
File* file = ftr.createFile(QStringToFileName(fileName));
ASSERT_TRUE(file != 0);
ASSERT_TRUE(dynamic_cast<Ogg::Vorbis::File*>(file) != 0);
ASSERT_TRUE(file->isOpen());
......@@ -66,7 +65,8 @@ TEST(FileTypeResolverTest, OggFileExists)
TEST(FileTypeResolverTest, JapaneseOggFile)
{
FileTypeResolver ftr;
File* file = ftr.createFile(QStringToFileName(datapath("テスト.ogg")));
QString fileName = datapath("テスト.ogg");
File* file = ftr.createFile(QStringToFileName(fileName));
ASSERT_TRUE(file != 0);
ASSERT_TRUE(dynamic_cast<Ogg::Vorbis::File*>(file) != 0);
ASSERT_TRUE(file->isOpen());
......@@ -75,7 +75,8 @@ TEST(FileTypeResolverTest, JapaneseOggFile)
TEST(FileTypeResolverTest, ArabicOggFile)
{
FileTypeResolver ftr;
File* file = ftr.createFile(QStringToFileName(datapath("اختبار.ogg")));
QString fileName = datapath("اختبار.ogg");
File* file = ftr.createFile(QStringToFileName(fileName));
ASSERT_TRUE(file != 0);
ASSERT_TRUE(dynamic_cast<Ogg::Vorbis::File*>(file) != 0);
ASSERT_TRUE(file->isOpen());
......@@ -84,7 +85,8 @@ TEST(FileTypeResolverTest, ArabicOggFile)
TEST(FileTypeResolverTest, RussianOggFile)
{
FileTypeResolver ftr;
File* file = ftr.createFile(QStringToFileName(datapath("тест.ogg")));
QString fileName = datapath("тест.ogg");
File* file = ftr.createFile(QStringToFileName(fileName));
ASSERT_TRUE(file != 0);
ASSERT_TRUE(dynamic_cast<Ogg::Vorbis::File*>(file) != 0);
ASSERT_TRUE(file->isOpen());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment