system.cpp

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <felspar/test.hpp>
#include <felspar/exceptions.hpp>


namespace {


    auto const suite = felspar::testsuite("system");


    auto const c = suite.test("construct", []() {
        felspar::source_location loc = felspar::source_location::current();
        felspar::stdexcept::system_error{std::error_code{}, loc};
        felspar::stdexcept::system_error{std::error_code{}, "What ho!"};
        felspar::stdexcept::system_error{0, std::system_category()};
        felspar::stdexcept::system_error{0, std::system_category(), "What no!"};
    });


    auto const t = suite.test("throw", [](auto check) {
        check([]() {
            throw felspar::stdexcept::system_error{
                    std::error_code{}, "Message\n"};
        })
                .throws(felspar::stdexcept::system_error{
                        std::error_code{}, "Message\n"});
        check([]() {
            throw felspar::stdexcept::system_error{
                    std::error_code{}, "Message\n"};
        }).throws(std::system_error{std::error_code{}, "Message\n"});
    });


}