length_error.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("length_error");


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


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


}