Skip to content

Commit fa3967e

Browse files
author
MarcoFalke
committed
test: Replace ARRAYLEN with C++11 ranged for loop
1 parent fafc529 commit fa3967e

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/test/script_tests.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -106,18 +106,18 @@ static ScriptErrorDesc script_errors[]={
106106

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

116-
static ScriptError_t ParseScriptError(const std::string &name)
116+
static ScriptError_t ParseScriptError(const std::string& name)
117117
{
118-
for (unsigned int i=0; i<ARRAYLEN(script_errors); ++i)
119-
if (script_errors[i].name == name)
120-
return script_errors[i].err;
118+
for (const auto& se : script_errors)
119+
if (se.name == name)
120+
return se.err;
121121
BOOST_ERROR("Unknown scripterror \"" << name << "\" in test description");
122122
return SCRIPT_ERR_UNKNOWN_ERROR;
123123
}

0 commit comments

Comments
 (0)