runtime.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
#include <felspar/test.hpp>
#include <felspar/exceptions.hpp>


namespace {


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


    auto const c = suite.test("construct", []() {
        felspar::stdexcept::runtime_error{"Error message"};
        felspar::stdexcept::runtime_error{std::string{"Error message"}};
    });


    auto const t = suite.test("throw", [](auto check) {
        check([]() {
            throw felspar::stdexcept::runtime_error{"An error message"};
        }).throws(felspar::stdexcept::runtime_error{"An error message"});
        check([]() {
            throw felspar::stdexcept::runtime_error{"An error message"};
        }).throws(std::runtime_error{"An error message"});
    });


}