aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--playlist.go4
-rw-r--r--playlist_test.go15
2 files changed, 18 insertions, 1 deletions
diff --git a/playlist.go b/playlist.go
index cb9c90c..bc410e3 100644
--- a/playlist.go
+++ b/playlist.go
@@ -65,13 +65,15 @@ func (pl *Playlist) RemoveSong(s *Song) {
func (pl *Playlist) OrderedList() []*Song {
songs := make([]*Song, 0, pl.Len())
- cpy := make(Playlist, 0, pl.Len())
+ cpy := make(Playlist, pl.Len())
copy(cpy, *pl)
+ llog.DDebug("copying %v returned %v", *pl, cpy)
for cpy.Len() > 0 {
songs = append(songs, heap.Pop(&cpy).(*Song))
}
+ llog.DDebug("ordering queue %v returned %v", pl, songs)
return songs
}
diff --git a/playlist_test.go b/playlist_test.go
index 8730737..bb236ee 100644
--- a/playlist_test.go
+++ b/playlist_test.go
@@ -133,3 +133,18 @@ func TestPlAdd3AdjustAdjustPop(t *testing.T) {
t.Fail()
}
}
+
+func TestPlOrderedList(t *testing.T) {
+ var pl Playlist
+ s := NewDummySong("Foo", "Bar")
+ pl.Add(s)
+ l := pl.OrderedList()
+ if len(pl) != len(l) {
+ t.Log("size of pl and ordered list differs")
+ t.Fail()
+ }
+ if pl[0] != l[0] {
+ t.Log("element of pl and ordered list differs")
+ t.Fail()
+ }
+}