mirror of
https://github.com/XRPLF/rippled.git
synced 2026-04-29 15:37:57 +00:00
test: Add STInteger and STParsedJSON tests (#5726)
This change is to improve code coverage (and to simplify #5720 and #5725); there is otherwise no change in functionality. The change adds basic tests for `STInteger` and `STParsedJSON`, so it becomes easier to test smaller changes to the types, as well as removes `STParsedJSONArray`, since it is not used anywhere (including in Clio).
This commit is contained in:
@@ -62,8 +62,10 @@ STUInt8::getText() const
|
||||
if (transResultInfo(TER::fromInt(value_), token, human))
|
||||
return human;
|
||||
|
||||
// LCOV_EXCL_START
|
||||
JLOG(debugLog().error())
|
||||
<< "Unknown result code in metadata: " << value_;
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
|
||||
return std::to_string(value_);
|
||||
@@ -80,8 +82,10 @@ STUInt8::getJson(JsonOptions) const
|
||||
if (transResultInfo(TER::fromInt(value_), token, human))
|
||||
return token;
|
||||
|
||||
// LCOV_EXCL_START
|
||||
JLOG(debugLog().error())
|
||||
<< "Unknown result code in metadata: " << value_;
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
|
||||
return value_;
|
||||
@@ -171,6 +175,13 @@ template <>
|
||||
std::string
|
||||
STUInt32::getText() const
|
||||
{
|
||||
if (getFName() == sfPermissionValue)
|
||||
{
|
||||
auto const permissionName =
|
||||
Permission::getInstance().getPermissionName(value_);
|
||||
if (permissionName)
|
||||
return *permissionName;
|
||||
}
|
||||
return std::to_string(value_);
|
||||
}
|
||||
|
||||
@@ -180,23 +191,10 @@ STUInt32::getJson(JsonOptions) const
|
||||
{
|
||||
if (getFName() == sfPermissionValue)
|
||||
{
|
||||
auto const permissionValue =
|
||||
static_cast<GranularPermissionType>(value_);
|
||||
auto const granular =
|
||||
Permission::getInstance().getGranularName(permissionValue);
|
||||
|
||||
if (granular)
|
||||
{
|
||||
return *granular;
|
||||
}
|
||||
else
|
||||
{
|
||||
auto const txType =
|
||||
Permission::getInstance().permissionToTxType(value_);
|
||||
auto item = TxFormats::getInstance().findByType(txType);
|
||||
if (item != nullptr)
|
||||
return item->getName();
|
||||
}
|
||||
auto const permissionName =
|
||||
Permission::getInstance().getPermissionName(value_);
|
||||
if (permissionName)
|
||||
return *permissionName;
|
||||
}
|
||||
|
||||
return value_;
|
||||
|
||||
Reference in New Issue
Block a user