diff --git a/src/storage_tests.cc b/src/storage_tests.cc index d85c90765..7a66496fb 100644 --- a/src/storage_tests.cc +++ b/src/storage_tests.cc @@ -984,10 +984,22 @@ TEST_F(StorageTest, PackageSplitFirst) { cyclus::QueryResult qr_res = sim.db().Query("Resources", &res_conds); // because package does split-first, resources are size 2 and 1 EXPECT_EQ(qr_res.rows.size(), 4); - EXPECT_EQ(2, qr_res.GetVal("Quantity", 0)); - EXPECT_EQ(1, qr_res.GetVal("Quantity", 1)); - EXPECT_EQ(2, qr_res.GetVal("Quantity", 2)); - EXPECT_EQ(1, qr_res.GetVal("Quantity", 3)); + + // order of trade execution is not guaranteed. Therefore, create vector, + // sort by size, and then check values + std::vector pkgd_t0 = {qr_res.GetVal("Quantity", 0), + qr_res.GetVal("Quantity", 1)}; + std::sort(pkgd_t0.begin(), pkgd_t0.end(), std::greater()); + std::vector exp_t0 = {2, 1}; + + EXPECT_EQ(exp_t0, pkgd_t0); + + std::vector pkgd_t1 = {qr_res.GetVal("Quantity", 2), + qr_res.GetVal("Quantity", 3)}; + std::sort(pkgd_t1.begin(), pkgd_t1.end(), std::greater()); + std::vector exp_t1 = {2, 1}; + + EXPECT_EQ(exp_t1, pkgd_t1); } TEST_F(StorageTest, PackageMerge) {