Skip to content

Commit

Permalink
Add tests for non-returning functions
Browse files Browse the repository at this point in the history
  • Loading branch information
gumb0 committed Aug 9, 2023
1 parent 0ba6186 commit 5af2c72
Showing 1 changed file with 50 additions and 1 deletion.
51 changes: 50 additions & 1 deletion test/unittests/eof_validation_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -295,9 +295,11 @@ TEST(eof_validation, EOF1_invalid_type_section_size)

TEST(eof_validation, EOF1_invalid_section_0_type)
{
EXPECT_EQ(validate_eof("EF0001 010004 0200010001 040000 00 00000000 00"),
EOFValidationError::invalid_first_section_type);
EXPECT_EQ(validate_eof("EF0001 010004 0200010003 040000 00 00010000 60005C"),
EOFValidationError::invalid_first_section_type);
EXPECT_EQ(validate_eof("EF0001 010004 0200010002 040000 00 01000000 5000"),
EXPECT_EQ(validate_eof("EF0001 010004 0200010001 040000 00 01800000 FE"),
EOFValidationError::invalid_first_section_type);
EXPECT_EQ(validate_eof("EF0001 010004 0200010003 040000 00 02030000 60005C"),
EOFValidationError::invalid_first_section_type);
Expand Down Expand Up @@ -827,3 +829,50 @@ TEST(eof_validation, dataloadn)
"00000000000000001111111111111111222222222222222233333333333333"),
EOFValidationError::invalid_dataloadn_index);
}

TEST(eof_validation, non_returning_status)
{
// Non-returning with no JUMPF and no RETF
EXPECT_EQ(validate_eof("EF0001 010004 0200010001 040000 00 00800000 00"),
EOFValidationError::success);
// Non-returning with JUMPF
EXPECT_EQ(validate_eof("EF0001 010008 02000200030001 040000 00 0080000000800000 E50001 00"),
EOFValidationError::success);

// Returning with RETF
EXPECT_EQ(validate_eof("EF0001 010008 02000200010001 040000 00 0080000000000000 00 E4"),
EOFValidationError::success);
// Returning with JUMPF
EXPECT_EQ(
validate_eof(
"EF0001 01000c 020003000100030001 040000 00 008000000000000000000000 00 E50002 E4"),
EOFValidationError::success);
// Returning with JUMPF to returning and RETF
EXPECT_EQ(validate_eof("EF0001 01000C 020003000100070001 040000 00 008000000100000100000000 00 "
"E10001E4E50002 E4"),
EOFValidationError::success);
// Returning with JUMPF to non-returning and RETF
EXPECT_EQ(
validate_eof("EF0001 010008 02000200010007 040000 00 0080000001000001 00 E10001E4E50000"),
EOFValidationError::success);

// Invalid with RETF
EXPECT_EQ(validate_eof("EF0001 010008 02000200010001 040000 00 0080000000800000 00 E4"),
EOFValidationError::invalid_non_returning_flag);
// Invalid with JUMPF to returning
EXPECT_EQ(
validate_eof(
"EF0001 01000c 020003000100030001 040000 00 008000000080000000000000 00 E50002 E4"),
EOFValidationError::invalid_non_returning_flag);
// Invalid with JUMPF to non-returning
EXPECT_EQ(validate_eof("EF0001 010008 02000200010003 040000 00 0080000000000000 00 E50000"),
EOFValidationError::invalid_non_returning_flag);
// Invalid with JUMPF to returning and RETF
EXPECT_EQ(validate_eof("EF0001 01000C 020003000100070001 040000 00 008000000180000100000000 00 "
"E10001E4E50002 E4"),
EOFValidationError::invalid_non_returning_flag);
// Invalid with JUMPF to non-returning and RETF
EXPECT_EQ(
validate_eof("EF0001 010008 02000200010007 040000 00 0080000001800001 00 E10001E4E50000"),
EOFValidationError::invalid_non_returning_flag);
}

0 comments on commit 5af2c72

Please sign in to comment.