mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[poincare/test/helper] Print richer information when test fails
This commit is contained in:
committed by
Léa Saviot
parent
3271fc90a4
commit
caa7e6fbbf
@@ -44,7 +44,30 @@ void assert_parsed_expression_process_to(const char * expression, const char * r
|
||||
constexpr int bufferSize = 500;
|
||||
char buffer[bufferSize];
|
||||
m.serialize(buffer, bufferSize, DecimalMode, numberOfSignifiantDigits);
|
||||
quiz_assert_print_if_failure(strcmp(buffer, result) == 0, expression);
|
||||
const bool test = strcmp(buffer, result) == 0;
|
||||
char information[bufferSize] = "";
|
||||
if (!test) {
|
||||
char * position = information;
|
||||
size_t remainingLength = bufferSize;
|
||||
static constexpr size_t numberOfPieces = 6;
|
||||
const char * piecesOfInformation[numberOfPieces] = {
|
||||
" ",
|
||||
expression,
|
||||
"\n processed to\n ",
|
||||
buffer,
|
||||
"\n instead of\n ",
|
||||
result,
|
||||
};
|
||||
for (size_t piece = 0; piece < numberOfPieces; piece++) {
|
||||
const size_t length = strlcpy(position, piecesOfInformation[piece], remainingLength);
|
||||
if (length > remainingLength) {
|
||||
break;
|
||||
}
|
||||
remainingLength -= length;
|
||||
position += length;
|
||||
}
|
||||
}
|
||||
quiz_assert_print_if_failure(test, information);
|
||||
}
|
||||
|
||||
Poincare::Expression parse_expression(const char * expression, bool addParentheses) {
|
||||
|
||||
Reference in New Issue
Block a user