From 46534fb2ffa05140d64a5bcdbf492316678e151f Mon Sep 17 00:00:00 2001 From: Katie Mummah Date: Wed, 22 Nov 2023 12:51:11 -0700 Subject: [PATCH] tests for random uniform and normal --- src/sink_tests.cc | 74 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 71 insertions(+), 3 deletions(-) diff --git a/src/sink_tests.cc b/src/sink_tests.cc index 389177a270..de06e87314 100644 --- a/src/sink_tests.cc +++ b/src/sink_tests.cc @@ -45,7 +45,7 @@ TEST_F(SinkTest, InitialState) { EXPECT_DOUBLE_EQ(0.0, src_facility->InventorySize()); EXPECT_DOUBLE_EQ(capacity_, src_facility->Capacity()); EXPECT_DOUBLE_EQ(inv_, src_facility->MaxInventorySize()); - EXPECT_DOUBLE_EQ(capacity_, src_facility->RequestAmt()); + EXPECT_DOUBLE_EQ(capacity_, src_facility->SpaceAvailable()); EXPECT_DOUBLE_EQ(0.0, src_facility->InventorySize()); std::string arr[] = {commod1_, commod2_}; std::vector vexp (arr, arr + sizeof(arr) / sizeof(arr[0]) ); @@ -66,7 +66,7 @@ TEST_F(SinkTest, Clone) { EXPECT_DOUBLE_EQ(0.0, cloned_fac->InventorySize()); EXPECT_DOUBLE_EQ(capacity_, cloned_fac->Capacity()); EXPECT_DOUBLE_EQ(inv_, cloned_fac->MaxInventorySize()); - EXPECT_DOUBLE_EQ(capacity_, cloned_fac->RequestAmt()); + EXPECT_DOUBLE_EQ(capacity_, cloned_fac->SpaceAvailable()); std::string arr[] = {commod1_, commod2_}; std::vector vexp (arr, arr + sizeof(arr) / sizeof(arr[0]) ); EXPECT_EQ(vexp, cloned_fac->input_commodities()); @@ -104,7 +104,7 @@ TEST_F(SinkTest, DISABLED_XMLInit) { EXPECT_EQ(vexp, fac.input_commodities()); EXPECT_DOUBLE_EQ(capacity_, fac.Capacity()); EXPECT_DOUBLE_EQ(inv_, fac.MaxInventorySize()); - EXPECT_DOUBLE_EQ(capacity_, fac.RequestAmt()); + EXPECT_DOUBLE_EQ(capacity_, fac.SpaceAvailable()); EXPECT_DOUBLE_EQ(0.0, fac.InventorySize()); } @@ -342,6 +342,74 @@ TEST_F(SinkTest, PositionInitialize2) { } +TEST_F(SinkTest, RandomUniform) { + using cyclus::QueryResult; + using cyclus::Cond; + + std::string config = + " " + " commods_1" + " " + " 10" + " UniformReal "; + + int simdur = 1; + cyclus::MockSim sim(cyclus::AgentSpec + (":cycamore:Sink"), config, simdur); + sim.AddSource("commods_1").capacity(10).Finalize(); + int id = sim.Run(); + + QueryResult qr = sim.db().Query("Resources", NULL); + EXPECT_EQ(qr.rows.size(), 1); + EXPECT_NEAR(qr.GetVal("Quantity"), 9.41273, 0.0001); +} + +TEST_F(SinkTest, RandomNormal) { + using cyclus::QueryResult; + using cyclus::Cond; + + std::string config = + " " + " commods_1" + " " + " 10" + " NormalReal "; + + int simdur = 1; + cyclus::MockSim sim(cyclus::AgentSpec + (":cycamore:Sink"), config, simdur); + sim.AddSource("commods_1").capacity(10).Finalize(); + int id = sim.Run(); + + QueryResult qr = sim.db().Query("Resources", NULL); + EXPECT_EQ(qr.rows.size(), 1); + EXPECT_NEAR(qr.GetVal("Quantity"), 9.60929, 0.0001); +} + +TEST_F(SinkTest, RandomNormalWithMeanSttdev) { + using cyclus::QueryResult; + using cyclus::Cond; + + std::string config = + " " + " commods_1" + " " + " 10" + " NormalReal " + " 0.5 " + " 0.2 "; + + int simdur = 1; + cyclus::MockSim sim(cyclus::AgentSpec + (":cycamore:Sink"), config, simdur); + sim.AddSource("commods_1").capacity(10).Finalize(); + int id = sim.Run(); + + QueryResult qr = sim.db().Query("Resources", NULL); + EXPECT_EQ(qr.rows.size(), 1); + EXPECT_NEAR(qr.GetVal("Quantity"), 1.52979, 0.0001); +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - cyclus::Agent* SinkConstructor(cyclus::Context* ctx) { return new cycamore::Sink(ctx);