]> git.llucax.com Git - software/posixx.git/blob - test/error.cpp
Improve test suite coverage
[software/posixx.git] / test / error.cpp
1
2 #include <posixx/error.hpp> // posixx::error
3
4 #include <boost/test/unit_test.hpp>
5 #include <string>
6 #include <fcntl.h>
7
8 BOOST_AUTO_TEST_SUITE( error_suite )
9
10 BOOST_AUTO_TEST_CASE( constructor_test )
11 {
12
13         // default constructor
14         open("/non/existent", 0);
15         posixx::error e1;
16         BOOST_CHECK_EQUAL(e1.no, ENOENT);
17
18         // "where" string constructor
19         open("/non/existent", 0);
20         posixx::error e2("open");
21         BOOST_CHECK_EQUAL(e2.no, ENOENT);
22         BOOST_CHECK_EQUAL(std::string(e2.what()).find("open: "), 0);
23
24         // e1 and e2 should be the same appart from the "where" string
25         BOOST_CHECK_EQUAL(std::string(e2.what()).substr(6), e1.what());
26
27 }
28
29 BOOST_AUTO_TEST_SUITE_END()
30