]> git.llucax.com Git - software/posixx.git/blob - test/error.cpp
Add Boost License
[software/posixx.git] / test / error.cpp
1 // Copyright Leandro Lucarella 2008 - 2010.
2 // Distributed under the Boost Software License, Version 1.0.
3 // (See accompanying file COPYING or copy at
4 // http://www.boost.org/LICENSE_1_0.txt)
5
6
7
8 #include <posixx/error.hpp> // posixx::error
9
10 #include <boost/test/unit_test.hpp>
11 #include <string>
12 #include <fcntl.h>
13
14 BOOST_AUTO_TEST_SUITE( error_suite )
15
16 BOOST_AUTO_TEST_CASE( constructor_test )
17 {
18
19         // default constructor
20         open("/non/existent", 0);
21         posixx::error e1;
22         BOOST_CHECK_EQUAL(e1.no, ENOENT);
23
24         // "where" string constructor
25         open("/non/existent", 0);
26         posixx::error e2("open");
27         BOOST_CHECK_EQUAL(e2.no, ENOENT);
28         BOOST_CHECK_EQUAL(std::string(e2.what()).find("open: "), 0);
29
30         // e1 and e2 should be the same appart from the "where" string
31         BOOST_CHECK_EQUAL(std::string(e2.what()).substr(6), e1.what());
32
33 }
34
35 BOOST_AUTO_TEST_SUITE_END()
36