Sha256: 27342a608fac119c5cfc9b2e8099838a90272e3f7d732dd1ba2adfceaf901fb6

Contents?: true

Size: 1.23 KB

Versions: 396

Compression:

Stored size: 1.23 KB

Contents

#include "robot_name.h"
#define BOOST_TEST_MAIN
#include <boost/test/unit_test.hpp>
#include <boost/regex.hpp>

using namespace std;

namespace
{
const boost::regex name_pattern{R"name(^[[:upper:]]{2}\d{3}$)name"};
}

BOOST_AUTO_TEST_CASE(has_a_name)
{
    const robot_name::robot robot;

    BOOST_REQUIRE(boost::regex_match(robot.name(), name_pattern));
}

#if defined(EXERCISM_RUN_ALL_TESTS)
BOOST_AUTO_TEST_CASE(name_is_the_same_each_time)
{
    const robot_name::robot robot;

    BOOST_REQUIRE_EQUAL(robot.name(), robot.name());
}

BOOST_AUTO_TEST_CASE(different_robots_have_different_names)
{
    const robot_name::robot robot_one;
    const robot_name::robot robot_two;

    BOOST_REQUIRE_NE(robot_one.name(), robot_two.name());
}

BOOST_AUTO_TEST_CASE(is_able_to_reset_name)
{
    robot_name::robot robot;
    const auto original_name = robot.name();

    robot.reset();

    BOOST_REQUIRE_NE(original_name, robot.name());
}

BOOST_AUTO_TEST_CASE(exhausting_digits_yields_different_names)
{
    robot_name::robot robot;
    auto last_name = robot.name();

    for (int i = 0; i < 1000; ++i) {
        robot.reset();
        BOOST_REQUIRE_NE(last_name, robot.name());
        BOOST_REQUIRE(boost::regex_match(robot.name(), name_pattern));
    }
}
#endif

Version data entries

396 entries across 396 versions & 1 rubygems

Version Path
trackler-2.0.4.0 tracks/cpp/robot-name/robot_name_test.cpp
trackler-2.0.3.9 tracks/cpp/robot-name/robot_name_test.cpp
trackler-2.0.3.8 tracks/cpp/robot-name/robot_name_test.cpp
trackler-2.0.3.7 tracks/cpp/robot-name/robot_name_test.cpp
trackler-2.0.3.6 tracks/cpp/robot-name/robot_name_test.cpp
trackler-2.0.3.5 tracks/cpp/robot-name/robot_name_test.cpp
trackler-2.0.3.4 tracks/cpp/robot-name/robot_name_test.cpp
trackler-2.0.3.3 tracks/cpp/robot-name/robot_name_test.cpp
trackler-2.0.3.2 tracks/cpp/robot-name/robot_name_test.cpp
trackler-2.0.3.1 tracks/cpp/robot-name/robot_name_test.cpp
trackler-2.0.3.0 tracks/cpp/robot-name/robot_name_test.cpp
trackler-2.0.2.0 tracks/cpp/robot-name/robot_name_test.cpp
trackler-2.0.1.2 tracks/cpp/robot-name/robot_name_test.cpp
trackler-2.0.1.1 tracks/cpp/robot-name/robot_name_test.cpp
trackler-2.0.1.0 tracks/cpp/robot-name/robot_name_test.cpp
trackler-2.0.0.10 tracks/cpp/robot-name/robot_name_test.cpp
trackler-2.0.0.9 tracks/cpp/robot-name/robot_name_test.cpp
trackler-2.0.0.8 tracks/cpp/robot-name/robot_name_test.cpp
trackler-2.0.0.7 tracks/cpp/robot-name/robot_name_test.cpp
trackler-2.0.0.6 tracks/cpp/robot-name/robot_name_test.cpp