[vlc-commits] randomizer: add unit test for history cursor

Romain Vimont git at videolan.org
Wed May 22 21:44:28 CEST 2019


vlc | branch: master | Romain Vimont <rom1v at videolabs.io> | Wed May 15 17:22:08 2019 +0200| [bc4180a05d9b2fc438099bd40efc0a05ab7ab18e] | committer: Jean-Baptiste Kempf

randomizer: add unit test for history cursor

This will avoid regression of bug #22305.

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=bc4180a05d9b2fc438099bd40efc0a05ab7ab18e
---

 src/playlist/randomizer.c | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

diff --git a/src/playlist/randomizer.c b/src/playlist/randomizer.c
index 1bbf14c55b..2da77b84fd 100644
--- a/src/playlist/randomizer.c
+++ b/src/playlist/randomizer.c
@@ -744,6 +744,37 @@ test_all_items_selected_exactly_once_with_removals(void)
 }
 
 static void
+test_cycle_after_manual_selection(void)
+{
+    struct randomizer randomizer;
+    randomizer_Init(&randomizer);
+    randomizer_SetLoop(&randomizer, true);
+
+    #define SIZE 100
+    vlc_playlist_item_t *items[SIZE];
+    ArrayInit(items, SIZE);
+
+    bool ok = randomizer_Add(&randomizer, items, 100);
+    assert(ok);
+
+    /* force selection of the first item */
+    randomizer_Select(&randomizer, randomizer.items.data[0]);
+
+    for (int i = 0; i < 2 * SIZE; ++i)
+    {
+        assert(randomizer_HasNext(&randomizer));
+        vlc_playlist_item_t *item = randomizer_Next(&randomizer);
+        assert(item);
+    }
+
+    assert(randomizer_HasNext(&randomizer)); /* still has items in loop */
+
+    ArrayDestroy(items, SIZE);
+    randomizer_Destroy(&randomizer);
+    #undef SIZE
+}
+
+static void
 test_force_select_new_item(void)
 {
     struct randomizer randomizer;
@@ -1111,6 +1142,7 @@ int main(void)
     test_all_items_selected_exactly_once_per_cycle();
     test_all_items_selected_exactly_once_with_additions();
     test_all_items_selected_exactly_once_with_removals();
+    test_cycle_after_manual_selection();
     test_force_select_new_item();
     test_force_select_item_already_selected();
     test_prev();



More information about the vlc-commits mailing list