Skip to content

Commit

Permalink
volcartesian: properly update patch data structures when switching me…
Browse files Browse the repository at this point in the history
…mory mode
  • Loading branch information
andrea-iob committed Jul 1, 2024
1 parent 8c7b514 commit b27524e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/volcartesian/volcartesian.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -957,6 +957,13 @@ void VolCartesian::switchMemoryMode(MemoryMode mode)

// Set the requested memory mode
setMemoryMode(mode);

// Update the patch
//
// This will update all data structures (e.g., the interface) associated with the patch.
if (mode == MemoryMode::MEMORY_NORMAL) {
update();
}
}

/*!
Expand Down
15 changes: 14 additions & 1 deletion test/unit_tests/volcartesian/test_volcartesian_general.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ BOOST_FIXTURE_TEST_CASE(method_getSpacing_2, NormalTestPatch)
}
}

BOOST_FIXTURE_TEST_CASE(method_switchMemoryMode, NormalTestPatch)
BOOST_FIXTURE_TEST_CASE(method_switchMemoryMode_1, NormalTestPatch)
{
BITPIT_UNIT_TEST_DISPLAY_NAME(log::cout());

Expand All @@ -100,6 +100,19 @@ BOOST_FIXTURE_TEST_CASE(method_switchMemoryMode, NormalTestPatch)
}
}

BOOST_FIXTURE_TEST_CASE(method_switchMemoryMode_2, LightTestPatch)
{
BITPIT_UNIT_TEST_DISPLAY_NAME(log::cout());

const VolCartesian::MemoryMode EXPECTED_RESULT = VolCartesian::MEMORY_NORMAL;

patch->switchMemoryMode(VolCartesian::MEMORY_NORMAL);
VolCartesian::MemoryMode result = patch->getMemoryMode();
if (result != EXPECTED_RESULT) {
throw std::runtime_error("Function 'switchMemoryMode(MemoryMode mode)' failed unit test.");
}
}

BOOST_FIXTURE_TEST_CASE(method_getMemoryMode, NormalTestPatch)
{
BITPIT_UNIT_TEST_DISPLAY_NAME(log::cout());
Expand Down

0 comments on commit b27524e

Please sign in to comment.