change default overlapping note strategy to "relax" (i.e. do nothing); fix crash...
[ardour2.git] / libs / taglib / tests / test_fileref.cpp
blob0752c08a4383732e343fb08b44f1e4676d835907
1 #include <cppunit/extensions/HelperMacros.h>
2 #include <string>
3 #include <stdio.h>
4 #include <tag.h>
5 #include <fileref.h>
6 #include "utils.h"
8 using namespace std;
9 using namespace TagLib;
11 class TestFileRef : public CppUnit::TestFixture
13 CPPUNIT_TEST_SUITE(TestFileRef);
14 CPPUNIT_TEST(testMusepack);
15 CPPUNIT_TEST(testVorbis);
16 CPPUNIT_TEST(testSpeex);
17 CPPUNIT_TEST(testFLAC);
18 CPPUNIT_TEST(testMP3);
19 CPPUNIT_TEST(testTrueAudio);
20 CPPUNIT_TEST_SUITE_END();
22 public:
24 void fileRefSave(const string &filename, const string &ext)
26 string newname = copyFile(filename, ext);
28 FileRef *f = new FileRef(newname.c_str());
29 CPPUNIT_ASSERT(!f->isNull());
30 f->tag()->setArtist("test artist");
31 f->tag()->setTitle("test title");
32 f->tag()->setGenre("Test!");
33 f->tag()->setAlbum("albummmm");
34 f->tag()->setTrack(5);
35 f->tag()->setYear(2020);
36 f->save();
37 delete f;
39 f = new FileRef(newname.c_str());
40 CPPUNIT_ASSERT(!f->isNull());
41 CPPUNIT_ASSERT_EQUAL(f->tag()->artist(), String("test artist"));
42 CPPUNIT_ASSERT_EQUAL(f->tag()->title(), String("test title"));
43 CPPUNIT_ASSERT_EQUAL(f->tag()->genre(), String("Test!"));
44 CPPUNIT_ASSERT_EQUAL(f->tag()->album(), String("albummmm"));
45 CPPUNIT_ASSERT_EQUAL(f->tag()->track(), TagLib::uint(5));
46 CPPUNIT_ASSERT_EQUAL(f->tag()->year(), TagLib::uint(2020));
47 f->tag()->setArtist("ttest artist");
48 f->tag()->setTitle("ytest title");
49 f->tag()->setGenre("uTest!");
50 f->tag()->setAlbum("ialbummmm");
51 f->tag()->setTrack(7);
52 f->tag()->setYear(2080);
53 f->save();
54 delete f;
56 f = new FileRef(newname.c_str());
57 CPPUNIT_ASSERT(!f->isNull());
58 CPPUNIT_ASSERT_EQUAL(f->tag()->artist(), String("ttest artist"));
59 CPPUNIT_ASSERT_EQUAL(f->tag()->title(), String("ytest title"));
60 CPPUNIT_ASSERT_EQUAL(f->tag()->genre(), String("uTest!"));
61 CPPUNIT_ASSERT_EQUAL(f->tag()->album(), String("ialbummmm"));
62 CPPUNIT_ASSERT_EQUAL(f->tag()->track(), TagLib::uint(7));
63 CPPUNIT_ASSERT_EQUAL(f->tag()->year(), TagLib::uint(2080));
64 delete f;
66 deleteFile(newname);
69 void testMusepack()
71 fileRefSave("click", ".mpc");
74 void testVorbis()
76 fileRefSave("empty", ".ogg");
79 void testSpeex()
81 fileRefSave("empty", ".spx");
84 void testFLAC()
86 fileRefSave("no-tags", ".flac");
89 void testMP3()
91 fileRefSave("xing", ".mp3");
94 void testTrueAudio()
96 fileRefSave("empty", ".tta");
101 CPPUNIT_TEST_SUITE_REGISTRATION(TestFileRef);