#include <boost/test/unit_test.hpp>
#include <string>
-#include <unistd.h>
+#include <fcntl.h>
BOOST_AUTO_TEST_SUITE( error_suite )
{
// 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());
}