From: Leandro Lucarella Date: Thu, 18 Sep 2008 22:43:15 +0000 (-0300) Subject: Use open() instead of close() for testing posixx::error X-Git-Url: https://git.llucax.com/software/posixx.git/commitdiff_plain/cbe3c49e9a5cde08d4b992245c476bfc141a6f80 Use open() instead of close() for testing posixx::error Closing an invalid file descriptor triggers a valgrind error and makes 'make memtest' fail. --- diff --git a/test/error.cpp b/test/error.cpp index 03996b5..7726da2 100644 --- a/test/error.cpp +++ b/test/error.cpp @@ -3,7 +3,7 @@ #include #include -#include +#include BOOST_AUTO_TEST_SUITE( error_suite ) @@ -11,18 +11,18 @@ BOOST_AUTO_TEST_CASE( constructor_test ) { // default constructor - close(-123); + open("/non/existent", 0); posixx::error e1; - BOOST_CHECK_EQUAL(e1.no, EBADF); + BOOST_CHECK_EQUAL(e1.no, ENOENT); // "where" string constructor - close(-123); - posixx::error e2("fopen"); - BOOST_CHECK_EQUAL(e2.no, EBADF); - BOOST_CHECK_EQUAL(std::string(e2.what()).find("fopen: "), 0); + open("/non/existent", 0); + posixx::error e2("open"); + BOOST_CHECK_EQUAL(e2.no, ENOENT); + BOOST_CHECK_EQUAL(std::string(e2.what()).find("open: "), 0); // e1 and e2 should be the same appart from the "where" string - BOOST_CHECK_EQUAL(std::string(e2.what()).substr(7), e1.what()); + BOOST_CHECK_EQUAL(std::string(e2.what()).substr(6), e1.what()); }