Skip to content

Commit

Permalink
test: Replace ARRAYLEN with C++11 ranged for loop
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoFalke committed Oct 26, 2020
1 parent fafc529 commit fa3967e
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/test/script_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,18 +106,18 @@ static ScriptErrorDesc script_errors[]={

static std::string FormatScriptError(ScriptError_t err)
{
for (unsigned int i=0; i<ARRAYLEN(script_errors); ++i)
if (script_errors[i].err == err)
return script_errors[i].name;
for (const auto& se : script_errors)
if (se.err == err)
return se.name;
BOOST_ERROR("Unknown scripterror enumeration value, update script_errors in script_tests.cpp.");
return "";
}

static ScriptError_t ParseScriptError(const std::string &name)
static ScriptError_t ParseScriptError(const std::string& name)
{
for (unsigned int i=0; i<ARRAYLEN(script_errors); ++i)
if (script_errors[i].name == name)
return script_errors[i].err;
for (const auto& se : script_errors)
if (se.name == name)
return se.err;
BOOST_ERROR("Unknown scripterror \"" << name << "\" in test description");
return SCRIPT_ERR_UNKNOWN_ERROR;
}
Expand Down

0 comments on commit fa3967e

Please sign in to comment.