concordia-library/concordia/t/test_example.cpp
2015-04-30 09:29:10 +02:00

30 lines
788 B
C++

#include <boost/algorithm/string/predicate.hpp>
#include "tests/unit-tests/unit_tests_globals.hpp"
#include <string>
#include <climits>
#include "concordia/common/config.hpp"
#include "concordia/example.hpp"
BOOST_AUTO_TEST_SUITE(exampleTest)
BOOST_AUTO_TEST_CASE( ExceedingId )
{
SUFFIX_MARKER_TYPE maxId = (SUFFIX_MARKER_TYPE_MAX_VALUE >> 8) - 1;
Example example1("Test", maxId);
bool exceptionThrown = false;
std::string message = "";
try {
Example example2("Test", maxId+1);
} catch (ConcordiaException & e) {
exceptionThrown = true;
message = e.what();
}
BOOST_CHECK_EQUAL(exceptionThrown, true);
BOOST_CHECK_EQUAL(boost::starts_with(message, "Example id too large"), true);
}
BOOST_AUTO_TEST_SUITE_END()