Fix some set-but-not-used variable warnings from gcc 4.6
[ardour.git] / libs / taglib / tests / test_fileref.cpp
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"
7
8 using namespace std;
9 using namespace TagLib;
10
11 class TestFileRef : public CppUnit::TestFixture
12 {
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();
21
22 public:
23
24   void fileRefSave(const string &filename, const string &ext)
25   {
26     string newname = copyFile(filename, ext);
27
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;
38
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;
55
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;
65
66     deleteFile(newname);
67   }
68
69   void testMusepack()
70   {
71     fileRefSave("click", ".mpc");
72   }
73
74   void testVorbis()
75   {
76     fileRefSave("empty", ".ogg");
77   }
78
79   void testSpeex()
80   {
81     fileRefSave("empty", ".spx");
82   }
83
84   void testFLAC()
85   {
86     fileRefSave("no-tags", ".flac");
87   }
88
89   void testMP3()
90   {
91     fileRefSave("xing", ".mp3");
92   }
93
94   void testTrueAudio()
95   {
96     fileRefSave("empty", ".tta");
97   }
98
99 };
100
101 CPPUNIT_TEST_SUITE_REGISTRATION(TestFileRef);