Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
dist: trusty
sudo: false
sudo: false
language: cpp

matrix:
Expand Down Expand Up @@ -30,10 +30,10 @@ before_install:
- sudo apt-get -y -d update
- eval "${MATRIX_EVAL}"
install:
- sudo apt-get -y install libboost-regex1.60-dev libboost-test1.60-dev libboost-date-time1.60-dev
- sudo apt-get -y install libboost-date-time1.60-dev ninja-build
script:
- bin/fetch-configlet
- bin/configlet lint .
- cmake -G "Unix Makefiles"
- make
- cmake -G Ninja
- ninja

2 changes: 1 addition & 1 deletion config.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"uuid": "4dbe1bb3-0419-4749-8c2a-ec91539a8640",
"core": true,
"unlocked_by": null,
"difficulty": 2,
"difficulty": 5,
"topics": [
"dates",
"interfaces"
Expand Down
6 changes: 2 additions & 4 deletions docs/INSTALLATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ The unit tests use Boost.Test, the unit testing framework included with
in Boost useful to you as you work through the exercises.
You will need to download and install Boost. As of this writing Boost
1.59+ is the required version. You will need a compiled version of the
boost libraries Boost.Test, Boost.DateTime and Boost.Regex, or you will
need to download from source and build the library yourself.
Boost.Test library or you will need to download it from source and
build the library yourself.

If you are having difficulties installing Boost for use with exercism,
[ask for help](https://github.com/exercism/cpp/issues).
Expand Down Expand Up @@ -142,8 +142,6 @@ CMake Error at C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/FindBoos
The following Boost libraries could not be found:

boost_unit_test_framework
boost_date_time
boost_regex

No Boost libraries were found. You may need to set BOOST_LIBRARYDIR to the
directory containing Boost libraries or BOOST_ROOT to the location of
Expand Down
12 changes: 0 additions & 12 deletions exercises/allergies/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,6 @@ cmake_minimum_required(VERSION 2.8.11)
# Name the project after the exercise
project(${exercise} CXX)

# Locate Boost libraries: unit_test_framework, date_time and regex
set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_MULTITHREADED ON)
set(Boost_USE_STATIC_RUNTIME OFF)
find_package(Boost 1.59 REQUIRED COMPONENTS unit_test_framework date_time regex)

# Enable C++11 features on gcc/clang
if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)")
set(CMAKE_CXX_FLAGS "-std=c++11")
Expand All @@ -36,12 +30,6 @@ endif()
# Build executable from sources and headers
add_executable(${exercise} ${file}_test.cpp ${exercise_cpp} ${file}.h)

# We need boost includes
target_include_directories(${exercise} PRIVATE ${Boost_INCLUDE_DIRS})

# We need boost libraries
target_link_libraries(${exercise} ${Boost_LIBRARIES})

