mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
[isoltest] Prints bytes result if expectations mismatch.
This commit is contained in:
parent
07051f41d2
commit
38285b33d7
@ -205,3 +205,24 @@ string BytesUtils::formatString(bytes const& _bytes, size_t _cutOff) const
|
|||||||
|
|
||||||
return os.str();
|
return os.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
string BytesUtils::formatRawBytes(bytes const& _bytes)
|
||||||
|
{
|
||||||
|
if (_bytes.empty())
|
||||||
|
return "[]";
|
||||||
|
|
||||||
|
stringstream os;
|
||||||
|
auto it = _bytes.begin();
|
||||||
|
for (size_t i = 0; i < _bytes.size(); i += 32)
|
||||||
|
{
|
||||||
|
bytes byteRange{it, it + 32};
|
||||||
|
|
||||||
|
os << " " << byteRange;
|
||||||
|
|
||||||
|
it += 32;
|
||||||
|
if (it != _bytes.end())
|
||||||
|
os << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
return os.str();
|
||||||
|
}
|
||||||
|
@ -91,6 +91,11 @@ public:
|
|||||||
/// a hexString value.
|
/// a hexString value.
|
||||||
static std::string formatHexString(bytes const& _bytes);
|
static std::string formatHexString(bytes const& _bytes);
|
||||||
|
|
||||||
|
/// Returns a string representation of given _bytes. Adds a newline
|
||||||
|
/// every 32 bytes to increase readability.
|
||||||
|
/// Used to print returned bytes from function calls to the commandline.
|
||||||
|
static std::string formatRawBytes(bytes const& _bytes);
|
||||||
|
|
||||||
/// Converts \param _bytes to a soltest-compliant and human-readable
|
/// Converts \param _bytes to a soltest-compliant and human-readable
|
||||||
/// string representation of a byte array which is assumed to hold
|
/// string representation of a byte array which is assumed to hold
|
||||||
/// a string value.
|
/// a string value.
|
||||||
|
@ -218,6 +218,7 @@ string TestFunctionCall::formatBytesParameters(
|
|||||||
" does not match the one inferred from ABI."
|
" does not match the one inferred from ABI."
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
_errorReporter.warning("The call to \"" + _signature + "\" returned \n" + BytesUtils::formatRawBytes(_bytes));
|
||||||
|
|
||||||
/// Prints obtained result if it does not match the expectation
|
/// Prints obtained result if it does not match the expectation
|
||||||
/// and prints the expected result otherwise.
|
/// and prints the expected result otherwise.
|
||||||
@ -288,15 +289,13 @@ string TestFunctionCall::formatRawParameters(
|
|||||||
{
|
{
|
||||||
stringstream os;
|
stringstream os;
|
||||||
for (auto const& param: _params)
|
for (auto const& param: _params)
|
||||||
|
{
|
||||||
|
if (!param.rawString.empty())
|
||||||
{
|
{
|
||||||
if (param.format.newline)
|
if (param.format.newline)
|
||||||
os << endl << _linePrefix << "// ";
|
os << endl << _linePrefix << "// ";
|
||||||
os << param.rawString;
|
os << param.rawString;
|
||||||
if (¶m != &_params.back())
|
if (¶m != &_params.back())
|
||||||
{
|
|
||||||
if (param.format.newline)
|
|
||||||
os << ",";
|
|
||||||
else
|
|
||||||
os << ", ";
|
os << ", ";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user