tests: add the testcase from #153 (#154)

* tests: add a testcase for #153

* tests: rename testcase, hook up

* tests: fix REQUIRE check
This commit is contained in:
William Woodruff 2021-04-29 12:54:27 -04:00 committed by GitHub
parent baeeb19427
commit 58b254a863
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 0 deletions

View File

@ -23,6 +23,7 @@ add_executable(tests
test_main.cpp
simple_test.cpp
corkami_test.cpp
pr_153_test.cpp
filesystem_compat.h
)

BIN
tests/assets/pr_153.exe Normal file

Binary file not shown.

17
tests/pr_153_test.cpp Normal file
View File

@ -0,0 +1,17 @@
#include <pe-parse/parse.h>
#include <catch2/catch.hpp>
#include "filesystem_compat.h"
namespace peparse {
TEST_CASE("malformed PE (GH#153) does not parse", "[pr_153]") {
auto path = fs::path(ASSETS_DIR) / "pr_153.exe";
auto *p = ParsePEFromFile(path.string().c_str());
// pr_153.exe should not parse, and should return an error indicating
// that the magic was invalid (masking the underlying PEERR_ADDRESS error).
REQUIRE(p == nullptr);
REQUIRE(GetPEErr() == PEERR_MAGIC);
}
} // namespace peparse