trackler 2.1.0.36 → 2.1.0.37
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/common/CONTRIBUTING.md +1 -1
- data/lib/trackler/version.rb +1 -1
- data/lib/trackler.rb +0 -5
- data/tracks/c/config.json +0 -5
- data/tracks/clojure/config.json +177 -59
- data/tracks/clojure/exercises/kindergarten-garden/src/example.clj +10 -8
- data/tracks/elisp/config.json +60 -24
- data/tracks/elixir/exercises/poker/poker_test.exs +1 -1
- data/tracks/fortran/config.json +6 -0
- data/tracks/fortran/exercises/pangram/example.f90 +33 -0
- data/tracks/fortran/exercises/pangram/pangram.fun +42 -0
- data/tracks/go/config.json +10 -4
- data/tracks/go/exercises/acronym/acronym.go +1 -1
- data/tracks/groovy/{SETUP.md → docs/EXERCISE_README_INSERT.md} +0 -0
- data/tracks/haskell/config.json +1 -1
- data/tracks/java/bin/journey-test.sh +3 -0
- data/tracks/java/config.json +14 -14
- data/tracks/java/exercises/binary-search/src/test/java/BinarySearchTest.java +20 -20
- data/tracks/java/exercises/binary-search-tree/src/test/java/BSTTest.java +32 -32
- data/tracks/java/exercises/build.gradle +57 -31
- data/tracks/java/exercises/hello-world/GETTING_STARTED.md +4 -0
- data/tracks/java/exercises/pythagorean-triplet/src/test/java/PythagoreanTripletTest.java +8 -8
- data/tracks/java/exercises/scrabble-score/src/example/java/Scrabble.java +1 -1
- data/tracks/java/exercises/scrabble-score/src/test/java/ScrabbleScoreTest.java +10 -5
- data/tracks/java/exercises/series/src/test/java/SeriesTest.java +20 -20
- data/tracks/java/gradle/wrapper/gradle-wrapper.jar +0 -0
- data/tracks/java/gradle/wrapper/gradle-wrapper.properties +2 -2
- data/tracks/julia/runtests.jl +1 -6
- data/tracks/kotlin/.gitignore +0 -5
- data/tracks/kotlin/.travis.yml +21 -1
- data/tracks/kotlin/bin/build-jq.sh +11 -0
- data/tracks/kotlin/bin/fetch-configlet +1 -1
- data/tracks/kotlin/bin/journey-test.sh +34 -14
- data/tracks/kotlin/bin/unit-tests.sh +2 -2
- data/tracks/kotlin/config.json +230 -160
- data/tracks/kotlin/exercises/build.gradle +3 -0
- data/tracks/kotlin/exercises/collatz-conjecture/src/test/kotlin/CollatzCalculatorTest.kt +7 -1
- data/tracks/kotlin/exercises/gradle.properties +1 -0
- data/tracks/kotlin/exercises/list-ops/HINTS.md +5 -0
- data/tracks/kotlin/exercises/list-ops/build.gradle +28 -0
- data/tracks/kotlin/exercises/list-ops/src/example/kotlin/CustomListExtensions.kt +43 -0
- data/tracks/kotlin/exercises/list-ops/src/main/kotlin/.keep +0 -0
- data/tracks/kotlin/exercises/list-ops/src/test/kotlin/ListExtensionsTest.kt +157 -0
- data/tracks/kotlin/exercises/settings.gradle +13 -12
- data/tracks/kotlin/gradle/wrapper/gradle-wrapper.jar +0 -0
- data/tracks/kotlin/gradle/wrapper/gradle-wrapper.properties +6 -0
- data/tracks/kotlin/gradlew +172 -0
- data/tracks/kotlin/gradlew.bat +84 -0
- data/tracks/lfe/config.json +90 -30
- data/tracks/ocaml/.travis-ci.sh +1 -1
- data/tracks/ocaml/.travis.yml +1 -1
- data/tracks/ocaml/README.md +1 -1
- data/tracks/perl5/.travis.yml +3 -2
- data/tracks/perl6/bin/exercise-gen.pl6 +6 -3
- data/tracks/racket/config.json +63 -21
- data/tracks/ruby/exercises/bob/bob_test.rb +0 -1
- data/tracks/ruby/lib/generator/command_line.rb +7 -3
- data/tracks/ruby/lib/generator/exercise.rb +19 -0
- data/tracks/ruby/lib/generator/files/generator_cases.rb +0 -4
- data/tracks/ruby/lib/generator/files/metadata_files.rb +1 -1
- data/tracks/ruby/lib/generator/files/track_files.rb +3 -3
- data/tracks/ruby/lib/generator/implementation.rb +7 -11
- data/tracks/ruby/lib/generator/template_values.rb +5 -9
- data/tracks/ruby/lib/generator/underscore.rb +4 -0
- data/tracks/ruby/lib/generator.rb +2 -2
- data/tracks/ruby/test/fixtures/xruby/lib/generator/test_template.erb +3 -3
- data/tracks/ruby/test/generator/exercise_test.rb +20 -0
- data/tracks/ruby/test/generator/files/generate_cases_test.rb +0 -4
- data/tracks/ruby/test/generator/files/metadata_files_test.rb +2 -2
- data/tracks/ruby/test/generator/files/track_files_test.rb +4 -5
- data/tracks/ruby/test/generator/implementation_test.rb +12 -20
- data/tracks/ruby/test/generator/template_values_test.rb +2 -33
- data/tracks/ruby/test/generator/underscore_test.rb +4 -0
- data/tracks/ruby/test/generator_test.rb +2 -2
- data/tracks/rust/exercises/gigasecond/Cargo.lock +58 -13
- data/tracks/rust/exercises/gigasecond/Cargo.toml +1 -1
- data/tracks/scala/exercises/acronym/src/test/scala/AcronymTest.scala +32 -12
- data/tracks/scala/exercises/hamming/example.scala +1 -1
- data/tracks/scala/exercises/hamming/src/test/scala/HammingTest.scala +55 -19
- data/tracks/scala/exercises/phone-number/example.scala +10 -20
- data/tracks/scala/exercises/phone-number/src/test/scala/PhoneNumberTest.scala +28 -81
- data/tracks/scala/testgen/src/main/scala/AcronymTestGenerator.scala +16 -0
- data/tracks/scala/testgen/src/main/scala/HammingTestGenerator.scala +34 -0
- data/tracks/scala/testgen/src/main/scala/PhoneNumberTestGenerator.scala +34 -0
- data/tracks/scheme/config.json +43 -16
- metadata +21 -5
- data/lib/trackler/problem.rb +0 -7
- data/lib/trackler/problems.rb +0 -7
data/tracks/elisp/config.json
CHANGED
@@ -5,10 +5,6 @@
|
|
5
5
|
"active": true,
|
6
6
|
"deprecated": [
|
7
7
|
|
8
|
-
],
|
9
|
-
"ignored": [
|
10
|
-
"docs",
|
11
|
-
"bin"
|
12
8
|
],
|
13
9
|
"foregone": [
|
14
10
|
|
@@ -17,102 +13,142 @@
|
|
17
13
|
{
|
18
14
|
"difficulty": 1,
|
19
15
|
"slug": "hello-world",
|
20
|
-
"topics": [
|
16
|
+
"topics": [
|
17
|
+
|
18
|
+
]
|
21
19
|
},
|
22
20
|
{
|
23
21
|
"difficulty": 1,
|
24
22
|
"slug": "bob",
|
25
|
-
"topics": [
|
23
|
+
"topics": [
|
24
|
+
|
25
|
+
]
|
26
26
|
},
|
27
27
|
{
|
28
28
|
"difficulty": 1,
|
29
29
|
"slug": "difference-of-squares",
|
30
|
-
"topics": [
|
30
|
+
"topics": [
|
31
|
+
|
32
|
+
]
|
31
33
|
},
|
32
34
|
{
|
33
35
|
"difficulty": 1,
|
34
36
|
"slug": "gigasecond",
|
35
|
-
"topics": [
|
37
|
+
"topics": [
|
38
|
+
|
39
|
+
]
|
36
40
|
},
|
37
41
|
{
|
38
42
|
"difficulty": 1,
|
39
43
|
"slug": "hamming",
|
40
|
-
"topics": [
|
44
|
+
"topics": [
|
45
|
+
|
46
|
+
]
|
41
47
|
},
|
42
48
|
{
|
43
49
|
"difficulty": 1,
|
44
50
|
"slug": "anagram",
|
45
|
-
"topics": [
|
51
|
+
"topics": [
|
52
|
+
|
53
|
+
]
|
46
54
|
},
|
47
55
|
{
|
48
56
|
"difficulty": 1,
|
49
57
|
"slug": "binary",
|
50
|
-
"topics": [
|
58
|
+
"topics": [
|
59
|
+
|
60
|
+
]
|
51
61
|
},
|
52
62
|
{
|
53
63
|
"difficulty": 1,
|
54
64
|
"slug": "leap",
|
55
|
-
"topics": [
|
65
|
+
"topics": [
|
66
|
+
|
67
|
+
]
|
56
68
|
},
|
57
69
|
{
|
58
70
|
"difficulty": 1,
|
59
71
|
"slug": "allergies",
|
60
|
-
"topics": [
|
72
|
+
"topics": [
|
73
|
+
|
74
|
+
]
|
61
75
|
},
|
62
76
|
{
|
63
77
|
"difficulty": 1,
|
64
78
|
"slug": "robot-name",
|
65
|
-
"topics": [
|
79
|
+
"topics": [
|
80
|
+
|
81
|
+
]
|
66
82
|
},
|
67
83
|
{
|
68
84
|
"difficulty": 1,
|
69
85
|
"slug": "rna-transcription",
|
70
|
-
"topics": [
|
86
|
+
"topics": [
|
87
|
+
|
88
|
+
]
|
71
89
|
},
|
72
90
|
{
|
73
91
|
"difficulty": 1,
|
74
92
|
"slug": "atbash-cipher",
|
75
|
-
"topics": [
|
93
|
+
"topics": [
|
94
|
+
|
95
|
+
]
|
76
96
|
},
|
77
97
|
{
|
78
98
|
"difficulty": 1,
|
79
99
|
"slug": "raindrops",
|
80
|
-
"topics": [
|
100
|
+
"topics": [
|
101
|
+
|
102
|
+
]
|
81
103
|
},
|
82
104
|
{
|
83
105
|
"difficulty": 1,
|
84
106
|
"slug": "roman-numerals",
|
85
|
-
"topics": [
|
107
|
+
"topics": [
|
108
|
+
|
109
|
+
]
|
86
110
|
},
|
87
111
|
{
|
88
112
|
"difficulty": 1,
|
89
113
|
"slug": "perfect-numbers",
|
90
|
-
"topics": [
|
114
|
+
"topics": [
|
115
|
+
|
116
|
+
]
|
91
117
|
},
|
92
118
|
{
|
93
119
|
"difficulty": 1,
|
94
120
|
"slug": "etl",
|
95
|
-
"topics": [
|
121
|
+
"topics": [
|
122
|
+
|
123
|
+
]
|
96
124
|
},
|
97
125
|
{
|
98
126
|
"difficulty": 1,
|
99
127
|
"slug": "word-count",
|
100
|
-
"topics": [
|
128
|
+
"topics": [
|
129
|
+
|
130
|
+
]
|
101
131
|
},
|
102
132
|
{
|
103
133
|
"difficulty": 1,
|
104
134
|
"slug": "nucleotide-count",
|
105
|
-
"topics": [
|
135
|
+
"topics": [
|
136
|
+
|
137
|
+
]
|
106
138
|
},
|
107
139
|
{
|
108
140
|
"difficulty": 1,
|
109
141
|
"slug": "phone-number",
|
110
|
-
"topics": [
|
142
|
+
"topics": [
|
143
|
+
|
144
|
+
]
|
111
145
|
},
|
112
146
|
{
|
113
147
|
"slug": "grains",
|
114
148
|
"difficulty": 1,
|
115
|
-
"topics": [
|
149
|
+
"topics": [
|
150
|
+
|
151
|
+
]
|
116
152
|
}
|
117
153
|
]
|
118
154
|
}
|
@@ -142,7 +142,7 @@ defmodule PokerTest do
|
|
142
142
|
end
|
143
143
|
|
144
144
|
@tag :pending
|
145
|
-
test "
|
145
|
+
test "flush beats a straight" do
|
146
146
|
straight_to_8 = ~w(4C 6H 7D 8D 5H)
|
147
147
|
flush_to_7 = ~w(2S 4S 5S 6S 7S)
|
148
148
|
assert Poker.best_hand([straight_to_8, flush_to_7]) == [flush_to_7]
|
data/tracks/fortran/config.json
CHANGED
@@ -0,0 +1,33 @@
|
|
1
|
+
module pangram
|
2
|
+
contains
|
3
|
+
logical function is_pangram(sentance)
|
4
|
+
implicit none
|
5
|
+
character(*) :: sentance
|
6
|
+
logical :: seen(26)
|
7
|
+
integer :: i,val
|
8
|
+
|
9
|
+
seen = .false.
|
10
|
+
|
11
|
+
do i = 1,len(sentance)
|
12
|
+
val = to_index(sentance(i:i))
|
13
|
+
if ( val .ne. 0 ) then
|
14
|
+
seen(val:val) = .true.
|
15
|
+
end if
|
16
|
+
end do
|
17
|
+
|
18
|
+
is_pangram = all(seen)
|
19
|
+
end function is_pangram
|
20
|
+
|
21
|
+
integer function to_index(chr)
|
22
|
+
implicit none
|
23
|
+
character :: chr
|
24
|
+
|
25
|
+
if ((chr .ge. 'a' ) .and. (chr .le. 'z')) then
|
26
|
+
to_index = ichar('z') - ichar(chr) + 1
|
27
|
+
else if ((chr .ge. 'A' ) .and. (chr .le. 'Z')) then
|
28
|
+
to_index = ichar('Z') - ichar(chr) + 1
|
29
|
+
else
|
30
|
+
to_index = 0
|
31
|
+
end if
|
32
|
+
end function to_index
|
33
|
+
end module pangram
|
@@ -0,0 +1,42 @@
|
|
1
|
+
test_suite pangram
|
2
|
+
|
3
|
+
setup
|
4
|
+
end setup
|
5
|
+
|
6
|
+
test sentance_empty
|
7
|
+
assert_false( is_pangram('') )
|
8
|
+
end test
|
9
|
+
|
10
|
+
Xtest pangram_with_only_lower_case
|
11
|
+
assert_true( is_pangram('the quick brown fox jumps over the lazy dog') )
|
12
|
+
end test
|
13
|
+
|
14
|
+
Xtest missing_character_x
|
15
|
+
assert_false( is_pangram('a quick movement of the enemy will jeopordize five gunboats') )
|
16
|
+
end test
|
17
|
+
|
18
|
+
Xtest missing_another_character_x
|
19
|
+
assert_false( is_pangram('the quick brown fish jumps over the lazy dog') )
|
20
|
+
end test
|
21
|
+
|
22
|
+
Xtest panagram_with_underscores
|
23
|
+
assert_true( is_pangram('the_quick_brown_fox_jumps_over_the_lazy_dog') )
|
24
|
+
end test
|
25
|
+
|
26
|
+
Xtest panagram_with_numbers
|
27
|
+
assert_true( is_pangram('the 1 quick brown fox jumps over the 2 lazy dogs') )
|
28
|
+
end test
|
29
|
+
|
30
|
+
Xtest pangram_missing_letters_replaced_by_numbers
|
31
|
+
assert_false( is_pangram('7h3 qu1ck brown fox jumps ov3r 7h3 lazy dog') )
|
32
|
+
end test
|
33
|
+
|
34
|
+
Xtest pangram_with_mixed_case_and_punctuation
|
35
|
+
assert_true( is_pangram('""Five quacking Zephyrs jolt my wax bed.""') )
|
36
|
+
end test
|
37
|
+
|
38
|
+
Xtest upper_and_lower_case_versions_of_the_same_character
|
39
|
+
assert_false( is_pangram('the quick brown fox jumped over the lazy FOX') )
|
40
|
+
end test
|
41
|
+
|
42
|
+
end test_suite
|
data/tracks/go/config.json
CHANGED
@@ -229,14 +229,20 @@
|
|
229
229
|
]
|
230
230
|
},
|
231
231
|
{
|
232
|
-
"difficulty":
|
232
|
+
"difficulty": 5,
|
233
233
|
"slug": "pythagorean-triplet",
|
234
|
-
"topics": [
|
234
|
+
"topics": [
|
235
|
+
"Algorithms",
|
236
|
+
"Mathematics"
|
237
|
+
]
|
235
238
|
},
|
236
239
|
{
|
237
|
-
"difficulty":
|
240
|
+
"difficulty": 3,
|
238
241
|
"slug": "isogram",
|
239
|
-
"topics": [
|
242
|
+
"topics": [
|
243
|
+
"Strings",
|
244
|
+
"Sequences"
|
245
|
+
]
|
240
246
|
},
|
241
247
|
{
|
242
248
|
"difficulty": 1,
|
File without changes
|
data/tracks/haskell/config.json
CHANGED
@@ -236,6 +236,9 @@ solve_all_exercises() {
|
|
236
236
|
"$EXECPATH"/gradlew compileTestJava
|
237
237
|
# Ensure we run all the tests (as delivered, all but the first is @Ignore'd)
|
238
238
|
for testfile in `find . -name "*Test.${TRACK_SRC_EXT}"`; do
|
239
|
+
# Strip @Ignore annotations to ensure we run the tests (as delivered, all but the first is @Ignore'd).
|
240
|
+
# Note that unit-test.sh also strips @Ignore annotations via the Gradle task copyTestsFilteringIgnores.
|
241
|
+
# The stripping implementations here and in copyTestsFilteringIgnores should be kept consistent.
|
239
242
|
sed 's/@Ignore\(\(.*\)\)\{0,1\}//' ${testfile} > "${tempfile}" && mv "${tempfile}" "${testfile}"
|
240
243
|
done
|
241
244
|
"$EXECPATH"/gradlew test
|
data/tracks/java/config.json
CHANGED
@@ -137,6 +137,13 @@
|
|
137
137
|
|
138
138
|
]
|
139
139
|
},
|
140
|
+
{
|
141
|
+
"slug": "kindergarten-garden",
|
142
|
+
"difficulty": 4,
|
143
|
+
"topics": [
|
144
|
+
|
145
|
+
]
|
146
|
+
},
|
140
147
|
{
|
141
148
|
"slug": "collatz-conjecture",
|
142
149
|
"difficulty": 4,
|
@@ -207,6 +214,13 @@
|
|
207
214
|
|
208
215
|
]
|
209
216
|
},
|
217
|
+
{
|
218
|
+
"slug": "run-length-encoding",
|
219
|
+
"difficulty": 5,
|
220
|
+
"topics": [
|
221
|
+
|
222
|
+
]
|
223
|
+
},
|
210
224
|
{
|
211
225
|
"slug": "robot-name",
|
212
226
|
"difficulty": 5,
|
@@ -457,20 +471,6 @@
|
|
457
471
|
"difficulty": 1,
|
458
472
|
"topics": [
|
459
473
|
|
460
|
-
]
|
461
|
-
},
|
462
|
-
{
|
463
|
-
"slug": "run-length-encoding",
|
464
|
-
"difficulty": 1,
|
465
|
-
"topics": [
|
466
|
-
|
467
|
-
]
|
468
|
-
},
|
469
|
-
{
|
470
|
-
"slug": "kindergarten-garden",
|
471
|
-
"difficulty": 1,
|
472
|
-
"topics": [
|
473
|
-
|
474
474
|
]
|
475
475
|
}
|
476
476
|
],
|
@@ -15,9 +15,9 @@ public class BinarySearchTest {
|
|
15
15
|
public void findsAValueInAnArrayWithOneElement() {
|
16
16
|
List<Integer> listOfUnitLength = Collections.singletonList(6);
|
17
17
|
|
18
|
-
BinarySearch<Integer>
|
18
|
+
BinarySearch<Integer> search = new BinarySearch<>(listOfUnitLength);
|
19
19
|
|
20
|
-
assertEquals(0,
|
20
|
+
assertEquals(0, search.indexOf(6));
|
21
21
|
}
|
22
22
|
|
23
23
|
@Ignore("Remove to run test")
|
@@ -27,9 +27,9 @@ public class BinarySearchTest {
|
|
27
27
|
Arrays.asList(1, 3, 4, 6, 8, 9, 11)
|
28
28
|
);
|
29
29
|
|
30
|
-
BinarySearch<Integer>
|
30
|
+
BinarySearch<Integer> search = new BinarySearch<>(sortedList);
|
31
31
|
|
32
|
-
assertEquals(3,
|
32
|
+
assertEquals(3, search.indexOf(6));
|
33
33
|
}
|
34
34
|
|
35
35
|
@Ignore("Remove to run test")
|
@@ -39,9 +39,9 @@ public class BinarySearchTest {
|
|
39
39
|
Arrays.asList(1, 3, 4, 6, 8, 9, 11)
|
40
40
|
);
|
41
41
|
|
42
|
-
BinarySearch<Integer>
|
42
|
+
BinarySearch<Integer> search = new BinarySearch<>(sortedList);
|
43
43
|
|
44
|
-
assertEquals(0,
|
44
|
+
assertEquals(0, search.indexOf(1));
|
45
45
|
}
|
46
46
|
|
47
47
|
@Ignore("Remove to run test")
|
@@ -51,9 +51,9 @@ public class BinarySearchTest {
|
|
51
51
|
Arrays.asList(1, 3, 4, 6, 8, 9, 11)
|
52
52
|
);
|
53
53
|
|
54
|
-
BinarySearch<Integer>
|
54
|
+
BinarySearch<Integer> search = new BinarySearch<>(sortedList);
|
55
55
|
|
56
|
-
assertEquals(6,
|
56
|
+
assertEquals(6, search.indexOf(11));
|
57
57
|
}
|
58
58
|
|
59
59
|
@Ignore("Remove to run test")
|
@@ -63,9 +63,9 @@ public class BinarySearchTest {
|
|
63
63
|
Arrays.asList(1, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 634)
|
64
64
|
);
|
65
65
|
|
66
|
-
BinarySearch<Integer>
|
66
|
+
BinarySearch<Integer> search = new BinarySearch<>(sortedListOfOddLength);
|
67
67
|
|
68
|
-
assertEquals(9,
|
68
|
+
assertEquals(9, search.indexOf(144));
|
69
69
|
}
|
70
70
|
|
71
71
|
@Ignore("Remove to run test")
|
@@ -75,9 +75,9 @@ public class BinarySearchTest {
|
|
75
75
|
Arrays.asList(1, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377)
|
76
76
|
);
|
77
77
|
|
78
|
-
BinarySearch<Integer>
|
78
|
+
BinarySearch<Integer> search = new BinarySearch<>(sortedListOfEvenLength);
|
79
79
|
|
80
|
-
assertEquals(5,
|
80
|
+
assertEquals(5, search.indexOf(21));
|
81
81
|
}
|
82
82
|
|
83
83
|
@Ignore("Remove to run test")
|
@@ -87,9 +87,9 @@ public class BinarySearchTest {
|
|
87
87
|
Arrays.asList(1, 3, 4, 6, 8, 9, 11)
|
88
88
|
);
|
89
89
|
|
90
|
-
BinarySearch<Integer>
|
90
|
+
BinarySearch<Integer> search = new BinarySearch<>(sortedList);
|
91
91
|
|
92
|
-
assertEquals(-1,
|
92
|
+
assertEquals(-1, search.indexOf(7));
|
93
93
|
}
|
94
94
|
|
95
95
|
@Ignore("Remove to run test")
|
@@ -99,9 +99,9 @@ public class BinarySearchTest {
|
|
99
99
|
Arrays.asList(1, 3, 4, 6, 8, 9, 11)
|
100
100
|
);
|
101
101
|
|
102
|
-
BinarySearch<Integer>
|
102
|
+
BinarySearch<Integer> search = new BinarySearch<>(sortedList);
|
103
103
|
|
104
|
-
assertEquals(-1,
|
104
|
+
assertEquals(-1, search.indexOf(0));
|
105
105
|
}
|
106
106
|
|
107
107
|
@Ignore("Remove to run test")
|
@@ -111,9 +111,9 @@ public class BinarySearchTest {
|
|
111
111
|
Arrays.asList(1, 3, 4, 6, 8, 9, 11)
|
112
112
|
);
|
113
113
|
|
114
|
-
BinarySearch<Integer>
|
114
|
+
BinarySearch<Integer> search = new BinarySearch<>(sortedList);
|
115
115
|
|
116
|
-
assertEquals(-1,
|
116
|
+
assertEquals(-1, search.indexOf(13));
|
117
117
|
}
|
118
118
|
|
119
119
|
@Ignore("Remove to run test")
|
@@ -121,8 +121,8 @@ public class BinarySearchTest {
|
|
121
121
|
public void nothingIsIncludedInAnEmptyArray() {
|
122
122
|
List<Integer> emptyList = Collections.emptyList();
|
123
123
|
|
124
|
-
BinarySearch<Integer>
|
124
|
+
BinarySearch<Integer> search = new BinarySearch<>(emptyList);
|
125
125
|
|
126
|
-
assertEquals(-1,
|
126
|
+
assertEquals(-1, search.indexOf(1));
|
127
127
|
}
|
128
128
|
}
|
@@ -11,10 +11,10 @@ public class BSTTest {
|
|
11
11
|
|
12
12
|
@Test
|
13
13
|
public void dataIsRetained() {
|
14
|
-
BST<Integer>
|
14
|
+
BST<Integer> bst = new BST();
|
15
15
|
final int actual = 4;
|
16
|
-
|
17
|
-
final BST.Node<Integer> root =
|
16
|
+
bst.insert(actual);
|
17
|
+
final BST.Node<Integer> root = bst.getRoot();
|
18
18
|
assertNotNull(root);
|
19
19
|
final int expected = root.getData();
|
20
20
|
assertEquals(expected, actual);
|
@@ -23,14 +23,14 @@ public class BSTTest {
|
|
23
23
|
@Test
|
24
24
|
@Ignore("Remove to run test")
|
25
25
|
public void insertsLess() {
|
26
|
-
BST<Integer>
|
26
|
+
BST<Integer> bst = new BST();
|
27
27
|
final int expectedRoot = 4;
|
28
28
|
final int expectedLeft = 2;
|
29
29
|
|
30
|
-
|
31
|
-
|
30
|
+
bst.insert(expectedRoot);
|
31
|
+
bst.insert(expectedLeft);
|
32
32
|
|
33
|
-
final BST.Node<Integer> root =
|
33
|
+
final BST.Node<Integer> root = bst.getRoot();
|
34
34
|
assertNotNull(root);
|
35
35
|
final BST.Node<Integer> left = root.getLeft();
|
36
36
|
assertNotNull(left);
|
@@ -44,14 +44,14 @@ public class BSTTest {
|
|
44
44
|
@Test
|
45
45
|
@Ignore("Remove to run test")
|
46
46
|
public void insertsSame() {
|
47
|
-
BST<Integer>
|
47
|
+
BST<Integer> bst = new BST();
|
48
48
|
final int expectedRoot = 4;
|
49
49
|
final int expectedLeft = 4;
|
50
50
|
|
51
|
-
|
52
|
-
|
51
|
+
bst.insert(expectedRoot);
|
52
|
+
bst.insert(expectedLeft);
|
53
53
|
|
54
|
-
final BST.Node<Integer> root =
|
54
|
+
final BST.Node<Integer> root = bst.getRoot();
|
55
55
|
assertNotNull(root);
|
56
56
|
final BST.Node<Integer> left = root.getLeft();
|
57
57
|
assertNotNull(left);
|
@@ -65,14 +65,14 @@ public class BSTTest {
|
|
65
65
|
@Test
|
66
66
|
@Ignore("Remove to run test")
|
67
67
|
public void insertsRight() {
|
68
|
-
BST<Integer>
|
68
|
+
BST<Integer> bst = new BST();
|
69
69
|
final int expectedRoot = 4;
|
70
70
|
final int expectedRight = 5;
|
71
71
|
|
72
|
-
|
73
|
-
|
72
|
+
bst.insert(expectedRoot);
|
73
|
+
bst.insert(expectedRight);
|
74
74
|
|
75
|
-
final BST.Node<Integer> root =
|
75
|
+
final BST.Node<Integer> root = bst.getRoot();
|
76
76
|
assertNotNull(root);
|
77
77
|
final BST.Node<Integer> right = root.getRight();
|
78
78
|
assertNotNull(right);
|
@@ -86,7 +86,7 @@ public class BSTTest {
|
|
86
86
|
@Test
|
87
87
|
@Ignore("Remove to run test")
|
88
88
|
public void createsComplexTree() {
|
89
|
-
BST<Integer>
|
89
|
+
BST<Integer> bst = new BST<>();
|
90
90
|
List<Integer> expected = Collections.unmodifiableList(
|
91
91
|
Arrays.asList(4, 2, 6, 1, 3, 5, 7)
|
92
92
|
);
|
@@ -94,60 +94,60 @@ public class BSTTest {
|
|
94
94
|
List<Integer> treeData = Collections.unmodifiableList(
|
95
95
|
Arrays.asList(4, 2, 6, 1, 3, 7, 5)
|
96
96
|
);
|
97
|
-
treeData.forEach(
|
97
|
+
treeData.forEach(bst::insert);
|
98
98
|
|
99
|
-
List<Integer> actual =
|
99
|
+
List<Integer> actual = bst.getAsLevelOrderList();
|
100
100
|
assertEquals(expected, actual);
|
101
101
|
}
|
102
102
|
|
103
103
|
@Test
|
104
104
|
@Ignore("Remove to run test")
|
105
105
|
public void sortsSingleElement() {
|
106
|
-
BST<Integer>
|
106
|
+
BST<Integer> bst = new BST<>();
|
107
107
|
List<Integer> expected = Collections.unmodifiableList(
|
108
108
|
Collections.singletonList(4)
|
109
109
|
);
|
110
110
|
|
111
|
-
|
111
|
+
bst.insert(4);
|
112
112
|
|
113
|
-
List<Integer> actual =
|
113
|
+
List<Integer> actual = bst.getAsSortedList();
|
114
114
|
assertEquals(expected, actual);
|
115
115
|
}
|
116
116
|
|
117
117
|
@Test
|
118
118
|
@Ignore("Remove to run test")
|
119
119
|
public void sortsCollectionOfTwoIfSecondInsertedIsSmallerThanFirst() {
|
120
|
-
BST<Integer>
|
120
|
+
BST<Integer> bst = new BST<>();
|
121
121
|
List<Integer> expected = Collections.unmodifiableList(
|
122
122
|
Arrays.asList(2, 4)
|
123
123
|
);
|
124
124
|
|
125
|
-
|
126
|
-
|
125
|
+
bst.insert(4);
|
126
|
+
bst.insert(2);
|
127
127
|
|
128
|
-
List<Integer> actual =
|
128
|
+
List<Integer> actual = bst.getAsSortedList();
|
129
129
|
assertEquals(expected, actual);
|
130
130
|
}
|
131
131
|
|
132
132
|
@Test
|
133
133
|
@Ignore("Remove to run test")
|
134
134
|
public void sortsCollectionOfTwoIfSecondInsertedIsBiggerThanFirst() {
|
135
|
-
BST<Integer>
|
135
|
+
BST<Integer> bst = new BST<>();
|
136
136
|
List<Integer> expected = Collections.unmodifiableList(
|
137
137
|
Arrays.asList(4, 5)
|
138
138
|
);
|
139
139
|
|
140
|
-
|
141
|
-
|
140
|
+
bst.insert(4);
|
141
|
+
bst.insert(5);
|
142
142
|
|
143
|
-
List<Integer> actual =
|
143
|
+
List<Integer> actual = bst.getAsSortedList();
|
144
144
|
assertEquals(expected, actual);
|
145
145
|
}
|
146
146
|
|
147
147
|
@Test
|
148
148
|
@Ignore("Remove to run test")
|
149
149
|
public void iteratesOverComplexTree() {
|
150
|
-
BST<Integer>
|
150
|
+
BST<Integer> bst = new BST<>();
|
151
151
|
List<Integer> expected = Collections.unmodifiableList(
|
152
152
|
Arrays.asList(1, 2, 3, 4, 5, 6, 7)
|
153
153
|
);
|
@@ -155,9 +155,9 @@ public class BSTTest {
|
|
155
155
|
List<Integer> treeData = Collections.unmodifiableList(
|
156
156
|
Arrays.asList(4, 2, 1, 3, 6, 7, 5)
|
157
157
|
);
|
158
|
-
treeData.forEach(
|
158
|
+
treeData.forEach(bst::insert);
|
159
159
|
|
160
|
-
List<Integer> actual =
|
160
|
+
List<Integer> actual = bst.getAsSortedList();
|
161
161
|
assertEquals(expected, actual);
|
162
162
|
}
|
163
163
|
}
|