Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

BOOST_level_LE

BOOST_level_LE(lhs, rhs) asserts that lhs is less than or equal to rhs. The comparison is made by applying operator<= to both arguments. The diagnostic message is constructed from applying operator<< to the two arguments.

[Important] Important

If you get a strange compile error when using BOOST_level_LE, check that the appropriate operator<= and operator<< are defined for the arguments. If you define these operators in your test code, keep in mind argument-dependent lookup of types based on enclosing namespaces and the namespaces opened by test suites. The need to define operator<< can be eliminated by using BOOST_TEST_DONT_PRINT_LOG_VALUE.

Example

BOOST_AUTO_TEST_CASE(example_le)
{
    // integral types
    unsigned const u = 10u;
    int const i = -10;
    char const M = 'M';
    // standard library types providing operator>= and operator<<
    std::string const s = "scooby";

    BOOST_REQUIRE_LE(9u, u);
    BOOST_REQUIRE_LE(10u, u);
    BOOST_REQUIRE_LE(-11, i);
    BOOST_REQUIRE_LE(-10, i);
    BOOST_REQUIRE_LE('L', M);
    BOOST_REQUIRE_LE('M', M);
    BOOST_REQUIRE_LE("scoobx", s);
    BOOST_REQUIRE_LE("scooby", s);
}


PrevUpHomeNext