]> git.llucax.com Git - software/posixx.git/blob - test/error.cpp
Add some help on adding suppressions to valgrind.
[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 <unistd.h>
7
8 BOOST_AUTO_TEST_SUITE( error_suite )
9
10 BOOST_AUTO_TEST_CASE( constructor_test )
11 {
12
13         // default constructor
14         close(-123);
15         posixx::error e1;
16         BOOST_CHECK_EQUAL(e1.no, EBADF);
17
18         // "where" string constructor
19         close(-123);
20         posixx::error e2("fopen");
21         BOOST_CHECK_EQUAL(e2.no, EBADF);
22         BOOST_CHECK_EQUAL(std::string(e2.what()).find("fopen: "), 0);
23
24         // e1 and e2 should be the same appart from the "where" string
25         BOOST_CHECK_EQUAL(std::string(e2.what()).substr(7), e1.what());
26
27 }
28
29 BOOST_AUTO_TEST_SUITE_END()
30