From 3cdcd06b663c442e4031210a07d700c5b7b66237 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Tue, 5 Feb 2019 20:26:47 +0000 Subject: [PATCH] Add last test case for callbacks in libsolc --- test/libsolidity/LibSolc.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/test/libsolidity/LibSolc.cpp b/test/libsolidity/LibSolc.cpp index ea725f433..89a502100 100644 --- a/test/libsolidity/LibSolc.cpp +++ b/test/libsolidity/LibSolc.cpp @@ -133,7 +133,7 @@ BOOST_AUTO_TEST_CASE(with_callback) "language": "Solidity", "sources": { "fileA": { - "content": "import \"found.sol\"; contract A { }" + "content": "import \"found.sol\"; import \"notfound.sol\"; contract A { }" } } } @@ -149,12 +149,17 @@ BOOST_AUTO_TEST_CASE(with_callback) *o_contents = strdup(content.c_str()); *o_error = nullptr; } - else + else if (string(_path) == "missing.sol") { static string errorMsg{"Missing file."}; *o_error = strdup(errorMsg.c_str()); *o_contents = nullptr; } + else + { + *o_error = nullptr; + *o_contents = nullptr; + } } }; @@ -163,6 +168,9 @@ BOOST_AUTO_TEST_CASE(with_callback) // This ensures that "found.sol" was properly loaded which triggered the second import statement. BOOST_CHECK(containsError(result, "ParserError", "Source \"missing.sol\" not found: Missing file.")); + + // This should be placed due to the missing "notfound.sol" which sets both pointers to null. + BOOST_CHECK(containsError(result, "ParserError", "Source \"notfound.sol\" not found: File not found.")); } BOOST_AUTO_TEST_SUITE_END()