diff options
author | jmmv <jmmv@FreeBSD.org> | 2014-02-14 19:33:16 +0000 |
---|---|---|
committer | jmmv <jmmv@FreeBSD.org> | 2014-02-14 19:33:16 +0000 |
commit | 3000aef4b44bdeb9b83e0df3facbc6a75f8da412 (patch) | |
tree | 12192b0e3ae6cc3f8047467370fbd632a6788123 /contrib/atf/atf-c++/detail/test_helpers.cpp | |
parent | e21b440a4ce43fd31d59cd278801c727e21d3f2b (diff) | |
parent | 14f39fed9fe557bdd640e02d9abbe2e695400d9e (diff) | |
download | FreeBSD-src-3000aef4b44bdeb9b83e0df3facbc6a75f8da412.zip FreeBSD-src-3000aef4b44bdeb9b83e0df3facbc6a75f8da412.tar.gz |
MFV: Import atf-0.20.
Diffstat (limited to 'contrib/atf/atf-c++/detail/test_helpers.cpp')
-rw-r--r-- | contrib/atf/atf-c++/detail/test_helpers.cpp | 55 |
1 files changed, 9 insertions, 46 deletions
diff --git a/contrib/atf/atf-c++/detail/test_helpers.cpp b/contrib/atf/atf-c++/detail/test_helpers.cpp index 92f588d..38e6516 100644 --- a/contrib/atf/atf-c++/detail/test_helpers.cpp +++ b/contrib/atf/atf-c++/detail/test_helpers.cpp @@ -52,28 +52,24 @@ static const char* atf_c_tests_base = NULL; #endif #undef ATF_C_TESTS_BASE -void -build_check_cxx_o_aux(const atf::fs::path& sfile, const char* failmsg, - const bool expect_pass) +bool +build_check_cxx_o(const char* sfile) { std::vector< std::string > optargs; optargs.push_back("-I" + atf::config::get("atf_includedir")); optargs.push_back("-Wall"); optargs.push_back("-Werror"); - const bool result = atf::check::build_cxx_o( - sfile.str(), "test.o", atf::process::argv_array(optargs)); - if ((expect_pass && !result) || (!expect_pass && result)) - ATF_FAIL(failmsg); + return atf::check::build_cxx_o(sfile, "test.o", + atf::process::argv_array(optargs)); } -void -build_check_cxx_o(const atf::tests::tc& tc, const char* sfile, - const char* failmsg, const bool expect_pass) +bool +build_check_cxx_o_srcdir(const atf::tests::tc& tc, const char* sfile) { const atf::fs::path sfilepath = atf::fs::path(tc.get_config_var("srcdir")) / sfile; - build_check_cxx_o_aux(sfilepath, failmsg, expect_pass); + return build_check_cxx_o(sfilepath.c_str()); } void @@ -86,7 +82,8 @@ header_check(const char *hdrname) const std::string failmsg = std::string("Header check failed; ") + hdrname + " is not self-contained"; - build_check_cxx_o_aux(atf::fs::path("test.cpp"), failmsg.c_str(), true); + if (!build_check_cxx_o("test.cpp")) + ATF_FAIL(failmsg); } atf::fs::path @@ -104,37 +101,3 @@ get_process_helpers_path(const atf::tests::tc& tc, bool is_detail) return atf::fs::path(atf_c_tests_base) / helper; } } - -void -test_helpers_detail::check_equal(const char* expected[], - const string_vector& actual) -{ - const char** expected_iter = expected; - string_vector::const_iterator actual_iter = actual.begin(); - - bool equals = true; - while (equals && *expected_iter != NULL && actual_iter != actual.end()) { - if (*expected_iter != *actual_iter) { - equals = false; - } else { - expected_iter++; - actual_iter++; - } - } - if (equals && ((*expected_iter == NULL && actual_iter != actual.end()) || - (*expected_iter != NULL && actual_iter == actual.end()))) - equals = false; - - if (!equals) { - std::cerr << "EXPECTED:\n"; - for (expected_iter = expected; *expected_iter != NULL; expected_iter++) - std::cerr << *expected_iter << "\n"; - - std::cerr << "ACTUAL:\n"; - for (actual_iter = actual.begin(); actual_iter != actual.end(); - actual_iter++) - std::cerr << *actual_iter << "\n"; - - ATF_FAIL("Expected results differ to actual values"); - } -} |