From 6e0c5f99cbfd557309da66126d9aceaf24cef57a Mon Sep 17 00:00:00 2001 From: Oliver Hamlet Date: Sun, 23 Jun 2019 11:14:33 +0100 Subject: [PATCH] Improve sorting stability test --- .../api/internals/sorting/plugin_sorter_test.h | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/tests/api/internals/sorting/plugin_sorter_test.h b/src/tests/api/internals/sorting/plugin_sorter_test.h index b1002ad3..33cdcd3e 100644 --- a/src/tests/api/internals/sorting/plugin_sorter_test.h +++ b/src/tests/api/internals/sorting/plugin_sorter_test.h @@ -179,14 +179,11 @@ TEST_P(PluginSorterTest, PluginSorter ps; std::vector expectedSortedOrder = getLoadOrder(); - std::vector sorted = ps.Sort(game_); - EXPECT_TRUE( - std::equal(begin(sorted), end(sorted), begin(expectedSortedOrder))); - - // Check stability. - sorted = ps.Sort(game_); - EXPECT_TRUE( - std::equal(begin(sorted), end(sorted), begin(expectedSortedOrder))); + // Check stability by running the sort 100 times. + for (int i = 0; i < 100; i++) { + std::vector sorted = ps.Sort(game_); + ASSERT_EQ(expectedSortedOrder, sorted) << " for sort " << i; + } } TEST_P(PluginSorterTest, sortingShouldResolveGroupsAsTransitiveLoadAfterSets) {