|
1 | 1 | #include "deploy_inst_tests.h" |
2 | | - |
| 2 | +#include "error.h" |
| 3 | +#include "deploy_inst.h" |
3 | 4 | // make sure that the deployed agent's prototype name is identical to the |
4 | 5 | // originally specified prototype name - this is important to test because |
5 | 6 | // DeployInst does some mucking around with registering name-modded prototypes |
@@ -154,6 +155,65 @@ TEST_F(DeployInstTests, NoDupProtos) { |
154 | 155 | EXPECT_EQ(1, stmt->GetInt(0)); |
155 | 156 | } |
156 | 157 |
|
| 158 | +TEST_F(DeployInstTests, DeployYear) { |
| 159 | + std::string config = |
| 160 | + "<prototypes> <val>foobar</val> </prototypes>" |
| 161 | + "<build_times> <val>2</val> </build_times>" |
| 162 | + "<n_build> <val>3</val> </n_build>" |
| 163 | + "<deployyear> 2012 </deployyear>" |
| 164 | + ; |
| 165 | + |
| 166 | + int simdur = 30; |
| 167 | + //MockSim starts in 2010 by default |
| 168 | + cyclus::MockSim sim(cyclus::AgentSpec(":cycamore:DeployInst"), config, simdur); |
| 169 | + sim.DummyProto("foobar"); |
| 170 | + int id = sim.Run(); |
| 171 | + // 2 years and 2 months after MockSim start is 25 time steps |
| 172 | + cyclus::SqlStatement::Ptr stmt = sim.db().db().Prepare( |
| 173 | + "SELECT COUNT(*) FROM AgentEntry WHERE Prototype = 'foobar' AND EnterTime = '25';" |
| 174 | + ); |
| 175 | + stmt->Step(); |
| 176 | + EXPECT_EQ(3, stmt->GetInt(0)); |
| 177 | +} |
| 178 | + |
| 179 | +TEST_F(DeployInstTests, DeployYearEarlyError) { |
| 180 | + std::string config = |
| 181 | + "<prototypes> <val>foobar</val> </prototypes>" |
| 182 | + "<build_times> <val>2</val> </build_times>" |
| 183 | + "<n_build> <val>3</val> </n_build>" |
| 184 | + "<deployyear> 2000 </deployyear>" |
| 185 | + ; |
| 186 | + |
| 187 | + int simdur = 5; |
| 188 | + cyclus::MockSim sim(cyclus::AgentSpec(":cycamore:DeployInst"), config, simdur); |
| 189 | + |
| 190 | + EXPECT_THROW(sim.Run(),cyclus::ValueError); |
| 191 | +} |
| 192 | + |
| 193 | +TEST_F(DeployInstTests, DeployYearLateWarn) { |
| 194 | + std::string config = |
| 195 | + "<prototypes> <val>foobar</val> </prototypes>" |
| 196 | + "<build_times> <val>2</val> </build_times>" |
| 197 | + "<n_build> <val>3</val> </n_build>" |
| 198 | + "<deployyear> 2030 </deployyear>" |
| 199 | + ; |
| 200 | + |
| 201 | + int simdur = 5; |
| 202 | + cyclus::MockSim sim(cyclus::AgentSpec(":cycamore:DeployInst"), config, simdur); |
| 203 | + |
| 204 | + cyclus::warn_as_error = true; |
| 205 | + EXPECT_THROW(sim.Run(), |
| 206 | + cyclus::ValueError); |
| 207 | + cyclus::warn_as_error = false; |
| 208 | + |
| 209 | + int id = sim.Run(); |
| 210 | + cyclus::SqlStatement::Ptr stmt = sim.db().db().Prepare( |
| 211 | + "SELECT COUNT(*) FROM AgentEntry WHERE Prototype = 'foobar';" |
| 212 | + ); |
| 213 | + stmt->Step(); |
| 214 | + EXPECT_EQ(0, stmt->GetInt(0)); |
| 215 | +} |
| 216 | + |
157 | 217 | TEST_F(DeployInstTests, PositionInitialize) { |
158 | 218 | std::string config = |
159 | 219 | "<prototypes> <val>foobar</val> </prototypes>" |
|
0 commit comments