Skip to content

Commit

Permalink
Use standard error messages in EOF validation tests export
Browse files Browse the repository at this point in the history
  • Loading branch information
gumb0 committed Feb 22, 2024
1 parent a057e12 commit 62d18d9
Showing 1 changed file with 80 additions and 1 deletion.
81 changes: 80 additions & 1 deletion test/unittests/eof_validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,85 @@

namespace evmone::test
{
namespace
{
std::string_view get_tests_error_message(EOFValidationError err) noexcept
{
switch (err)
{
case EOFValidationError::success:
return "success";

Check warning on line 18 in test/unittests/eof_validation.cpp

View check run for this annotation

Codecov / codecov/patch

test/unittests/eof_validation.cpp#L17-L18

Added lines #L17 - L18 were not covered by tests
case EOFValidationError::invalid_prefix:
return "EOF_InvalidPrefix";
case EOFValidationError::eof_version_unknown:
return "EOF_UnknownVersion";
case EOFValidationError::incomplete_section_size:
return "EOF_IncompleteSectionSize";
case EOFValidationError::incomplete_section_number:
return "EOF_IncompleteSectionNumber";
case EOFValidationError::header_terminator_missing:
return "EOF_HeaderTerminatorMissing";
case EOFValidationError::type_section_missing:
return "EOF_TypeSectionMissing";
case EOFValidationError::code_section_missing:
return "EOF_CodeSectionMissing";
case EOFValidationError::data_section_missing:
return "EOF_DataSectionMissing";
case EOFValidationError::zero_section_size:
return "EOF_InvalidSectionSize";
case EOFValidationError::section_headers_not_terminated:
return "EOF_SectionHeadersNotTerminated";
case EOFValidationError::invalid_section_bodies_size:
return "EOF_InvalidSectionBodiesSize";
case EOFValidationError::unreachable_code_sections:
return "EOF_UnreachableCodeSections";
case EOFValidationError::undefined_instruction:
return "EOF_UndefinedInstruction";
case EOFValidationError::truncated_instruction:
return "EOF_TruncatedInstruction";
case EOFValidationError::invalid_rjump_destination:
return "EOF_InvalidJumpDestination";
case EOFValidationError::too_many_code_sections:
return "EOF_TooManyCodeSections";
case EOFValidationError::invalid_type_section_size:
return "EOF_InvalidTypeSectionSize";
case EOFValidationError::invalid_first_section_type:
return "EOF_InvalidFirstSectionType";
case EOFValidationError::invalid_max_stack_height:
return "EOF_InvalidMaxStackHeight";
case EOFValidationError::max_stack_height_above_limit:
return "EOF_MaxStackHeightExceeded";
case EOFValidationError::inputs_outputs_num_above_limit:
return "EOF_InputsOutputsAboveLimit";
case EOFValidationError::no_terminating_instruction:
return "EOF_InvalidCodeTermination";
case EOFValidationError::stack_height_mismatch:
return "EOF_ConflictingStackHeight";
case EOFValidationError::stack_higher_than_outputs_required:
return "EOF_InvalidNumberOfOutputs";
case EOFValidationError::unreachable_instructions:
return "EOF_UnreachableCode";
case EOFValidationError::stack_underflow:
return "EOF_StackUnderflow";
case EOFValidationError::stack_overflow:
return "EOF_StackOverflow";
case EOFValidationError::invalid_code_section_index:
return "EOF_InvalidCodeSectionIndex";
case EOFValidationError::invalid_dataloadn_index:
return "EOF_InvalidDataloadnIndex";
case EOFValidationError::jumpf_destination_incompatible_outputs:
return "EOF_JumpfDestinationIncompatibleOutputs";
case EOFValidationError::invalid_non_returning_flag:
return "EOF_InvalidNonReturningFlag";
case EOFValidationError::callf_to_non_returning_function:
return "EOF_CallfToNonReturning";
case EOFValidationError::impossible:
return "impossible";

Check warning on line 84 in test/unittests/eof_validation.cpp

View check run for this annotation

Codecov / codecov/patch

test/unittests/eof_validation.cpp#L83-L84

Added lines #L83 - L84 were not covered by tests
}
return "<unknown>";

Check warning on line 86 in test/unittests/eof_validation.cpp

View check run for this annotation

Codecov / codecov/patch

test/unittests/eof_validation.cpp#L86

Added line #L86 was not covered by tests
}
} // namespace

void eof_validation::TearDown()
{
for (size_t i = 0; i < test_cases.size(); ++i)
Expand Down Expand Up @@ -44,7 +123,7 @@ void eof_validation::export_eof_validation_test()
else
{
jresults["result"] = false;
jresults["exception"] = get_error_message(test_case.error);
jresults["exception"] = get_tests_error_message(test_case.error);
}
}

Expand Down

0 comments on commit 62d18d9

Please sign in to comment.