diff options
author | Max Kellermann <max@duempel.org> | 2014-01-07 21:39:47 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2014-01-09 09:05:58 +0100 |
commit | 322b0616322760dc162447563d8f4da7e024ca90 (patch) | |
tree | 2f87cb3ce061556161797aba9f57ee08de5b9e21 /test | |
parent | 43847f2244a34064af24704aac4cfad4a3c76f7d (diff) |
DetachedSong: fork of struct Song
From now on, struct Song will be used by the database only, and
DetachedSong will be used by everybody else. DetachedSong is easier
to use, but Song has lower overhead.
Diffstat (limited to 'test')
-rw-r--r-- | test/DumpDatabase.cxx | 5 | ||||
-rw-r--r-- | test/dump_playlist.cxx | 34 | ||||
-rw-r--r-- | test/test_queue_priority.cxx | 41 |
3 files changed, 42 insertions, 38 deletions
diff --git a/test/DumpDatabase.cxx b/test/DumpDatabase.cxx index 14bb4ba14..6e9259238 100644 --- a/test/DumpDatabase.cxx +++ b/test/DumpDatabase.cxx @@ -49,7 +49,10 @@ DumpDirectory(const Directory &directory, Error &) static bool DumpSong(Song &song, Error &) { - cout << "S " << song.parent->path << "/" << song.uri << endl; + cout << "S "; + if (song.parent != nullptr && !song.parent->IsRoot()) + cout << song.parent->path << "/"; + cout << song.uri << endl; return true; } diff --git a/test/dump_playlist.cxx b/test/dump_playlist.cxx index 2ac855a84..b0702d3be 100644 --- a/test/dump_playlist.cxx +++ b/test/dump_playlist.cxx @@ -19,9 +19,8 @@ #include "config.h" #include "TagSave.hxx" -#include "Song.hxx" +#include "DetachedSong.hxx" #include "SongEnumerator.hxx" -#include "Directory.hxx" #include "InputStream.hxx" #include "ConfigGlobal.hxx" #include "DecoderList.hxx" @@ -39,14 +38,10 @@ #include <unistd.h> #include <stdlib.h> -Directory::Directory() {} -Directory::~Directory() {} - int main(int argc, char **argv) { const char *uri; InputStream *is = NULL; - Song *song; if (argc != 3) { fprintf(stderr, "Usage: dump_playlist CONFIG URI\n"); @@ -114,24 +109,27 @@ int main(int argc, char **argv) /* dump the playlist */ + DetachedSong *song; while ((song = playlist->NextSong()) != NULL) { - printf("%s\n", song->uri); + printf("%s\n", song->GetURI()); + + const unsigned start_ms = song->GetStartMS(); + const unsigned end_ms = song->GetEndMS(); - if (song->end_ms > 0) + if (end_ms > 0) printf("range: %u:%02u..%u:%02u\n", - song->start_ms / 60000, - (song->start_ms / 1000) % 60, - song->end_ms / 60000, - (song->end_ms / 1000) % 60); - else if (song->start_ms > 0) + start_ms / 60000, + (start_ms / 1000) % 60, + end_ms / 60000, + (end_ms / 1000) % 60); + else if (start_ms > 0) printf("range: %u:%02u..\n", - song->start_ms / 60000, - (song->start_ms / 1000) % 60); + start_ms / 60000, + (start_ms / 1000) % 60); - if (song->tag != NULL) - tag_save(stdout, *song->tag); + tag_save(stdout, song->GetTag()); - song->Free(); + delete song; } /* deinitialize everything */ diff --git a/test/test_queue_priority.cxx b/test/test_queue_priority.cxx index a1037798c..953103f9a 100644 --- a/test/test_queue_priority.cxx +++ b/test/test_queue_priority.cxx @@ -1,7 +1,6 @@ #include "config.h" #include "Queue.hxx" -#include "Song.hxx" -#include "Directory.hxx" +#include "DetachedSong.hxx" #include "util/Macros.hxx" #include <cppunit/TestFixture.h> @@ -9,21 +8,8 @@ #include <cppunit/ui/text/TestRunner.h> #include <cppunit/extensions/HelperMacros.h> -Directory detached_root; - -Directory::Directory() {} -Directory::~Directory() {} - -Song * -Song::DupDetached() const -{ - return const_cast<Song *>(this); -} - -void -Song::Free() -{ -} +Tag::Tag(const Tag &) {} +void Tag::Clear() {} static void check_descending_priority(const struct queue *queue, @@ -53,12 +39,29 @@ public: void QueuePriorityTest::TestPriority() { - static Song songs[16]; + DetachedSong songs[16] = { + DetachedSong("0.ogg"), + DetachedSong("1.ogg"), + DetachedSong("2.ogg"), + DetachedSong("3.ogg"), + DetachedSong("4.ogg"), + DetachedSong("5.ogg"), + DetachedSong("6.ogg"), + DetachedSong("7.ogg"), + DetachedSong("8.ogg"), + DetachedSong("9.ogg"), + DetachedSong("a.ogg"), + DetachedSong("b.ogg"), + DetachedSong("c.ogg"), + DetachedSong("d.ogg"), + DetachedSong("e.ogg"), + DetachedSong("f.ogg"), + }; struct queue queue(32); for (unsigned i = 0; i < ARRAY_SIZE(songs); ++i) - queue.Append(&songs[i], 0); + queue.Append(DetachedSong(songs[i]), 0); CPPUNIT_ASSERT_EQUAL(unsigned(ARRAY_SIZE(songs)), queue.GetLength()); |