JayBeams  0.1
Another project to have fun coding.
ut_severity_level.cpp
Go to the documentation of this file.
1 #include <jb/severity_level.hpp>
2 
3 #include <boost/test/unit_test.hpp>
4 
5 /**
6  * @test Verify that the severity_level functions work as expected.
7  */
8 BOOST_AUTO_TEST_CASE(severity_level_simple) {
10  std::ostringstream os;
11  os << actual;
12  BOOST_CHECK_EQUAL(os.str(), std::string("ERROR"));
13 
14  BOOST_CHECK_EQUAL(std::string(jb::get_name(actual)), std::string("ERROR"));
15 
16  std::istringstream is("NOTICE");
17  is >> actual;
18  BOOST_CHECK_EQUAL(actual, jb::severity_level::notice);
19 }
20 
21 /**
22  * @test Verify that the severity_level functions detect errors.
23  */
24 BOOST_AUTO_TEST_CASE(severity_level_errors) {
25  jb::severity_level in_error = static_cast<jb::severity_level>(2000);
26  std::ostringstream os;
27  os << in_error;
28  BOOST_CHECK_EQUAL(os.str(), "[invalid severity (2000)]");
29 
30  BOOST_CHECK_THROW(jb::get_name(in_error), std::exception);
31 
32  std::istringstream is("NOT-A-SEVERITY");
33  BOOST_CHECK_THROW(is >> in_error, std::exception);
34 }
severity_level
Severity levels for JayBeams, based on syslog.
char const * get_name(severity_level const &rhs)
Get the name of a security level.
BOOST_AUTO_TEST_CASE(severity_level_simple)