diff --git a/test/unittests/eof_validation.cpp b/test/unittests/eof_validation.cpp index 640595aa73..49d7805300 100644 --- a/test/unittests/eof_validation.cpp +++ b/test/unittests/eof_validation.cpp @@ -10,6 +10,85 @@ namespace fs = std::filesystem; namespace evmone::test { +namespace +{ +std::string_view get_tests_error_message(EOFValidationError err) noexcept +{ + switch (err) + { + case EOFValidationError::success: + return "success"; + 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"; + } + return ""; +} +} // namespace + void eof_validation::TearDown() { for (size_t i = 0; i < test_cases.size(); ++i) @@ -46,7 +125,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); } }