Skip to content

Commit

Permalink
Merge pull request #612 from nuclearkatie/packaging_order
Browse files Browse the repository at this point in the history
cannot assume order of packaged material
  • Loading branch information
gonuke authored Jun 12, 2024
2 parents 718bcd7 + ee40b8c commit 1a670d2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ Since last release
======================

**Added:**
* Added package parameter to storage (#603, #612)

**Changed:**

* Rely on ``python3`` in environment instead of ``python`` (#602)
* Link against ``libxml++`` imported target in CMake instead of ``LIBXMLXX_LIBRARIES`` (#608)
* Cleaned up ``using`` declarations throughout archetypes (#610)
* Added package parameter to storage (#603)

**Fixed:**

Expand Down
26 changes: 19 additions & 7 deletions src/storage_tests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<double>("Quantity", 0));
EXPECT_EQ(1, qr_res.GetVal<double>("Quantity", 1));
EXPECT_EQ(2, qr_res.GetVal<double>("Quantity", 2));
EXPECT_EQ(1, qr_res.GetVal<double>("Quantity", 3));

// order of trade execution is not guaranteed. Therefore, create vector,
// sort by size, and then check values
std::vector<double> pkgd_t0 = {qr_res.GetVal<double>("Quantity", 0),
qr_res.GetVal<double>("Quantity", 1)};
std::sort(pkgd_t0.begin(), pkgd_t0.end(), std::greater<double>());
std::vector<double> exp_t0 = {2, 1};

EXPECT_EQ(exp_t0, pkgd_t0);

std::vector<double> pkgd_t1 = {qr_res.GetVal<double>("Quantity", 2),
qr_res.GetVal<double>("Quantity", 3)};
std::sort(pkgd_t1.begin(), pkgd_t1.end(), std::greater<double>());
std::vector<double> exp_t1 = {2, 1};

EXPECT_EQ(exp_t1, pkgd_t1);
}

TEST_F(StorageTest, PackageMerge) {
Expand Down Expand Up @@ -1024,9 +1036,9 @@ TEST_F(StorageTest, PackageMerge) {
res_conds.push_back(cyclus::Cond("PackageName", "==", p->name()));
cyclus::QueryResult qr_res = sim.db().Query("Resources", &res_conds);
// Combines two 0.5 mass resources to make packages with mass 1
EXPECT_EQ(qr_res.rows.size(), 2);
EXPECT_EQ(qr_res.GetVal<double>("Quantity", 0), 1);
EXPECT_EQ(qr_res.GetVal<double>("Quantity", 1), 1);
EXPECT_EQ(2, qr_res.rows.size());
EXPECT_EQ(1, qr_res.GetVal<double>("Quantity", 0));
EXPECT_EQ(1, qr_res.GetVal<double>("Quantity", 1));
}

} // namespace cycamore
Expand Down

0 comments on commit 1a670d2

Please sign in to comment.