trackler 2.1.0.0 → 2.1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/common/exercises/connect/description.md +2 -1
- data/common/exercises/crypto-square/canonical-data.json +2 -2
- data/common/exercises/two-bucket/canonical-data.json +27 -1
- data/lib/trackler/version.rb +1 -1
- data/tracks/c/exercises/perfect-numbers/src/example.c +8 -4
- data/tracks/clojure/config.json +5 -0
- data/tracks/clojure/exercises/secret-handshake/project.clj +4 -0
- data/tracks/clojure/exercises/secret-handshake/src/example.clj +19 -0
- data/tracks/clojure/exercises/secret-handshake/test/secret_handshake_test.clj +55 -0
- data/tracks/cpp/.travis.yml +4 -3
- data/tracks/cpp/README.md +1 -1
- data/tracks/cpp/config.json +171 -67
- data/tracks/cpp/docs/ABOUT.md +2 -2
- data/tracks/cpp/docs/INSTALLATION.md +22 -28
- data/tracks/cpp/docs/TESTS.md +1 -1
- data/tracks/cpp/exercises/anagram/CMakeLists.txt +2 -9
- data/tracks/cpp/exercises/beer-song/CMakeLists.txt +2 -9
- data/tracks/cpp/exercises/binary/CMakeLists.txt +2 -9
- data/tracks/cpp/exercises/bob/CMakeLists.txt +2 -9
- data/tracks/cpp/exercises/clock/CMakeLists.txt +2 -9
- data/tracks/cpp/exercises/clock/clock_test.cpp +188 -64
- data/tracks/cpp/exercises/clock/example.cpp +17 -12
- data/tracks/cpp/exercises/clock/example.h +1 -0
- data/tracks/cpp/exercises/crypto-square/CMakeLists.txt +2 -9
- data/tracks/cpp/exercises/difference-of-squares/CMakeLists.txt +2 -9
- data/tracks/cpp/exercises/etl/CMakeLists.txt +2 -9
- data/tracks/cpp/exercises/etl/etl_test.cpp +5 -5
- data/tracks/cpp/exercises/food-chain/CMakeLists.txt +2 -9
- data/tracks/cpp/exercises/gigasecond/CMakeLists.txt +2 -9
- data/tracks/cpp/exercises/gigasecond/example.cpp +2 -6
- data/tracks/cpp/exercises/gigasecond/example.h +2 -2
- data/tracks/cpp/exercises/gigasecond/gigasecond_test.cpp +26 -8
- data/tracks/cpp/exercises/grade-school/CMakeLists.txt +2 -9
- data/tracks/cpp/exercises/grade-school/grade_school_test.cpp +5 -6
- data/tracks/cpp/exercises/grains/CMakeLists.txt +2 -9
- data/tracks/cpp/exercises/hamming/CMakeLists.txt +2 -9
- data/tracks/cpp/exercises/hello-world/CMakeLists.txt +2 -9
- data/tracks/cpp/exercises/hexadecimal/CMakeLists.txt +2 -9
- data/tracks/cpp/exercises/leap/CMakeLists.txt +2 -9
- data/tracks/cpp/exercises/meetup/CMakeLists.txt +2 -9
- data/tracks/cpp/exercises/meetup/meetup_test.cpp +1 -1
- data/tracks/cpp/exercises/nth-prime/CMakeLists.txt +2 -9
- data/tracks/cpp/exercises/nucleotide-count/CMakeLists.txt +2 -9
- data/tracks/cpp/exercises/nucleotide-count/nucleotide_count_test.cpp +3 -4
- data/tracks/cpp/exercises/phone-number/CMakeLists.txt +2 -9
- data/tracks/cpp/exercises/prime-factors/CMakeLists.txt +2 -9
- data/tracks/cpp/exercises/queen-attack/CMakeLists.txt +2 -9
- data/tracks/cpp/exercises/raindrops/CMakeLists.txt +2 -9
- data/tracks/cpp/exercises/rna-transcription/CMakeLists.txt +2 -9
- data/tracks/cpp/exercises/robot-name/CMakeLists.txt +2 -9
- data/tracks/cpp/exercises/roman-numerals/CMakeLists.txt +2 -9
- data/tracks/cpp/exercises/say/CMakeLists.txt +2 -9
- data/tracks/cpp/exercises/scrabble-score/CMakeLists.txt +2 -9
- data/tracks/cpp/exercises/series/CMakeLists.txt +2 -9
- data/tracks/cpp/exercises/series/series_test.cpp +11 -11
- data/tracks/cpp/exercises/sieve/CMakeLists.txt +2 -9
- data/tracks/cpp/exercises/space-age/CMakeLists.txt +2 -9
- data/tracks/cpp/exercises/sum-of-multiples/CMakeLists.txt +2 -9
- data/tracks/cpp/exercises/triangle/CMakeLists.txt +2 -9
- data/tracks/cpp/exercises/trinary/CMakeLists.txt +2 -9
- data/tracks/cpp/exercises/word-count/CMakeLists.txt +2 -9
- data/tracks/cpp/exercises/word-count/word_count_test.cpp +14 -15
- data/tracks/go/README.md +27 -13
- data/tracks/go/config.json +1 -0
- data/tracks/go/exercises/connect/.meta/gen.go +1 -3
- data/tracks/go/exercises/connect/cases_test.go +2 -1
- data/tracks/go/exercises/custom-set/.meta/gen.go +122 -101
- data/tracks/go/exercises/custom-set/cases_test.go +13 -4
- data/tracks/go/exercises/custom-set/custom_set_test.go +2 -2
- data/tracks/go/exercises/hamming/.meta/gen.go +1 -3
- data/tracks/go/exercises/hamming/cases_test.go +7 -1
- data/tracks/go/exercises/hamming/example.go +1 -1
- data/tracks/go/exercises/hamming/hamming_test.go +1 -1
- data/tracks/go/exercises/hello-world/{hello_example_test.go → example_helloworld_test.go} +0 -0
- data/tracks/go/exercises/house/house_test.go +8 -8
- data/tracks/go/exercises/meetup/.meta/gen.go +1 -3
- data/tracks/go/exercises/meetup/cases_test.go +2 -1
- data/tracks/go/exercises/palindrome-products/example.go +1 -1
- data/tracks/go/exercises/palindrome-products/palindrome_products_test.go +1 -1
- data/tracks/go/exercises/pascals-triangle/pascals_triangle_test.go +24 -4
- data/tracks/go/exercises/rna-transcription/.meta/gen.go +1 -3
- data/tracks/go/exercises/rna-transcription/cases_test.go +2 -1
- data/tracks/go/exercises/roman-numerals/.meta/gen.go +1 -3
- data/tracks/go/exercises/roman-numerals/cases_test.go +2 -1
- data/tracks/go/exercises/roman-numerals/example.go +1 -1
- data/tracks/go/exercises/transpose/.meta/gen.go +1 -3
- data/tracks/go/exercises/transpose/cases_test.go +2 -1
- data/tracks/go/exercises/transpose/transpose_test.go +5 -0
- data/tracks/go/exercises/word-count/.meta/gen.go +1 -3
- data/tracks/go/exercises/word-count/cases_test.go +2 -1
- data/tracks/go/gen/gen.go +3 -2
- data/tracks/java/config.json +5 -0
- data/tracks/java/exercises/saddle-points/build.gradle +17 -0
- data/tracks/java/exercises/saddle-points/src/example/java/Matrix.java +44 -0
- data/tracks/java/exercises/saddle-points/src/example/java/MatrixCoordinate.java +31 -0
- data/tracks/java/exercises/saddle-points/src/main/java/Matrix.java +5 -0
- data/tracks/java/exercises/saddle-points/src/main/java/MatrixCoordinate.java +31 -0
- data/tracks/java/exercises/saddle-points/src/test/java/MatrixTest.java +82 -0
- data/tracks/java/exercises/settings.gradle +1 -0
- data/tracks/javascript/.travis.yml +3 -1
- data/tracks/javascript/Makefile +2 -8
- data/tracks/javascript/SETUP.md +1 -2
- data/tracks/javascript/docs/INSTALLATION.md +3 -4
- data/tracks/javascript/docs/TESTS.md +14 -26
- data/tracks/javascript/exercises/hamming/example.js +7 -11
- data/tracks/javascript/exercises/hello-world/HINTS.md +3 -3
- data/tracks/javascript/exercises/robot-simulator/example.js +72 -73
- data/tracks/perl6/config.json +5 -0
- data/tracks/perl6/exercises/clock/Clock.pm6 +4 -0
- data/tracks/perl6/exercises/clock/Example.pm6 +12 -0
- data/tracks/perl6/exercises/clock/clock.t +534 -0
- data/tracks/perl6/exercises/clock/example.yaml +16 -0
- data/tracks/perl6/exercises/robot-name/Example.pm +11 -4
- data/tracks/php/exercises/hello-world/hello-world.php +1 -1
- data/tracks/php/exercises/hello-world/hello-world_test.php +1 -11
- data/tracks/php/exercises/robot-name/robot-name_test.php +1 -0
- data/tracks/purescript/config.json +7 -0
- data/tracks/purescript/exercises/largest-series-product/bower.json +16 -0
- data/tracks/purescript/exercises/largest-series-product/examples/src/LargestSeriesProduct.purs +31 -0
- data/tracks/purescript/exercises/largest-series-product/src/LargestSeriesProduct.purs +3 -0
- data/tracks/purescript/exercises/largest-series-product/test/Main.purs +73 -0
- data/tracks/python/exercises/sublist/sublist_test.py +94 -55
- data/tracks/ruby/README.md +38 -25
- data/tracks/ruby/exercises/hamming/example.tt +6 -4
- data/tracks/ruby/exercises/hamming/hamming_test.rb +4 -5
- data/tracks/ruby/exercises/linked-list/linked_list_test.rb +16 -0
- data/tracks/ruby/exercises/luhn/luhn_test.rb +5 -5
- data/tracks/ruby/exercises/ocr-numbers/.meta/.version +1 -0
- data/tracks/ruby/exercises/ocr-numbers/example.rb +42 -61
- data/tracks/ruby/exercises/ocr-numbers/example.tt +21 -0
- data/tracks/ruby/exercises/ocr-numbers/ocr_numbers_test.rb +63 -138
- data/tracks/ruby/lib/generator/exercise_cases.rb +43 -0
- data/tracks/ruby/lib/generator/underscore.rb +9 -0
- data/tracks/ruby/lib/hamming_cases.rb +9 -14
- data/tracks/ruby/lib/luhn_cases.rb +2 -18
- data/tracks/ruby/lib/ocr_numbers_cases.rb +20 -0
- data/tracks/ruby/lib/pig_latin_cases.rb +2 -12
- data/tracks/ruby/test/generator/underscore_test.rb +23 -0
- data/tracks/scala/config.json +316 -316
- metadata +26 -10
- data/tracks/cpp/exercises/etl/require_equal_containers.h +0 -88
- data/tracks/cpp/exercises/grade-school/require_equal_containers.h +0 -88
- data/tracks/cpp/exercises/nucleotide-count/require_equal_containers.h +0 -88
- data/tracks/cpp/exercises/series/require_equal_containers.h +0 -88
- data/tracks/cpp/exercises/word-count/require_equal_containers.h +0 -88
- data/tracks/javascript/exercises/acronym/package.json +0 -12
- data/tracks/javascript/package.json +0 -12
@@ -18,24 +18,14 @@ namespace date_independent
|
|
18
18
|
clock& clock::plus(int minutes)
|
19
19
|
{
|
20
20
|
minute_ += minutes;
|
21
|
-
|
22
|
-
hour_ += (minute_/minutes_per_hour);
|
23
|
-
hour_ %= hours_per_day;
|
24
|
-
minute_ %= minutes_per_hour;
|
25
|
-
}
|
21
|
+
clean();
|
26
22
|
return *this;
|
27
23
|
}
|
28
24
|
|
29
25
|
clock& clock::minus(int minutes)
|
30
26
|
{
|
31
27
|
minute_ -= minutes;
|
32
|
-
|
33
|
-
--hour_;
|
34
|
-
minute_ += minutes_per_hour;
|
35
|
-
}
|
36
|
-
while (hour_ < 0) {
|
37
|
-
hour_ += hours_per_day;
|
38
|
-
}
|
28
|
+
clean();
|
39
29
|
return *this;
|
40
30
|
}
|
41
31
|
|
@@ -50,6 +40,21 @@ clock::clock(int hour, int minute)
|
|
50
40
|
: hour_(hour),
|
51
41
|
minute_(minute)
|
52
42
|
{
|
43
|
+
clean();
|
44
|
+
}
|
45
|
+
|
46
|
+
void clock::clean()
|
47
|
+
{
|
48
|
+
if (minute_ < 0) {
|
49
|
+
int tmp = 1 + (minute_ / -minutes_per_hour);
|
50
|
+
hour_ -= tmp;
|
51
|
+
minute_ += minutes_per_hour * tmp;
|
52
|
+
}
|
53
|
+
if (hour_ < 0)
|
54
|
+
hour_ += hours_per_day*(1 + (hour_ / -hours_per_day));
|
55
|
+
hour_ += minute_ / minutes_per_hour;
|
56
|
+
hour_ %= hours_per_day;
|
57
|
+
minute_ %= minutes_per_hour;
|
53
58
|
}
|
54
59
|
|
55
60
|
clock clock::at(int hour, int minute /*= 0*/)
|
@@ -11,7 +11,7 @@ project(${exercise} CXX)
|
|
11
11
|
set(Boost_USE_STATIC_LIBS ON)
|
12
12
|
set(Boost_USE_MULTITHREADED ON)
|
13
13
|
set(Boost_USE_STATIC_RUNTIME OFF)
|
14
|
-
find_package(Boost 1.
|
14
|
+
find_package(Boost 1.59 REQUIRED COMPONENTS unit_test_framework date_time regex)
|
15
15
|
|
16
16
|
# Enable C++11 features on gcc/clang
|
17
17
|
if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)")
|
@@ -33,15 +33,8 @@ else()
|
|
33
33
|
set(exercise_cpp "")
|
34
34
|
endif()
|
35
35
|
|
36
|
-
# Include a test helper header if it exists
|
37
|
-
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/require_equal_containers.h)
|
38
|
-
set(test_helper require_equal_containers.h)
|
39
|
-
else()
|
40
|
-
set(test_helper "")
|
41
|
-
endif()
|
42
|
-
|
43
36
|
# Build executable from sources and headers
|
44
|
-
add_executable(${exercise} ${file}_test.cpp ${
|
37
|
+
add_executable(${exercise} ${file}_test.cpp ${exercise_cpp} ${file}.h)
|
45
38
|
|
46
39
|
# We need boost includes
|
47
40
|
target_include_directories(${exercise} PRIVATE ${Boost_INCLUDE_DIRS})
|
@@ -11,7 +11,7 @@ project(${exercise} CXX)
|
|
11
11
|
set(Boost_USE_STATIC_LIBS ON)
|
12
12
|
set(Boost_USE_MULTITHREADED ON)
|
13
13
|
set(Boost_USE_STATIC_RUNTIME OFF)
|
14
|
-
find_package(Boost 1.
|
14
|
+
find_package(Boost 1.59 REQUIRED COMPONENTS unit_test_framework date_time regex)
|
15
15
|
|
16
16
|
# Enable C++11 features on gcc/clang
|
17
17
|
if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)")
|
@@ -33,15 +33,8 @@ else()
|
|
33
33
|
set(exercise_cpp "")
|
34
34
|
endif()
|
35
35
|
|
36
|
-
# Include a test helper header if it exists
|
37
|
-
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/require_equal_containers.h)
|
38
|
-
set(test_helper require_equal_containers.h)
|
39
|
-
else()
|
40
|
-
set(test_helper "")
|
41
|
-
endif()
|
42
|
-
|
43
36
|
# Build executable from sources and headers
|
44
|
-
add_executable(${exercise} ${file}_test.cpp ${
|
37
|
+
add_executable(${exercise} ${file}_test.cpp ${exercise_cpp} ${file}.h)
|
45
38
|
|
46
39
|
# We need boost includes
|
47
40
|
target_include_directories(${exercise} PRIVATE ${Boost_INCLUDE_DIRS})
|
@@ -11,7 +11,7 @@ project(${exercise} CXX)
|
|
11
11
|
set(Boost_USE_STATIC_LIBS ON)
|
12
12
|
set(Boost_USE_MULTITHREADED ON)
|
13
13
|
set(Boost_USE_STATIC_RUNTIME OFF)
|
14
|
-
find_package(Boost 1.
|
14
|
+
find_package(Boost 1.59 REQUIRED COMPONENTS unit_test_framework date_time regex)
|
15
15
|
|
16
16
|
# Enable C++11 features on gcc/clang
|
17
17
|
if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)")
|
@@ -33,15 +33,8 @@ else()
|
|
33
33
|
set(exercise_cpp "")
|
34
34
|
endif()
|
35
35
|
|
36
|
-
# Include a test helper header if it exists
|
37
|
-
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/require_equal_containers.h)
|
38
|
-
set(test_helper require_equal_containers.h)
|
39
|
-
else()
|
40
|
-
set(test_helper "")
|
41
|
-
endif()
|
42
|
-
|
43
36
|
# Build executable from sources and headers
|
44
|
-
add_executable(${exercise} ${file}_test.cpp ${
|
37
|
+
add_executable(${exercise} ${file}_test.cpp ${exercise_cpp} ${file}.h)
|
45
38
|
|
46
39
|
# We need boost includes
|
47
40
|
target_include_directories(${exercise} PRIVATE ${Boost_INCLUDE_DIRS})
|
@@ -1,7 +1,7 @@
|
|
1
1
|
#include "etl.h"
|
2
2
|
#define BOOST_TEST_MAIN
|
3
|
+
#include <map>
|
3
4
|
#include <boost/test/unit_test.hpp>
|
4
|
-
#include "require_equal_containers.h"
|
5
5
|
|
6
6
|
BOOST_AUTO_TEST_CASE(transforms_one_value)
|
7
7
|
{
|
@@ -10,7 +10,7 @@ BOOST_AUTO_TEST_CASE(transforms_one_value)
|
|
10
10
|
const auto actual = etl::transform(old);
|
11
11
|
|
12
12
|
const std::map<char, int> expected{{'a', 1}};
|
13
|
-
|
13
|
+
BOOST_TEST(expected == actual);
|
14
14
|
}
|
15
15
|
|
16
16
|
#if defined(EXERCISM_RUN_ALL_TESTS)
|
@@ -21,7 +21,7 @@ BOOST_AUTO_TEST_CASE(transforms_more_values)
|
|
21
21
|
const auto actual = etl::transform(old);
|
22
22
|
|
23
23
|
const std::map<char, int> expected{{'a', 1}, {'e', 1}, {'i', 1}, {'o', 1}, {'u', 1}};
|
24
|
-
|
24
|
+
BOOST_TEST(expected == actual);
|
25
25
|
}
|
26
26
|
|
27
27
|
BOOST_AUTO_TEST_CASE(transforms_more_keys)
|
@@ -31,7 +31,7 @@ BOOST_AUTO_TEST_CASE(transforms_more_keys)
|
|
31
31
|
const auto actual = etl::transform(old);
|
32
32
|
|
33
33
|
const std::map<char, int> expected{{'a', 1}, {'e', 1}, {'d', 2}, {'g', 2}};
|
34
|
-
|
34
|
+
BOOST_TEST(expected == actual);
|
35
35
|
}
|
36
36
|
|
37
37
|
BOOST_AUTO_TEST_CASE(transforms_a_full_dataset)
|
@@ -56,6 +56,6 @@ BOOST_AUTO_TEST_CASE(transforms_a_full_dataset)
|
|
56
56
|
{'u', 1}, {'v', 4}, {'w', 4}, {'x', 8}, {'y', 4},
|
57
57
|
{'z', 10}
|
58
58
|
};
|
59
|
-
|
59
|
+
BOOST_TEST(expected == actual);
|
60
60
|
}
|
61
61
|
#endif
|
@@ -11,7 +11,7 @@ project(${exercise} CXX)
|
|
11
11
|
set(Boost_USE_STATIC_LIBS ON)
|
12
12
|
set(Boost_USE_MULTITHREADED ON)
|
13
13
|
set(Boost_USE_STATIC_RUNTIME OFF)
|
14
|
-
find_package(Boost 1.
|
14
|
+
find_package(Boost 1.59 REQUIRED COMPONENTS unit_test_framework date_time regex)
|
15
15
|
|
16
16
|
# Enable C++11 features on gcc/clang
|
17
17
|
if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)")
|
@@ -33,15 +33,8 @@ else()
|
|
33
33
|
set(exercise_cpp "")
|
34
34
|
endif()
|
35
35
|
|
36
|
-
# Include a test helper header if it exists
|
37
|
-
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/require_equal_containers.h)
|
38
|
-
set(test_helper require_equal_containers.h)
|
39
|
-
else()
|
40
|
-
set(test_helper "")
|
41
|
-
endif()
|
42
|
-
|
43
36
|
# Build executable from sources and headers
|
44
|
-
add_executable(${exercise} ${file}_test.cpp ${
|
37
|
+
add_executable(${exercise} ${file}_test.cpp ${exercise_cpp} ${file}.h)
|
45
38
|
|
46
39
|
# We need boost includes
|
47
40
|
target_include_directories(${exercise} PRIVATE ${Boost_INCLUDE_DIRS})
|
@@ -11,7 +11,7 @@ project(${exercise} CXX)
|
|
11
11
|
set(Boost_USE_STATIC_LIBS ON)
|
12
12
|
set(Boost_USE_MULTITHREADED ON)
|
13
13
|
set(Boost_USE_STATIC_RUNTIME OFF)
|
14
|
-
find_package(Boost 1.
|
14
|
+
find_package(Boost 1.59 REQUIRED COMPONENTS unit_test_framework date_time regex)
|
15
15
|
|
16
16
|
# Enable C++11 features on gcc/clang
|
17
17
|
if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)")
|
@@ -33,15 +33,8 @@ else()
|
|
33
33
|
set(exercise_cpp "")
|
34
34
|
endif()
|
35
35
|
|
36
|
-
# Include a test helper header if it exists
|
37
|
-
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/require_equal_containers.h)
|
38
|
-
set(test_helper require_equal_containers.h)
|
39
|
-
else()
|
40
|
-
set(test_helper "")
|
41
|
-
endif()
|
42
|
-
|
43
36
|
# Build executable from sources and headers
|
44
|
-
add_executable(${exercise} ${file}_test.cpp ${
|
37
|
+
add_executable(${exercise} ${file}_test.cpp ${exercise_cpp} ${file}.h)
|
45
38
|
|
46
39
|
# We need boost includes
|
47
40
|
target_include_directories(${exercise} PRIVATE ${Boost_INCLUDE_DIRS})
|
@@ -3,13 +3,9 @@
|
|
3
3
|
namespace gigasecond
|
4
4
|
{
|
5
5
|
|
6
|
-
boost::
|
6
|
+
boost::posix_time::ptime advance(const boost::posix_time::ptime& start)
|
7
7
|
{
|
8
|
-
|
9
|
-
const unsigned long long seconds_per_hour = 60*seconds_per_minute;
|
10
|
-
const unsigned long long seconds_per_day = 24*seconds_per_hour;
|
11
|
-
const unsigned long long one_giga_second = 1000000000;
|
12
|
-
return start + boost::gregorian::days(one_giga_second/seconds_per_day);
|
8
|
+
return start + boost::posix_time::seconds(1e9);
|
13
9
|
}
|
14
10
|
|
15
11
|
}
|
@@ -1,12 +1,12 @@
|
|
1
1
|
#if !defined(GIGASECOND_H)
|
2
2
|
#define GIGASECOND_H
|
3
3
|
|
4
|
-
#include <boost/date_time/
|
4
|
+
#include <boost/date_time/posix_time/posix_time.hpp>
|
5
5
|
|
6
6
|
namespace gigasecond
|
7
7
|
{
|
8
8
|
|
9
|
-
boost::
|
9
|
+
boost::posix_time::ptime advance(const boost::posix_time::ptime& start);
|
10
10
|
|
11
11
|
}
|
12
12
|
|
@@ -2,31 +2,49 @@
|
|
2
2
|
#define BOOST_TEST_MAIN
|
3
3
|
#include <boost/test/unit_test.hpp>
|
4
4
|
|
5
|
-
// See <http://www.boost.org/doc/libs/
|
6
|
-
// for documentation on boost::
|
5
|
+
// See <http://www.boost.org/doc/libs/1_59_0/doc/html/date_time/posix_time.html>
|
6
|
+
// for documentation on boost::posix_time
|
7
|
+
|
8
|
+
using namespace boost::posix_time;
|
7
9
|
|
8
10
|
BOOST_AUTO_TEST_CASE(test_1)
|
9
11
|
{
|
10
|
-
const auto actual = gigasecond::advance(
|
12
|
+
const auto actual = gigasecond::advance(time_from_string("2011-04-25 00:00:00"));
|
11
13
|
|
12
|
-
const
|
14
|
+
const ptime expected(time_from_string("2043-01-01 01:46:40"));
|
13
15
|
BOOST_REQUIRE_EQUAL(expected, actual);
|
14
16
|
}
|
15
17
|
|
16
18
|
#if defined(EXERCISM_RUN_ALL_TESTS)
|
17
19
|
BOOST_AUTO_TEST_CASE(test_2)
|
18
20
|
{
|
19
|
-
const auto actual = gigasecond::advance(
|
21
|
+
const auto actual = gigasecond::advance(time_from_string("1977-06-13 00:00:00"));
|
20
22
|
|
21
|
-
const
|
23
|
+
const ptime expected(time_from_string("2009-02-19 01:46:40"));
|
22
24
|
BOOST_REQUIRE_EQUAL(expected, actual);
|
23
25
|
}
|
24
26
|
|
25
27
|
BOOST_AUTO_TEST_CASE(test_3)
|
26
28
|
{
|
27
|
-
const auto actual = gigasecond::advance(
|
29
|
+
const auto actual = gigasecond::advance(time_from_string("1959-07-19 00:00:00"));
|
30
|
+
|
31
|
+
const ptime expected(time_from_string("1991-03-27 01:46:40"));
|
32
|
+
BOOST_REQUIRE_EQUAL(expected, actual);
|
33
|
+
}
|
34
|
+
|
35
|
+
BOOST_AUTO_TEST_CASE(test_4)
|
36
|
+
{
|
37
|
+
const auto actual = gigasecond::advance(time_from_string("2015-01-24 22:00:00"));
|
38
|
+
|
39
|
+
const ptime expected(time_from_string("2046-10-02 23:46:40"));
|
40
|
+
BOOST_REQUIRE_EQUAL(expected, actual);
|
41
|
+
}
|
42
|
+
|
43
|
+
BOOST_AUTO_TEST_CASE(test_5)
|
44
|
+
{
|
45
|
+
const auto actual = gigasecond::advance(time_from_string("2015-01-24 23:59:59"));
|
28
46
|
|
29
|
-
const
|
47
|
+
const ptime expected(time_from_string("2046-10-03 01:46:39"));
|
30
48
|
BOOST_REQUIRE_EQUAL(expected, actual);
|
31
49
|
}
|
32
50
|
#endif
|
@@ -11,7 +11,7 @@ project(${exercise} CXX)
|
|
11
11
|
set(Boost_USE_STATIC_LIBS ON)
|
12
12
|
set(Boost_USE_MULTITHREADED ON)
|
13
13
|
set(Boost_USE_STATIC_RUNTIME OFF)
|
14
|
-
find_package(Boost 1.
|
14
|
+
find_package(Boost 1.59 REQUIRED COMPONENTS unit_test_framework date_time regex)
|
15
15
|
|
16
16
|
# Enable C++11 features on gcc/clang
|
17
17
|
if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)")
|
@@ -33,15 +33,8 @@ else()
|
|
33
33
|
set(exercise_cpp "")
|
34
34
|
endif()
|
35
35
|
|
36
|
-
# Include a test helper header if it exists
|
37
|
-
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/require_equal_containers.h)
|
38
|
-
set(test_helper require_equal_containers.h)
|
39
|
-
else()
|
40
|
-
set(test_helper "")
|
41
|
-
endif()
|
42
|
-
|
43
36
|
# Build executable from sources and headers
|
44
|
-
add_executable(${exercise} ${file}_test.cpp ${
|
37
|
+
add_executable(${exercise} ${file}_test.cpp ${exercise_cpp} ${file}.h)
|
45
38
|
|
46
39
|
# We need boost includes
|
47
40
|
target_include_directories(${exercise} PRIVATE ${Boost_INCLUDE_DIRS})
|
@@ -1,7 +1,6 @@
|
|
1
1
|
#include "grade_school.h"
|
2
2
|
#define BOOST_TEST_MAIN
|
3
3
|
#include <boost/test/unit_test.hpp>
|
4
|
-
#include "require_equal_containers.h"
|
5
4
|
|
6
5
|
using namespace std;
|
7
6
|
|
@@ -25,7 +24,7 @@ BOOST_AUTO_TEST_CASE(adding_a_student_adds_them_to_the_roster_for_the_given_grad
|
|
25
24
|
const auto actual = school_.roster();
|
26
25
|
|
27
26
|
const map<int, vector<string>> expected{{2, {"Aimee"}}};
|
28
|
-
|
27
|
+
BOOST_TEST(expected == actual);
|
29
28
|
}
|
30
29
|
|
31
30
|
BOOST_AUTO_TEST_CASE(adding_more_students_to_the_same_grade_adds_them_to_the_roster)
|
@@ -37,7 +36,7 @@ BOOST_AUTO_TEST_CASE(adding_more_students_to_the_same_grade_adds_them_to_the_ros
|
|
37
36
|
const auto actual = school_.roster();
|
38
37
|
|
39
38
|
const map<int, vector<string>> expected{{2, {"Blair", "James", "Paul"}}};
|
40
|
-
|
39
|
+
BOOST_TEST(expected == actual);
|
41
40
|
}
|
42
41
|
|
43
42
|
BOOST_AUTO_TEST_CASE(adding_students_to_different_grades_adds_them_to_the_roster)
|
@@ -48,7 +47,7 @@ BOOST_AUTO_TEST_CASE(adding_students_to_different_grades_adds_them_to_the_roster
|
|
48
47
|
const auto actual = school_.roster();
|
49
48
|
|
50
49
|
const map<int, vector<string>> expected{{3, {"Chelsea"}}, {7, {"Logan"}}};
|
51
|
-
|
50
|
+
BOOST_TEST(expected == actual);
|
52
51
|
}
|
53
52
|
|
54
53
|
BOOST_AUTO_TEST_CASE(grade_returns_the_students_in_that_grade_in_alphabetical_order)
|
@@ -60,7 +59,7 @@ BOOST_AUTO_TEST_CASE(grade_returns_the_students_in_that_grade_in_alphabetical_or
|
|
60
59
|
const auto actual = school_.grade(5);
|
61
60
|
|
62
61
|
const vector<string> expected{"Bradley", "Franklin"};
|
63
|
-
|
62
|
+
BOOST_TEST(expected == actual);
|
64
63
|
}
|
65
64
|
|
66
65
|
BOOST_AUTO_TEST_CASE(grade_returns_an_empty_array_if_there_are_no_students_in_that_grade)
|
@@ -84,7 +83,7 @@ BOOST_AUTO_TEST_CASE(the_student_names_in_each_grade_in_the_roster_are_sorted)
|
|
84
83
|
{4, {"Christopher", "Jennifer"}},
|
85
84
|
{6, {"Kareem"}}
|
86
85
|
};
|
87
|
-
|
86
|
+
BOOST_TEST(expected == actual);
|
88
87
|
}
|
89
88
|
#endif
|
90
89
|
|
@@ -11,7 +11,7 @@ project(${exercise} CXX)
|
|
11
11
|
set(Boost_USE_STATIC_LIBS ON)
|
12
12
|
set(Boost_USE_MULTITHREADED ON)
|
13
13
|
set(Boost_USE_STATIC_RUNTIME OFF)
|
14
|
-
find_package(Boost 1.
|
14
|
+
find_package(Boost 1.59 REQUIRED COMPONENTS unit_test_framework date_time regex)
|
15
15
|
|
16
16
|
# Enable C++11 features on gcc/clang
|
17
17
|
if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)")
|
@@ -33,15 +33,8 @@ else()
|
|
33
33
|
set(exercise_cpp "")
|
34
34
|
endif()
|
35
35
|
|
36
|
-
# Include a test helper header if it exists
|
37
|
-
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/require_equal_containers.h)
|
38
|
-
set(test_helper require_equal_containers.h)
|
39
|
-
else()
|
40
|
-
set(test_helper "")
|
41
|
-
endif()
|
42
|
-
|
43
36
|
# Build executable from sources and headers
|
44
|
-
add_executable(${exercise} ${file}_test.cpp ${
|
37
|
+
add_executable(${exercise} ${file}_test.cpp ${exercise_cpp} ${file}.h)
|
45
38
|
|
46
39
|
# We need boost includes
|
47
40
|
target_include_directories(${exercise} PRIVATE ${Boost_INCLUDE_DIRS})
|
@@ -11,7 +11,7 @@ project(${exercise} CXX)
|
|
11
11
|
set(Boost_USE_STATIC_LIBS ON)
|
12
12
|
set(Boost_USE_MULTITHREADED ON)
|
13
13
|
set(Boost_USE_STATIC_RUNTIME OFF)
|
14
|
-
find_package(Boost 1.
|
14
|
+
find_package(Boost 1.59 REQUIRED COMPONENTS unit_test_framework date_time regex)
|
15
15
|
|
16
16
|
# Enable C++11 features on gcc/clang
|
17
17
|
if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)")
|
@@ -33,15 +33,8 @@ else()
|
|
33
33
|
set(exercise_cpp "")
|
34
34
|
endif()
|
35
35
|
|
36
|
-
# Include a test helper header if it exists
|
37
|
-
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/require_equal_containers.h)
|
38
|
-
set(test_helper require_equal_containers.h)
|
39
|
-
else()
|
40
|
-
set(test_helper "")
|
41
|
-
endif()
|
42
|
-
|
43
36
|
# Build executable from sources and headers
|
44
|
-
add_executable(${exercise} ${file}_test.cpp ${
|
37
|
+
add_executable(${exercise} ${file}_test.cpp ${exercise_cpp} ${file}.h)
|
45
38
|
|
46
39
|
# We need boost includes
|
47
40
|
target_include_directories(${exercise} PRIVATE ${Boost_INCLUDE_DIRS})
|