Skip to content
Merged
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
13 changes: 0 additions & 13 deletions exercises/food-chain/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,6 @@ cmake_minimum_required(VERSION 3.1.3)
# Name the project after the exercise
project(${exercise} CXX)

# Locate Boost libraries: unit_test_framework and date_time
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)

# Get a source filename from the exercise name by replacing -'s with _'s
string(REPLACE "-" "_" file ${exercise})

Expand All @@ -38,13 +32,6 @@ if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)")
)
endif()

# We need boost libraries
target_link_libraries(${exercise}
PRIVATE
Boost::unit_test_framework
Boost::date_time
)

# Configure to run all the tests?
if(${EXERCISM_RUN_ALL_TESTS})
target_compile_definitions(${exercise} PRIVATE EXERCISM_RUN_ALL_TESTS)
Expand Down
44 changes: 22 additions & 22 deletions exercises/food-chain/food_chain_test.cpp
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@
#include "food_chain.h"
#define BOOST_TEST_MAIN
#include <boost/test/unit_test.hpp>
#define CATCH_CONFIG_MAIN
#include "test/catch.hpp"

using namespace std;

BOOST_AUTO_TEST_CASE(fly)
TEST_CASE("fly")
{
string expected = "I know an old lady who swallowed a fly.\n"
"I don't know why she swallowed the fly. Perhaps she'll die.\n";

BOOST_REQUIRE_EQUAL(expected, food_chain::verse(1));
REQUIRE(expected == food_chain::verse(1));
}

#if defined(EXERCISM_RUN_ALL_TESTS)
BOOST_AUTO_TEST_CASE(spider)
TEST_CASE("spider")
{
string expected = "I know an old lady who swallowed a spider.\n"
"It wriggled and jiggled and tickled inside her.\n"
"She swallowed the spider to catch the fly.\n"
"I don't know why she swallowed the fly. Perhaps she'll die.\n";

BOOST_REQUIRE_EQUAL(expected, food_chain::verse(2));
REQUIRE(expected == food_chain::verse(2));
}

BOOST_AUTO_TEST_CASE(bird)
TEST_CASE("bird")
{
string expected = "I know an old lady who swallowed a bird.\n"
"How absurd to swallow a bird!\n"
"She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her.\n"
"She swallowed the spider to catch the fly.\n"
"I don't know why she swallowed the fly. Perhaps she'll die.\n";

BOOST_REQUIRE_EQUAL(expected, food_chain::verse(3));
REQUIRE(expected == food_chain::verse(3));
}

BOOST_AUTO_TEST_CASE(cat)
TEST_CASE("cat")
{
string expected = "I know an old lady who swallowed a cat.\n"
"Imagine that, to swallow a cat!\n"
Expand All @@ -44,10 +44,10 @@ BOOST_AUTO_TEST_CASE(cat)
"I don't know why she swallowed the fly. "
"Perhaps she'll die.\n";

BOOST_REQUIRE_EQUAL(expected, food_chain::verse(4));
REQUIRE(expected == food_chain::verse(4));
}

BOOST_AUTO_TEST_CASE(dog)
TEST_CASE("dog")
{
string expected = "I know an old lady who swallowed a dog.\n"
"What a hog, to swallow a dog!\n"
Expand All @@ -58,10 +58,10 @@ BOOST_AUTO_TEST_CASE(dog)
"I don't know why she swallowed the fly. "
"Perhaps she'll die.\n";

BOOST_REQUIRE_EQUAL(expected, food_chain::verse(5));
REQUIRE(expected == food_chain::verse(5));
}

BOOST_AUTO_TEST_CASE(goat)
TEST_CASE("goat")
{
string expected = "I know an old lady who swallowed a goat.\n"
"Just opened her throat and swallowed a goat!\n"
Expand All @@ -73,10 +73,10 @@ BOOST_AUTO_TEST_CASE(goat)
"I don't know why she swallowed the fly. "
"Perhaps she'll die.\n";

BOOST_REQUIRE_EQUAL(expected, food_chain::verse(6));
REQUIRE(expected == food_chain::verse(6));
}

BOOST_AUTO_TEST_CASE(cow)
TEST_CASE("cow")
{
string expected = "I know an old lady who swallowed a cow.\n"
"I don't know how she swallowed a cow!\n"
Expand All @@ -89,18 +89,18 @@ BOOST_AUTO_TEST_CASE(cow)
"I don't know why she swallowed the fly. "
"Perhaps she'll die.\n";

BOOST_REQUIRE_EQUAL(expected, food_chain::verse(7));
REQUIRE(expected == food_chain::verse(7));
}

BOOST_AUTO_TEST_CASE(horse)
TEST_CASE("horse")
{
string expected = "I know an old lady who swallowed a horse.\n"
"She's dead, of course!\n";

BOOST_REQUIRE_EQUAL(expected, food_chain::verse(8));
REQUIRE(expected == food_chain::verse(8));
}

BOOST_AUTO_TEST_CASE(multiple_verses)
TEST_CASE("multiple_verses")
{
string expected =
"I know an old lady who swallowed a fly.\n"
Expand All @@ -112,11 +112,11 @@ BOOST_AUTO_TEST_CASE(multiple_verses)
"I don't know why she swallowed the fly. Perhaps she'll die.\n"
"\n";

BOOST_REQUIRE_EQUAL(expected, food_chain::verses(1, 2));
REQUIRE(expected == food_chain::verses(1, 2));
}

BOOST_AUTO_TEST_CASE(the_whole_song)
TEST_CASE("the_whole_song")
{
BOOST_REQUIRE_EQUAL(food_chain::verses(1, 8), food_chain::sing());
REQUIRE(food_chain::verses(1, 8) == food_chain::sing());
}
#endif
Loading