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.
Files changed (148) hide show
  1. checksums.yaml +4 -4
  2. data/common/exercises/connect/description.md +2 -1
  3. data/common/exercises/crypto-square/canonical-data.json +2 -2
  4. data/common/exercises/two-bucket/canonical-data.json +27 -1
  5. data/lib/trackler/version.rb +1 -1
  6. data/tracks/c/exercises/perfect-numbers/src/example.c +8 -4
  7. data/tracks/clojure/config.json +5 -0
  8. data/tracks/clojure/exercises/secret-handshake/project.clj +4 -0
  9. data/tracks/clojure/exercises/secret-handshake/src/example.clj +19 -0
  10. data/tracks/clojure/exercises/secret-handshake/test/secret_handshake_test.clj +55 -0
  11. data/tracks/cpp/.travis.yml +4 -3
  12. data/tracks/cpp/README.md +1 -1
  13. data/tracks/cpp/config.json +171 -67
  14. data/tracks/cpp/docs/ABOUT.md +2 -2
  15. data/tracks/cpp/docs/INSTALLATION.md +22 -28
  16. data/tracks/cpp/docs/TESTS.md +1 -1
  17. data/tracks/cpp/exercises/anagram/CMakeLists.txt +2 -9
  18. data/tracks/cpp/exercises/beer-song/CMakeLists.txt +2 -9
  19. data/tracks/cpp/exercises/binary/CMakeLists.txt +2 -9
  20. data/tracks/cpp/exercises/bob/CMakeLists.txt +2 -9
  21. data/tracks/cpp/exercises/clock/CMakeLists.txt +2 -9
  22. data/tracks/cpp/exercises/clock/clock_test.cpp +188 -64
  23. data/tracks/cpp/exercises/clock/example.cpp +17 -12
  24. data/tracks/cpp/exercises/clock/example.h +1 -0
  25. data/tracks/cpp/exercises/crypto-square/CMakeLists.txt +2 -9
  26. data/tracks/cpp/exercises/difference-of-squares/CMakeLists.txt +2 -9
  27. data/tracks/cpp/exercises/etl/CMakeLists.txt +2 -9
  28. data/tracks/cpp/exercises/etl/etl_test.cpp +5 -5
  29. data/tracks/cpp/exercises/food-chain/CMakeLists.txt +2 -9
  30. data/tracks/cpp/exercises/gigasecond/CMakeLists.txt +2 -9
  31. data/tracks/cpp/exercises/gigasecond/example.cpp +2 -6
  32. data/tracks/cpp/exercises/gigasecond/example.h +2 -2
  33. data/tracks/cpp/exercises/gigasecond/gigasecond_test.cpp +26 -8
  34. data/tracks/cpp/exercises/grade-school/CMakeLists.txt +2 -9
  35. data/tracks/cpp/exercises/grade-school/grade_school_test.cpp +5 -6
  36. data/tracks/cpp/exercises/grains/CMakeLists.txt +2 -9
  37. data/tracks/cpp/exercises/hamming/CMakeLists.txt +2 -9
  38. data/tracks/cpp/exercises/hello-world/CMakeLists.txt +2 -9
  39. data/tracks/cpp/exercises/hexadecimal/CMakeLists.txt +2 -9
  40. data/tracks/cpp/exercises/leap/CMakeLists.txt +2 -9
  41. data/tracks/cpp/exercises/meetup/CMakeLists.txt +2 -9
  42. data/tracks/cpp/exercises/meetup/meetup_test.cpp +1 -1
  43. data/tracks/cpp/exercises/nth-prime/CMakeLists.txt +2 -9
  44. data/tracks/cpp/exercises/nucleotide-count/CMakeLists.txt +2 -9
  45. data/tracks/cpp/exercises/nucleotide-count/nucleotide_count_test.cpp +3 -4
  46. data/tracks/cpp/exercises/phone-number/CMakeLists.txt +2 -9
  47. data/tracks/cpp/exercises/prime-factors/CMakeLists.txt +2 -9
  48. data/tracks/cpp/exercises/queen-attack/CMakeLists.txt +2 -9
  49. data/tracks/cpp/exercises/raindrops/CMakeLists.txt +2 -9
  50. data/tracks/cpp/exercises/rna-transcription/CMakeLists.txt +2 -9
  51. data/tracks/cpp/exercises/robot-name/CMakeLists.txt +2 -9
  52. data/tracks/cpp/exercises/roman-numerals/CMakeLists.txt +2 -9
  53. data/tracks/cpp/exercises/say/CMakeLists.txt +2 -9
  54. data/tracks/cpp/exercises/scrabble-score/CMakeLists.txt +2 -9
  55. data/tracks/cpp/exercises/series/CMakeLists.txt +2 -9
  56. data/tracks/cpp/exercises/series/series_test.cpp +11 -11
  57. data/tracks/cpp/exercises/sieve/CMakeLists.txt +2 -9
  58. data/tracks/cpp/exercises/space-age/CMakeLists.txt +2 -9
  59. data/tracks/cpp/exercises/sum-of-multiples/CMakeLists.txt +2 -9
  60. data/tracks/cpp/exercises/triangle/CMakeLists.txt +2 -9
  61. data/tracks/cpp/exercises/trinary/CMakeLists.txt +2 -9
  62. data/tracks/cpp/exercises/word-count/CMakeLists.txt +2 -9
  63. data/tracks/cpp/exercises/word-count/word_count_test.cpp +14 -15
  64. data/tracks/go/README.md +27 -13
  65. data/tracks/go/config.json +1 -0
  66. data/tracks/go/exercises/connect/.meta/gen.go +1 -3
  67. data/tracks/go/exercises/connect/cases_test.go +2 -1
  68. data/tracks/go/exercises/custom-set/.meta/gen.go +122 -101
  69. data/tracks/go/exercises/custom-set/cases_test.go +13 -4
  70. data/tracks/go/exercises/custom-set/custom_set_test.go +2 -2
  71. data/tracks/go/exercises/hamming/.meta/gen.go +1 -3
  72. data/tracks/go/exercises/hamming/cases_test.go +7 -1
  73. data/tracks/go/exercises/hamming/example.go +1 -1
  74. data/tracks/go/exercises/hamming/hamming_test.go +1 -1
  75. data/tracks/go/exercises/hello-world/{hello_example_test.go → example_helloworld_test.go} +0 -0
  76. data/tracks/go/exercises/house/house_test.go +8 -8
  77. data/tracks/go/exercises/meetup/.meta/gen.go +1 -3
  78. data/tracks/go/exercises/meetup/cases_test.go +2 -1
  79. data/tracks/go/exercises/palindrome-products/example.go +1 -1
  80. data/tracks/go/exercises/palindrome-products/palindrome_products_test.go +1 -1
  81. data/tracks/go/exercises/pascals-triangle/pascals_triangle_test.go +24 -4
  82. data/tracks/go/exercises/rna-transcription/.meta/gen.go +1 -3
  83. data/tracks/go/exercises/rna-transcription/cases_test.go +2 -1
  84. data/tracks/go/exercises/roman-numerals/.meta/gen.go +1 -3
  85. data/tracks/go/exercises/roman-numerals/cases_test.go +2 -1
  86. data/tracks/go/exercises/roman-numerals/example.go +1 -1
  87. data/tracks/go/exercises/transpose/.meta/gen.go +1 -3
  88. data/tracks/go/exercises/transpose/cases_test.go +2 -1
  89. data/tracks/go/exercises/transpose/transpose_test.go +5 -0
  90. data/tracks/go/exercises/word-count/.meta/gen.go +1 -3
  91. data/tracks/go/exercises/word-count/cases_test.go +2 -1
  92. data/tracks/go/gen/gen.go +3 -2
  93. data/tracks/java/config.json +5 -0
  94. data/tracks/java/exercises/saddle-points/build.gradle +17 -0
  95. data/tracks/java/exercises/saddle-points/src/example/java/Matrix.java +44 -0
  96. data/tracks/java/exercises/saddle-points/src/example/java/MatrixCoordinate.java +31 -0
  97. data/tracks/java/exercises/saddle-points/src/main/java/Matrix.java +5 -0
  98. data/tracks/java/exercises/saddle-points/src/main/java/MatrixCoordinate.java +31 -0
  99. data/tracks/java/exercises/saddle-points/src/test/java/MatrixTest.java +82 -0
  100. data/tracks/java/exercises/settings.gradle +1 -0
  101. data/tracks/javascript/.travis.yml +3 -1
  102. data/tracks/javascript/Makefile +2 -8
  103. data/tracks/javascript/SETUP.md +1 -2
  104. data/tracks/javascript/docs/INSTALLATION.md +3 -4
  105. data/tracks/javascript/docs/TESTS.md +14 -26
  106. data/tracks/javascript/exercises/hamming/example.js +7 -11
  107. data/tracks/javascript/exercises/hello-world/HINTS.md +3 -3
  108. data/tracks/javascript/exercises/robot-simulator/example.js +72 -73
  109. data/tracks/perl6/config.json +5 -0
  110. data/tracks/perl6/exercises/clock/Clock.pm6 +4 -0
  111. data/tracks/perl6/exercises/clock/Example.pm6 +12 -0
  112. data/tracks/perl6/exercises/clock/clock.t +534 -0
  113. data/tracks/perl6/exercises/clock/example.yaml +16 -0
  114. data/tracks/perl6/exercises/robot-name/Example.pm +11 -4
  115. data/tracks/php/exercises/hello-world/hello-world.php +1 -1
  116. data/tracks/php/exercises/hello-world/hello-world_test.php +1 -11
  117. data/tracks/php/exercises/robot-name/robot-name_test.php +1 -0
  118. data/tracks/purescript/config.json +7 -0
  119. data/tracks/purescript/exercises/largest-series-product/bower.json +16 -0
  120. data/tracks/purescript/exercises/largest-series-product/examples/src/LargestSeriesProduct.purs +31 -0
  121. data/tracks/purescript/exercises/largest-series-product/src/LargestSeriesProduct.purs +3 -0
  122. data/tracks/purescript/exercises/largest-series-product/test/Main.purs +73 -0
  123. data/tracks/python/exercises/sublist/sublist_test.py +94 -55
  124. data/tracks/ruby/README.md +38 -25
  125. data/tracks/ruby/exercises/hamming/example.tt +6 -4
  126. data/tracks/ruby/exercises/hamming/hamming_test.rb +4 -5
  127. data/tracks/ruby/exercises/linked-list/linked_list_test.rb +16 -0
  128. data/tracks/ruby/exercises/luhn/luhn_test.rb +5 -5
  129. data/tracks/ruby/exercises/ocr-numbers/.meta/.version +1 -0
  130. data/tracks/ruby/exercises/ocr-numbers/example.rb +42 -61
  131. data/tracks/ruby/exercises/ocr-numbers/example.tt +21 -0
  132. data/tracks/ruby/exercises/ocr-numbers/ocr_numbers_test.rb +63 -138
  133. data/tracks/ruby/lib/generator/exercise_cases.rb +43 -0
  134. data/tracks/ruby/lib/generator/underscore.rb +9 -0
  135. data/tracks/ruby/lib/hamming_cases.rb +9 -14
  136. data/tracks/ruby/lib/luhn_cases.rb +2 -18
  137. data/tracks/ruby/lib/ocr_numbers_cases.rb +20 -0
  138. data/tracks/ruby/lib/pig_latin_cases.rb +2 -12
  139. data/tracks/ruby/test/generator/underscore_test.rb +23 -0
  140. data/tracks/scala/config.json +316 -316
  141. metadata +26 -10
  142. data/tracks/cpp/exercises/etl/require_equal_containers.h +0 -88
  143. data/tracks/cpp/exercises/grade-school/require_equal_containers.h +0 -88
  144. data/tracks/cpp/exercises/nucleotide-count/require_equal_containers.h +0 -88
  145. data/tracks/cpp/exercises/series/require_equal_containers.h +0 -88
  146. data/tracks/cpp/exercises/word-count/require_equal_containers.h +0 -88
  147. data/tracks/javascript/exercises/acronym/package.json +0 -12
  148. 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
