Move initialisations to simplify cancelled checks

This commit is contained in:
Jack Grigg
2016-07-22 23:54:14 +12:00
parent 5a360a5c6a
commit 1655db285d
3 changed files with 5 additions and 29 deletions

View File

@@ -51,12 +51,6 @@ TEST(equihash_tests, check_basic_solver_cancelled) {
}), EhSolverCancelledException);
}
{
ASSERT_NO_THROW(Eh48_5.BasicSolve(state, [](EhSolverCancelCheck pos) {
return pos == StartCulling;
}));
}
{
ASSERT_NO_THROW(Eh48_5.BasicSolve(state, [](EhSolverCancelCheck pos) {
return pos == PartialGeneration;
@@ -130,25 +124,9 @@ TEST(equihash_tests, check_optimised_solver_cancelled) {
}), EhSolverCancelledException);
}
{
// More state required here, because in OptimisedSolve() the
// FinalColliding cancellation check can't throw because it will leak
// memory, and it can't goto because that steps over initialisations.
bool triggered = false;
ASSERT_THROW(Eh48_5.OptimisedSolve(state, [=](EhSolverCancelCheck pos) mutable {
if (triggered)
return pos == StartCulling;
if (pos == FinalColliding) {
triggered = true;
return true;
}
return false;
}), EhSolverCancelledException);
}
{
ASSERT_THROW(Eh48_5.OptimisedSolve(state, [](EhSolverCancelCheck pos) {
return pos == StartCulling;
return pos == FinalColliding;
}), EhSolverCancelledException);
}