From e2480dedcabf44fcc41641785c81bcafb16727fc Mon Sep 17 00:00:00 2001 From: Jack Lloyd Date: Mon, 16 Nov 2015 16:18:42 -0500 Subject: Add helper for test output files. Remove last uses of hardcoded data dir macros --- src/tests/tests.h | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) (limited to 'src/tests/tests.h') diff --git a/src/tests/tests.h b/src/tests/tests.h index 273035cbf..9f511c4fb 100644 --- a/src/tests/tests.h +++ b/src/tests/tests.h @@ -82,9 +82,31 @@ class Test return r; } + static Result OfExpectedFailure(bool expecting_failure, + const Test::Result& result) + { + if(!expecting_failure) + { + return result; + } + + if(result.tests_failed() == 0) + { + Result r = result; + r.test_failure("Expected this test to fail, but it did not"); + return r; + } + else + { + Result r(result.who()); + r.test_note("Got expected failure " + result.result_string()); + return r; + } + } + void merge(const Result& other); - void test_note(const std::string& note); + void test_note(const std::string& note, const char* extra = nullptr); void note_missing(const std::string& thing); @@ -119,7 +141,9 @@ class Test std::ostringstream out; out << m_who; if(what) + { out << " " << what; + } if(produced == expected) { @@ -237,6 +261,7 @@ class Test static std::string data_dir(const std::string& what); static std::string data_file(const std::string& what); + static std::string full_path_for_output_file(const std::string& base); template static std::vector mutate_vec(const std::vector& v, bool maybe_resize = false) @@ -350,10 +375,4 @@ class Text_Based_Test : public Test } -#define TEST_DATA_DIR "src/tests/data" -#define TEST_DATA_DIR_PK "src/tests/data/pubkey" -#define TEST_DATA_DIR_ECC "src/tests/data/ecc" - -#define TEST_OUTDATA_DIR "src/tests/outdata" - #endif -- cgit v1.2.3