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.2.1.180 tracks/cpp/exercises/robot-name/robot_name_test.cpp
trackler-2.2.1.179 tracks/cpp/exercises/robot-name/robot_name_test.cpp
trackler-2.2.1.178 tracks/cpp/exercises/robot-name/robot_name_test.cpp
trackler-2.2.1.177 tracks/cpp/exercises/robot-name/robot_name_test.cpp
trackler-2.2.1.176 tracks/cpp/exercises/robot-name/robot_name_test.cpp
trackler-2.2.1.175 tracks/cpp/exercises/robot-name/robot_name_test.cpp
trackler-2.2.1.174 tracks/cpp/exercises/robot-name/robot_name_test.cpp
trackler-2.2.1.173 tracks/cpp/exercises/robot-name/robot_name_test.cpp
trackler-2.2.1.172 tracks/cpp/exercises/robot-name/robot_name_test.cpp
trackler-2.2.1.171 tracks/cpp/exercises/robot-name/robot_name_test.cpp
trackler-2.2.1.170 tracks/cpp/exercises/robot-name/robot_name_test.cpp
trackler-2.2.1.169 tracks/cpp/exercises/robot-name/robot_name_test.cpp
trackler-2.2.1.167 tracks/cpp/exercises/robot-name/robot_name_test.cpp
trackler-2.2.1.166 tracks/cpp/exercises/robot-name/robot_name_test.cpp
trackler-2.2.1.165 tracks/cpp/exercises/robot-name/robot_name_test.cpp
trackler-2.2.1.164 tracks/cpp/exercises/robot-name/robot_name_test.cpp
trackler-2.2.1.163 tracks/cpp/exercises/robot-name/robot_name_test.cpp
trackler-2.2.1.162 tracks/cpp/exercises/robot-name/robot_name_test.cpp
trackler-2.2.1.161 tracks/cpp/exercises/robot-name/robot_name_test.cpp
trackler-2.2.1.160 tracks/cpp/exercises/robot-name/robot_name_test.cpp