From 7471cb64e9b7d8e6b1cabb07751181bbfdf3237c Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Fri, 28 Jul 2023 13:07:16 +0200 Subject: fix copying of the playlist when creating an ordered list Go's copy builtin does only copy min(len(dest), len(src)) elements, since we create an empty destination slice with a big enough capacity copy does not actually copy anything. --- playlist_test.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'playlist_test.go') 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() + } +} -- cgit v1.2.3