# Tell MSVC not to warn us about unchecked iterators in debug builds
if(${MSVC})
set_target_properties(${exercise} PROPERTIES
Expand Down
84 changes: 42 additions & 42 deletions exercises/allergies/allergies_test.cpp
Original file line number Diff line number Diff line change
@@ -1,148 +1,148 @@
#include "allergies.h"
#define BOOST_TEST_MAIN
#include <boost/test/unit_test.hpp>
#define CATCH_CONFIG_MAIN
#include "test/catch.hpp"

#include <string>
#include <unordered_set>

BOOST_AUTO_TEST_CASE(no_allergies_means_not_allergic)
TEST_CASE("no_allergies_means_not_allergic")
{
allergies::allergy_test score(0);

BOOST_REQUIRE_EQUAL(false, score.is_allergic_to("peanuts"));
BOOST_REQUIRE_EQUAL(false, score.is_allergic_to("cats"));
BOOST_REQUIRE_EQUAL(false, score.is_allergic_to("strawberries"));
REQUIRE(false == score.is_allergic_to("peanuts"));
REQUIRE(false == score.is_allergic_to("cats"));
REQUIRE(false == score.is_allergic_to("strawberries"));
}

#if defined(EXERCISM_RUN_ALL_TESTS)
BOOST_AUTO_TEST_CASE(allergic_to_eggs)
TEST_CASE("allergic_to_eggs")
{
allergies::allergy_test score(1);

BOOST_REQUIRE_EQUAL(true, score.is_allergic_to("eggs"));
REQUIRE(true == score.is_allergic_to("eggs"));
}

BOOST_AUTO_TEST_CASE(allergic_to_peanuts)
TEST_CASE("allergic_to_peanuts")
{
allergies::allergy_test score(2);

BOOST_REQUIRE_EQUAL(true, score.is_allergic_to("peanuts"));
REQUIRE(true == score.is_allergic_to("peanuts"));
}

BOOST_AUTO_TEST_CASE(allergic_to_shellfish)
TEST_CASE("allergic_to_shellfish")
{
allergies::allergy_test score(4);

BOOST_REQUIRE_EQUAL(true, score.is_allergic_to("shellfish"));
REQUIRE(true == score.is_allergic_to("shellfish"));
}

BOOST_AUTO_TEST_CASE(allergic_to_strawberries)
TEST_CASE("allergic_to_strawberries")
{
allergies::allergy_test score(8);

BOOST_REQUIRE_EQUAL(true, score.is_allergic_to("strawberries"));
REQUIRE(true == score.is_allergic_to("strawberries"));
}

BOOST_AUTO_TEST_CASE(allergic_to_tomatoes)
TEST_CASE("allergic_to_tomatoes")
{
allergies::allergy_test score(16);

BOOST_REQUIRE_EQUAL(true, score.is_allergic_to("tomatoes"));
REQUIRE(true == score.is_allergic_to("tomatoes"));
}

BOOST_AUTO_TEST_CASE(allergic_to_chocolate)
TEST_CASE("allergic_to_chocolate")
{
allergies::allergy_test score(32);

BOOST_REQUIRE_EQUAL(true, score.is_allergic_to("chocolate"));
REQUIRE(true == score.is_allergic_to("chocolate"));
}

BOOST_AUTO_TEST_CASE(allergic_to_pollen)
TEST_CASE("allergic_to_pollen")
{
allergies::allergy_test score(64);

BOOST_REQUIRE_EQUAL(true, score.is_allergic_to("pollen"));
REQUIRE(true == score.is_allergic_to("pollen"));
}

BOOST_AUTO_TEST_CASE(allergic_to_cats)
TEST_CASE("allergic_to_cats")
{
allergies::allergy_test score(128);

BOOST_REQUIRE_EQUAL(true, score.is_allergic_to("cats"));
REQUIRE(true == score.is_allergic_to("cats"));
}

BOOST_AUTO_TEST_CASE(allergic_to_eggs_and_other_stuff)
TEST_CASE("allergic_to_eggs_and_other_stuff")
{
allergies::allergy_test score(5);

BOOST_REQUIRE_EQUAL(true, score.is_allergic_to("eggs"));
BOOST_REQUIRE_EQUAL(true, score.is_allergic_to("shellfish"));
BOOST_REQUIRE_EQUAL(false, score.is_allergic_to("peanuts"));
REQUIRE(true == score.is_allergic_to("eggs"));
REQUIRE(true == score.is_allergic_to("shellfish"));
REQUIRE(false == score.is_allergic_to("peanuts"));
}

BOOST_AUTO_TEST_CASE(allergic_to_nothing)
TEST_CASE("allergic_to_nothing")
{
allergies::allergy_test score(0);
const std::unordered_set<std::string> no_allergies;

BOOST_TEST(no_allergies == score.get_allergies());
REQUIRE(no_allergies == score.get_allergies());
}

BOOST_AUTO_TEST_CASE(allergic_to_only_peanuts)
TEST_CASE("allergic_to_only_peanuts")
{
allergies::allergy_test score(2);
const std::unordered_set<std::string> only_peanuts = {"peanuts"};

BOOST_TEST(only_peanuts == score.get_allergies());
REQUIRE(only_peanuts == score.get_allergies());
}

BOOST_AUTO_TEST_CASE(allergic_to_only_strawberries)
TEST_CASE("allergic_to_only_strawberries")
{
allergies::allergy_test score(8);
const std::unordered_set<std::string> only_strawberries = {"strawberries"};

BOOST_TEST(only_strawberries == score.get_allergies());
REQUIRE(only_strawberries == score.get_allergies());
}

BOOST_AUTO_TEST_CASE(allergic_to_eggs_and_peanuts)
TEST_CASE("allergic_to_eggs_and_peanuts")
{
allergies::allergy_test score(3);
const std::unordered_set<std::string> eggs_peanuts = {"eggs", "peanuts"};

BOOST_TEST(eggs_peanuts == score.get_allergies());
REQUIRE(eggs_peanuts == score.get_allergies());
}

BOOST_AUTO_TEST_CASE(allergic_to_more_than_eggs_but_not_peanuts)
TEST_CASE("allergic_to_more_than_eggs_but_not_peanuts")
{
allergies::allergy_test score(5);
const std::unordered_set<std::string> eggs_shellfish = {"eggs", "shellfish"};

BOOST_TEST(eggs_shellfish == score.get_allergies());
REQUIRE(eggs_shellfish == score.get_allergies());
}

BOOST_AUTO_TEST_CASE(allergic_to_lots_of_stuff)
TEST_CASE("allergic_to_lots_of_stuff")
{
allergies::allergy_test score(248);
const std::unordered_set<std::string> lots_of_stuff = {"strawberries", "tomatoes", "chocolate", "pollen", "cats"};

BOOST_TEST(lots_of_stuff == score.get_allergies());
REQUIRE(lots_of_stuff == score.get_allergies());
}

BOOST_AUTO_TEST_CASE(allergic_to_everything)
TEST_CASE("allergic_to_everything")
{
allergies::allergy_test score(255);
const std::unordered_set<std::string> everything = {"eggs", "peanuts", "shellfish", "strawberries",
"tomatoes", "chocolate", "pollen", "cats"};

BOOST_TEST(everything == score.get_allergies());
REQUIRE(everything == score.get_allergies());
}

BOOST_AUTO_TEST_CASE(ignore_non_allergen_score_parts)
TEST_CASE("ignore_non_allergen_score_parts")
{
allergies::allergy_test score(509);
const std::unordered_set<std::string> non_allergen = {"eggs", "shellfish", "strawberries", "tomatoes",
"chocolate", "pollen", "cats"};

BOOST_TEST(non_allergen == score.get_allergies());
REQUIRE(non_allergen == score.get_allergies());
}
#endif
Loading