- if (minute_ > minutes_per_hour) {
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
- while (minute_ < 0) {
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*/)
@@ -20,6 +20,7 @@ public:
20
20
 
21
21
  private:
22
22
  clock(int hour, int minute);
23
+ void clean();
23
24
  int hour_;
24
25
  int minute_;
25
26
  };
@@ -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.55 REQUIRED COMPONENTS unit_test_framework date_time regex)
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 ${test_helper} ${exercise_cpp} ${file}.h)
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.55 REQUIRED COMPONENTS unit_test_framework date_time regex)
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 ${test_helper} ${exercise_cpp} ${file}.h)
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.55 REQUIRED COMPONENTS unit_test_framework date_time regex)
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 ${test_helper} ${exercise_cpp} ${file}.h)
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
- REQUIRE_EQUAL_CONTAINERS(expected, actual);
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
- REQUIRE_EQUAL_CONTAINERS(expected, actual);
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
- REQUIRE_EQUAL_CONTAINERS(expected, actual);
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
- REQUIRE_EQUAL_CONTAINERS(expected, actual);
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.55 REQUIRED COMPONENTS unit_test_framework date_time regex)
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 ${test_helper} ${exercise_cpp} ${file}.h)
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.55 REQUIRED COMPONENTS unit_test_framework date_time regex)
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 ${test_helper} ${exercise_cpp} ${file}.h)
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::gregorian::date advance(const boost::gregorian::date& start)
6
+ boost::posix_time::ptime advance(const boost::posix_time::ptime& start)
7
7
  {
8
- const unsigned long long seconds_per_minute = 60;
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/gregorian/gregorian.hpp>
4
+ #include <boost/date_time/posix_time/posix_time.hpp>
5
5
 
6
6
  namespace gigasecond
7
7
  {
8
8
 
9
- boost::gregorian::date advance(const boost::gregorian::date& start);
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/1_55_0/doc/html/date_time.html>
6
- // for documentation on boost::gregorian::date
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(boost::gregorian::date(2011, 4, 26));
12
+ const auto actual = gigasecond::advance(time_from_string("2011-04-25 00:00:00"));
11
13
 
12
- const boost::gregorian::date expected(2043, 1, 2);
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(boost::gregorian::date(1977, 6, 14));
21
+ const auto actual = gigasecond::advance(time_from_string("1977-06-13 00:00:00"));
20
22
 
21
- const boost::gregorian::date expected(2009, 2, 20);
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(boost::gregorian::date(1959, 7, 20));
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 boost::gregorian::date expected(1991, 3, 28);
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.55 REQUIRED COMPONENTS unit_test_framework date_time regex)
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 ${test_helper} ${exercise_cpp} ${file}.h)
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
- REQUIRE_EQUAL_CONTAINERS(expected, actual);
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
- REQUIRE_EQUAL_CONTAINERS(expected, actual);
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
- REQUIRE_EQUAL_CONTAINERS(expected, actual);
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
- REQUIRE_EQUAL_CONTAINERS(expected, actual);
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
- REQUIRE_EQUAL_CONTAINERS(expected, actual);
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.55 REQUIRED COMPONENTS unit_test_framework date_time regex)
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 ${test_helper} ${exercise_cpp} ${file}.h)
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.55 REQUIRED COMPONENTS unit_test_framework date_time regex)
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 ${test_helper} ${exercise_cpp} ${file}.h)
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})