diff --git a/src/storage_tests.cc b/src/storage_tests.cc
index a8d14f47c..d85c90765 100644
--- a/src/storage_tests.cc
+++ b/src/storage_tests.cc
@@ -873,10 +873,10 @@ TEST_F(StorageTest, CCap_Inventory) {
}
TEST_F(StorageTest, PackageExactly) {
+ // resource can be packaged without splitting or merging
std::string config =
" spent_fuel "
" dry_spent "
- " 10 "
" foo";
int simdur = 3;
@@ -893,6 +893,7 @@ TEST_F(StorageTest, PackageExactly) {
std::vector tr_conds;
tr_conds.push_back(cyclus::Cond("Commodity", "==", std::string("dry_spent")));
cyclus::QueryResult qr_trans = sim.db().Query("Transactions", &tr_conds);
+ // two transactions out of storage, happening at time 1 and 2
EXPECT_EQ(2, qr_trans.rows.size());
EXPECT_EQ(1, qr_trans.GetVal("Time", 0));
@@ -901,17 +902,17 @@ TEST_F(StorageTest, PackageExactly) {
std::vector res_conds;
res_conds.push_back(cyclus::Cond("PackageName", "==", p->name()));
cyclus::QueryResult qr_res = sim.db().Query("Resources", &res_conds);
+ // two resources that have been packaged, each of size two
EXPECT_EQ(qr_res.rows.size(), 2);
- // Given the PRNG with default seed, the resource should have mass 9.41273
EXPECT_EQ(qr_res.GetVal("Quantity", 0), 2);
EXPECT_EQ(qr_res.GetVal("Quantity", 1), 2);
}
TEST_F(StorageTest, PackageSplitEqual) {
+ // Resources must be split into two to package. Packaging strategy equal
std::string config =
" commodity "
" commodity1 "
- " 10 "
" foo";
int simdur = 3;
@@ -928,6 +929,8 @@ TEST_F(StorageTest, PackageSplitEqual) {
std::vector tr_conds;
tr_conds.push_back(cyclus::Cond("Commodity", "==", std::string("commodity1")));
cyclus::QueryResult qr_trans = sim.db().Query("Transactions", &tr_conds);
+ // four transactions out of storage. Each resource is split, so two
+ // transactions at time 1, two at time 2
EXPECT_EQ(4, qr_trans.rows.size());
EXPECT_EQ(1, qr_trans.GetVal("Time", 0));
@@ -938,11 +941,53 @@ TEST_F(StorageTest, PackageSplitEqual) {
std::vector res_conds;
res_conds.push_back(cyclus::Cond("PackageName", "==", p->name()));
cyclus::QueryResult qr_res = sim.db().Query("Resources", &res_conds);
+ // because package does split-equally, resources are all of size 1.5 (3/2)
EXPECT_EQ(qr_res.rows.size(), 4);
- EXPECT_EQ(qr_res.GetVal("Quantity", 0), 1.5);
- EXPECT_EQ(qr_res.GetVal("Quantity", 1), 1.5);
- EXPECT_EQ(qr_res.GetVal("Quantity", 2), 1.5);
- EXPECT_EQ(qr_res.GetVal("Quantity", 2), 1.5);
+ EXPECT_EQ(1.5, qr_res.GetVal("Quantity", 0));
+ EXPECT_EQ(1.5, qr_res.GetVal("Quantity", 1));
+ EXPECT_EQ(1.5, qr_res.GetVal("Quantity", 2));
+ EXPECT_EQ(1.5, qr_res.GetVal("Quantity", 3));
+}
+
+TEST_F(StorageTest, PackageSplitFirst) {
+ // Resources must be split into two to package. Packaging strategy first
+ std::string config =
+ " commodity "
+ " commodity1 "
+ " foo";
+
+ int simdur = 3;
+
+ cyclus::MockSim sim(cyclus::AgentSpec (":cycamore:Storage"), config, simdur);
+ sim.context()->AddPackage("foo", 1, 2, "first");
+ cyclus::Package::Ptr p = sim.context()->GetPackage("foo");
+
+ sim.AddSource("commodity").capacity(3).Finalize();
+ sim.AddSink("commodity1").Finalize();
+
+ int id = sim.Run();
+
+ std::vector tr_conds;
+ tr_conds.push_back(cyclus::Cond("Commodity", "==", std::string("commodity1")));
+ cyclus::QueryResult qr_trans = sim.db().Query("Transactions", &tr_conds);
+ // four transactions out of storage. Each resource is split, so two
+ // transactions at time 1, two at time 2
+ EXPECT_EQ(4, qr_trans.rows.size());
+
+ EXPECT_EQ(1, qr_trans.GetVal("Time", 0));
+ EXPECT_EQ(1, qr_trans.GetVal("Time", 1));
+ EXPECT_EQ(2, qr_trans.GetVal("Time", 2));
+ EXPECT_EQ(2, qr_trans.GetVal("Time", 3));
+
+ std::vector res_conds;
+ res_conds.push_back(cyclus::Cond("PackageName", "==", p->name()));
+ 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));
}
TEST_F(StorageTest, PackageMerge) {
@@ -967,6 +1012,9 @@ TEST_F(StorageTest, PackageMerge) {
tr_conds.push_back(cyclus::Cond("Commodity", "==", std::string("commodity1")));
cyclus::QueryResult qr_trans = sim.db().Query("Transactions", &tr_conds);
+ // two transactions out of storage. Because the source only provides 0.5 each
+ // time step, it takes two time steps to acquire enough material to package.
+ // Therefore transactions at time 2 and 4
EXPECT_EQ(2, qr_trans.rows.size());
EXPECT_EQ(2, qr_trans.GetVal("Time", 0));
@@ -975,6 +1023,7 @@ TEST_F(StorageTest, PackageMerge) {
std::vector res_conds;
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("Quantity", 0), 1);
EXPECT_EQ(qr_res.GetVal("Quantity", 1), 1);