Skip to content

Commit

Permalink
#413 Code smells fix
Browse files Browse the repository at this point in the history
Signed-off-by: Dimitri Baron <[email protected]>
  • Loading branch information
barondim committed Jul 11, 2024
1 parent d93be8e commit 6c6b0be
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
13 changes: 13 additions & 0 deletions sources/Common/DYNSimulationResult.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,19 @@ class SimulationResult {
*/
SimulationResult& operator=(const SimulationResult& result);

/**
* @brief move constructor
* @param result : result to move
*/
SimulationResult(SimulationResult&& result) = default;

/**
* @brief move operator
* @param result result to move
* @return new instance of simulationResult
*/
SimulationResult& operator=(SimulationResult&& result) = default;

/**
* @brief set the id of the scenario
* @param id id of the scenario
Expand Down
43 changes: 43 additions & 0 deletions sources/Common/test/TestBaseClasses.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,49 @@ TEST(TestBaseClasses, testSimulationResult) {
ASSERT_EQ(getStatusAsString(srCopy2.getStatus()), "EXECUTION_PROBLEM");
srCopy2.setStatus(CRITERIA_NON_RESPECTED_STATUS);
ASSERT_EQ(getStatusAsString(srCopy2.getStatus()), "CRITERIA_NON_RESPECTED");

sr.getConstraintsStream() << "Test Constraints";
sr.getTimelineStream() << "Test Timeline";
sr.getLostEquipementsStream() << "Test LostEquipements";
sr.setVariation(42);
sr.setConstraintsFileExtension("log");
sr.setTimelineFileExtension("log");
sr.setLostEquipmentsFileExtension("log");
sr.setLogPath("Test LogPath");
std::vector<std::pair<double, std::string> > failingCriteria;
failingCriteria.emplace_back({43, "Test FailingCriteria"});
sr.setFailingCriteria(failingCriteria);

SimulationResult srMove(std::move(sr));
ASSERT_EQ(srMove.getScenarioId(), "MyId");
ASSERT_TRUE(srMove.getSuccess());
ASSERT_EQ(srMove.getStatus(), CONVERGENCE_STATUS);
ASSERT_EQ(srMove.getConstraintsStreamStr(), "Test Constraints");
ASSERT_EQ(srMove.getTimelineStreamStr(), "Test Timeline");
ASSERT_EQ(srMove.getLostEquipementsStreamStr(), "Test LostEquipements");
ASSERT_EQ(srMove.getVariation(), 42);
ASSERT_EQ(srMove.getConstraintsFileExtension(), "log");
ASSERT_EQ(srMove.getTimelineFileExtension(), "log");
ASSERT_EQ(srMove.getLostEquipmentsFileExtension(), "log");
ASSERT_EQ(srMove.getLogPath(), "Test LogPath");
ASSERT_EQ(srMove.getFailingCriteria()[0].first, 43);
ASSERT_EQ(srMove.getFailingCriteria()[0].double, "Test FailingCriteria");

SimulationResult srMove2;
srMove2 = std::move(srMove);
ASSERT_EQ(srMove2.getScenarioId(), "MyId");
ASSERT_TRUE(srMove2.getSuccess());
ASSERT_EQ(srMove2.getStatus(), CONVERGENCE_STATUS);
ASSERT_EQ(srMove2.getConstraintsStreamStr(), "Test Constraints");
ASSERT_EQ(srMove2.getTimelineStreamStr(), "Test Timeline");
ASSERT_EQ(srMove2.getLostEquipementsStreamStr(), "Test LostEquipements");
ASSERT_EQ(srMove2.getVariation(), 42);
ASSERT_EQ(srMove2.getConstraintsFileExtension(), "log");
ASSERT_EQ(srMove2.getTimelineFileExtension(), "log");
ASSERT_EQ(srMove2.getLostEquipmentsFileExtension(), "log");
ASSERT_EQ(srMove2.getLogPath(), "Test LogPath");
ASSERT_EQ(srMove2.getFailingCriteria()[0].first, 43);
ASSERT_EQ(srMove2.getFailingCriteria()[0].double, "Test FailingCriteria");
}

TEST(TestBaseClasses, testLoadIncreaseResult) {
Expand Down

0 comments on commit 6c6b0be

Please sign in to comment.