trackler 2.2.1.106 → 2.2.1.107
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/trackler/version.rb +1 -1
- data/tracks/delphi/exercises/bowling/uBowlingExample.pas +31 -4
- data/tracks/delphi/exercises/bowling/uBowlingTests.pas +81 -5
- data/tracks/elm/config/exercise_readme.go.tmpl +29 -4
- data/tracks/elm/exercises/accumulate/README.md +0 -3
- data/tracks/elm/exercises/all-your-base/README.md +0 -1
- data/tracks/elm/exercises/allergies/README.md +0 -1
- data/tracks/elm/exercises/atbash-cipher/README.md +2 -1
- data/tracks/elm/exercises/etl/README.md +3 -1
- data/tracks/elm/exercises/grade-school/README.md +0 -1
- data/tracks/elm/exercises/grains/README.md +0 -1
- data/tracks/elm/exercises/leap/README.md +1 -1
- data/tracks/elm/exercises/list-ops/README.md +0 -1
- data/tracks/elm/exercises/nucleotide-count/README.md +8 -22
- data/tracks/elm/exercises/pangram/README.md +1 -1
- data/tracks/elm/exercises/pascals-triangle/README.md +1 -1
- data/tracks/elm/exercises/phone-number/README.md +4 -3
- data/tracks/elm/exercises/rna-transcription/README.md +2 -2
- data/tracks/elm/exercises/roman-numerals/README.md +1 -1
- data/tracks/elm/exercises/run-length-encoding/README.md +4 -4
- data/tracks/elm/exercises/scrabble-score/README.md +3 -1
- data/tracks/elm/exercises/space-age/README.md +1 -1
- data/tracks/elm/exercises/sublist/README.md +0 -1
- data/tracks/elm/exercises/sum-of-multiples/README.md +3 -6
- data/tracks/elm/exercises/triangle/README.md +9 -6
- data/tracks/elm/exercises/word-count/README.md +1 -2
- data/tracks/go/config.json +12 -0
- data/tracks/go/exercises/forth/.meta/gen.go +5 -3
- data/tracks/go/exercises/forth/cases_test.go +2 -2
- data/tracks/go/exercises/grains/.meta/gen.go +10 -8
- data/tracks/go/exercises/grains/cases_test.go +2 -2
- data/tracks/go/exercises/isogram/.meta/gen.go +5 -3
- data/tracks/go/exercises/isogram/cases_test.go +2 -2
- data/tracks/go/exercises/proverb/.meta/gen.go +51 -0
- data/tracks/go/exercises/proverb/README.md +41 -0
- data/tracks/go/exercises/proverb/cases_test.go +44 -0
- data/tracks/go/exercises/proverb/example.go +19 -0
- data/tracks/go/exercises/proverb/proverb.go +15 -0
- data/tracks/go/exercises/proverb/proverb_test.go +23 -0
- data/tracks/julia/exercises/isbn-verifier/example.jl +2 -0
- data/tracks/julia/exercises/isbn-verifier/runtests.jl +4 -4
- data/tracks/rust/exercises/two-bucket/README.md +1 -1
- data/tracks/scala/exercises/bracket-push/src/test/scala/BracketPushTest.scala +17 -15
- data/tracks/scala/exercises/change/src/test/scala/ChangeTest.scala +2 -2
- data/tracks/scala/exercises/collatz-conjecture/src/test/scala/CollatzConjectureTest.scala +2 -2
- data/tracks/scala/exercises/connect/src/test/scala/ConnectTest.scala +1 -1
- data/tracks/scala/exercises/crypto-square/src/test/scala/CryptoSquareTest.scala +20 -41
- data/tracks/scala/exercises/custom-set/src/test/scala/CustomSetTest.scala +58 -40
- data/tracks/scala/exercises/difference-of-squares/src/test/scala/DifferenceOfSquaresTest.scala +1 -1
- data/tracks/scala/testgen/src/main/scala/BracketPushTestGenerator.scala +1 -1
- data/tracks/scala/testgen/src/main/scala/ChangeTestGenerator.scala +3 -3
- data/tracks/scala/testgen/src/main/scala/CollatzConjectureTestGenerator.scala +3 -3
- data/tracks/scala/testgen/src/main/scala/ConnectTestGenerator.scala +6 -6
- data/tracks/scala/testgen/src/main/scala/CryptoSquareTestGenerator.scala +1 -1
- data/tracks/scala/testgen/src/main/scala/CustomSetTestGenerator.scala +32 -26
- data/tracks/scala/testgen/src/main/scala/DifferenceOfSquaresTestGenerator.scala +1 -1
- metadata +8 -3
- data/tracks/elm/docs/EXERCISE_README_INSERT.md +0 -28
@@ -0,0 +1,19 @@
|
|
1
|
+
// Package proverb deals with outputting the lines of a rhyme.
|
2
|
+
package proverb
|
3
|
+
|
4
|
+
import "fmt"
|
5
|
+
|
6
|
+
// Proverb outputs the lines of for want of a nail
|
7
|
+
func Proverb(rhyme []string) []string {
|
8
|
+
if len(rhyme) == 0 {
|
9
|
+
return []string{}
|
10
|
+
}
|
11
|
+
var r []string
|
12
|
+
if len(rhyme) > 1 {
|
13
|
+
for i := 0; i < len(rhyme)-1; i++ {
|
14
|
+
r = append(r, fmt.Sprintf("For want of a %s the %s was lost.", rhyme[i], rhyme[i+1]))
|
15
|
+
}
|
16
|
+
}
|
17
|
+
r = append(r, fmt.Sprintf("And all for the want of a %s.", rhyme[0]))
|
18
|
+
return r
|
19
|
+
}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
// This is a "stub" file. It's a little start on your solution.
|
2
|
+
// It's not a complete solution though; you have to write some code.
|
3
|
+
|
4
|
+
// Package proverb should have a package comment that summarizes what it's about.
|
5
|
+
// https://golang.org/doc/effective_go.html#commentary
|
6
|
+
package proverb
|
7
|
+
|
8
|
+
// Proverb should have a comment documenting it.
|
9
|
+
func Proverb(rhyme []string) []string {
|
10
|
+
// Write some code here to pass the test suite.
|
11
|
+
// Then remove all the stock comments.
|
12
|
+
// They're here to help you get started but they only clutter a finished solution.
|
13
|
+
// If you leave them in, reviewers may protest!
|
14
|
+
return []string{}
|
15
|
+
}
|
@@ -0,0 +1,23 @@
|
|
1
|
+
package proverb
|
2
|
+
|
3
|
+
import (
|
4
|
+
"fmt"
|
5
|
+
"testing"
|
6
|
+
)
|
7
|
+
|
8
|
+
func TestProverb(t *testing.T) {
|
9
|
+
for _, test := range stringTestCases {
|
10
|
+
actual := Proverb(test.input)
|
11
|
+
if fmt.Sprintf("%q", actual) != fmt.Sprintf("%q", test.expected) {
|
12
|
+
t.Fatalf("Proverb test [%s], expected [%s], actual [%s]", test.input, test.expected, actual)
|
13
|
+
}
|
14
|
+
}
|
15
|
+
}
|
16
|
+
|
17
|
+
func BenchmarkProverb(b *testing.B) {
|
18
|
+
for i := 0; i < b.N; i++ {
|
19
|
+
for _, test := range stringTestCases {
|
20
|
+
Proverb(test.input)
|
21
|
+
}
|
22
|
+
}
|
23
|
+
}
|
@@ -40,13 +40,13 @@ end
|
|
40
40
|
|
41
41
|
@testset "constructing valid ISBN numbers" begin
|
42
42
|
# ISBN number
|
43
|
-
@test isbn"3-598-21508-8"
|
43
|
+
@test string(isbn"3-598-21508-8") == "3598215088"
|
44
44
|
# ISBN number with a check digit of 10
|
45
|
-
@test isbn"3-598-21507-X"
|
45
|
+
@test string(isbn"3-598-21507-X") == "359821507X"
|
46
46
|
# ISBN without separating dashes
|
47
|
-
@test isbn"3598215088"
|
47
|
+
@test string(isbn"3598215088") == "3598215088"
|
48
48
|
# ISBN without separating dashes and X as check digit
|
49
|
-
@test isbn"359821507X"
|
49
|
+
@test string(isbn"359821507X") == "359821507X"
|
50
50
|
end
|
51
51
|
|
52
52
|
@testset "constructing invalid ISBN numbers" begin
|
@@ -27,7 +27,7 @@ To conclude, the only valid moves are:
|
|
27
27
|
- emptying one bucket and doing nothing to the other
|
28
28
|
- filling one bucket and doing nothing to the other
|
29
29
|
|
30
|
-
Written with <3 at [Fullstack Academy](http://www.fullstackacademy.com/) by
|
30
|
+
Written with <3 at [Fullstack Academy](http://www.fullstackacademy.com/) by Lindsay Levine.
|
31
31
|
|
32
32
|
## Rust Installation
|
33
33
|
|
@@ -1,74 +1,76 @@
|
|
1
1
|
import org.scalatest.{Matchers, FunSuite}
|
2
2
|
|
3
|
-
/** @version 1.
|
3
|
+
/** @version 1.2.0 */
|
4
4
|
class BracketPushTest extends FunSuite with Matchers {
|
5
5
|
|
6
6
|
test("paired square brackets") {
|
7
|
-
BracketPush.isPaired("[]") should be
|
7
|
+
BracketPush.isPaired("[]") should be(true)
|
8
8
|
}
|
9
9
|
|
10
10
|
test("empty string") {
|
11
11
|
pending
|
12
|
-
BracketPush.isPaired("") should be
|
12
|
+
BracketPush.isPaired("") should be(true)
|
13
13
|
}
|
14
14
|
|
15
15
|
test("unpaired brackets") {
|
16
16
|
pending
|
17
|
-
BracketPush.isPaired("[[") should be
|
17
|
+
BracketPush.isPaired("[[") should be(false)
|
18
18
|
}
|
19
19
|
|
20
20
|
test("wrong ordered brackets") {
|
21
21
|
pending
|
22
|
-
BracketPush.isPaired("}{") should be
|
22
|
+
BracketPush.isPaired("}{") should be(false)
|
23
23
|
}
|
24
24
|
|
25
25
|
test("wrong closing bracket") {
|
26
26
|
pending
|
27
|
-
BracketPush.isPaired("{]") should be
|
27
|
+
BracketPush.isPaired("{]") should be(false)
|
28
28
|
}
|
29
29
|
|
30
30
|
test("paired with whitespace") {
|
31
31
|
pending
|
32
|
-
BracketPush.isPaired("{ }") should be
|
32
|
+
BracketPush.isPaired("{ }") should be(true)
|
33
33
|
}
|
34
34
|
|
35
35
|
test("simple nested brackets") {
|
36
36
|
pending
|
37
|
-
BracketPush.isPaired("{[]}") should be
|
37
|
+
BracketPush.isPaired("{[]}") should be(true)
|
38
38
|
}
|
39
39
|
|
40
40
|
test("several paired brackets") {
|
41
41
|
pending
|
42
|
-
BracketPush.isPaired("{}[]") should be
|
42
|
+
BracketPush.isPaired("{}[]") should be(true)
|
43
43
|
}
|
44
44
|
|
45
45
|
test("paired and nested brackets") {
|
46
46
|
pending
|
47
|
-
BracketPush.isPaired("([{}({}[])])") should be
|
47
|
+
BracketPush.isPaired("([{}({}[])])") should be(true)
|
48
48
|
}
|
49
49
|
|
50
50
|
test("unopened closing brackets") {
|
51
51
|
pending
|
52
|
-
BracketPush.isPaired("{[)][]}") should be
|
52
|
+
BracketPush.isPaired("{[)][]}") should be(false)
|
53
53
|
}
|
54
54
|
|
55
55
|
test("unpaired and nested brackets") {
|
56
56
|
pending
|
57
|
-
BracketPush.isPaired("([{])") should be
|
57
|
+
BracketPush.isPaired("([{])") should be(false)
|
58
58
|
}
|
59
59
|
|
60
60
|
test("paired and wrong nested brackets") {
|
61
61
|
pending
|
62
|
-
BracketPush.isPaired("[({]})") should be
|
62
|
+
BracketPush.isPaired("[({]})") should be(false)
|
63
63
|
}
|
64
64
|
|
65
65
|
test("math expression") {
|
66
66
|
pending
|
67
|
-
BracketPush.isPaired("(((185 + 223.85) * 15) - 543)/2") should be
|
67
|
+
BracketPush.isPaired("(((185 + 223.85) * 15) - 543)/2") should be(true)
|
68
68
|
}
|
69
69
|
|
70
70
|
test("complex latex expression") {
|
71
71
|
pending
|
72
|
-
BracketPush.isPaired(
|
72
|
+
BracketPush.isPaired(
|
73
|
+
"\\left(\\begin{array}{cc} \\frac{1}{3} & x\\ \\mathrm{e}^{x} &... x^2 \\end{array}\\right)") should be(
|
74
|
+
true)
|
73
75
|
}
|
74
76
|
}
|
@@ -1,8 +1,8 @@
|
|
1
1
|
import org.scalatest.{Matchers, FunSuite}
|
2
2
|
|
3
|
-
/** @version 1.
|
3
|
+
/** @version 1.2.0 */
|
4
4
|
class ChangeTest extends FunSuite with Matchers {
|
5
|
-
|
5
|
+
|
6
6
|
test("single coin change") {
|
7
7
|
Change.findFewestCoins(25, List(1, 5, 10, 25, 100)) should be (Some(List(25)))
|
8
8
|
}
|
@@ -1,64 +1,43 @@
|
|
1
1
|
import org.scalatest.{Matchers, FunSuite}
|
2
2
|
|
3
|
-
/** @version 2.0
|
3
|
+
/** @version 3.2.0 */
|
4
4
|
class CryptoSquareTest extends FunSuite with Matchers {
|
5
5
|
|
6
|
-
test("
|
7
|
-
CryptoSquare.
|
8
|
-
}
|
9
|
-
|
10
|
-
test("Remove spaces") {
|
11
|
-
pending
|
12
|
-
CryptoSquare.normalizedPlaintext("Hi there") should be ("hithere")
|
13
|
-
}
|
14
|
-
|
15
|
-
test("Remove punctuation") {
|
16
|
-
pending
|
17
|
-
CryptoSquare.normalizedPlaintext("@1, 2%, 3 Go!") should be ("123go")
|
18
|
-
}
|
19
|
-
|
20
|
-
test("empty plaintext results in an empty rectangle") {
|
21
|
-
pending
|
22
|
-
CryptoSquare.plaintextSegments("") should be (List())
|
23
|
-
}
|
24
|
-
|
25
|
-
test("4 character plaintext results in an 2x2 rectangle") {
|
26
|
-
pending
|
27
|
-
CryptoSquare.plaintextSegments("Ab Cd") should be (List("ab", "cd"))
|
28
|
-
}
|
29
|
-
|
30
|
-
test("9 character plaintext results in an 3x3 rectangle") {
|
31
|
-
pending
|
32
|
-
CryptoSquare.plaintextSegments("This is fun!") should be (List("thi", "sis", "fun"))
|
6
|
+
test("empty plaintext results in an empty ciphertext") {
|
7
|
+
CryptoSquare.ciphertext("") should be("")
|
33
8
|
}
|
34
9
|
|
35
|
-
test("
|
10
|
+
test("Lowercase") {
|
36
11
|
pending
|
37
|
-
CryptoSquare.
|
12
|
+
CryptoSquare.ciphertext("A") should be("a")
|
38
13
|
}
|
39
14
|
|
40
|
-
test("
|
15
|
+
test("Remove spaces") {
|
41
16
|
pending
|
42
|
-
CryptoSquare.
|
17
|
+
CryptoSquare.ciphertext(" b ") should be("b")
|
43
18
|
}
|
44
19
|
|
45
|
-
test("
|
20
|
+
test("Remove punctuation") {
|
46
21
|
pending
|
47
|
-
CryptoSquare.
|
22
|
+
CryptoSquare.ciphertext("@1,%!") should be("1")
|
48
23
|
}
|
49
24
|
|
50
|
-
test("
|
25
|
+
test("9 character plaintext results in 3 chunks of 3 characters") {
|
51
26
|
pending
|
52
|
-
CryptoSquare.ciphertext("") should be
|
27
|
+
CryptoSquare.ciphertext("This is fun!") should be("tsf hiu isn")
|
53
28
|
}
|
54
29
|
|
55
|
-
test(
|
30
|
+
test(
|
31
|
+
"8 character plaintext results in 3 chunks, the last one with a trailing space") {
|
56
32
|
pending
|
57
|
-
CryptoSquare.ciphertext("
|
33
|
+
CryptoSquare.ciphertext("Chill out.") should be("clu hlt io ")
|
58
34
|
}
|
59
35
|
|
60
|
-
test(
|
36
|
+
test(
|
37
|
+
"54 character plaintext results in 7 chunks, the last two with trailing spaces") {
|
61
38
|
pending
|
62
|
-
CryptoSquare.ciphertext(
|
39
|
+
CryptoSquare.ciphertext(
|
40
|
+
"If man was meant to stay on the ground, god would have given us roots.") should be(
|
41
|
+
"imtgdvs fearwer mayoogo anouuio ntnnlvt wttddes aohghn sseoau ")
|
63
42
|
}
|
64
|
-
}
|
43
|
+
}
|
@@ -1,37 +1,37 @@
|
|
1
1
|
import org.scalatest.{FunSuite, Matchers}
|
2
2
|
|
3
|
-
/** @version 1.0
|
3
|
+
/** @version 1.3.0 */
|
4
4
|
class CustomSetTest extends FunSuite with Matchers {
|
5
5
|
|
6
6
|
// Empty test cases - Returns true if the set contains no elements
|
7
7
|
test("sets with no elements are empty") {
|
8
8
|
val set = CustomSet.fromList(List())
|
9
|
-
CustomSet.empty(set) should be
|
9
|
+
CustomSet.empty(set) should be(true)
|
10
10
|
}
|
11
11
|
|
12
12
|
test("sets with elements are not empty") {
|
13
13
|
pending
|
14
14
|
val set = CustomSet.fromList(List(1))
|
15
|
-
CustomSet.empty(set) should be
|
15
|
+
CustomSet.empty(set) should be(false)
|
16
16
|
}
|
17
17
|
|
18
18
|
// Contains test cases - Sets can report if they contain an element
|
19
19
|
test("nothing is contained in an empty set") {
|
20
20
|
pending
|
21
21
|
val set = CustomSet.fromList(List())
|
22
|
-
CustomSet.member(set, 1) should be
|
22
|
+
CustomSet.member(set, 1) should be(false)
|
23
23
|
}
|
24
24
|
|
25
25
|
test("when the element is in the set") {
|
26
26
|
pending
|
27
27
|
val set = CustomSet.fromList(List(1, 2, 3))
|
28
|
-
CustomSet.member(set, 1) should be
|
28
|
+
CustomSet.member(set, 1) should be(true)
|
29
29
|
}
|
30
30
|
|
31
31
|
test("when the element is not in the set") {
|
32
32
|
pending
|
33
33
|
val set = CustomSet.fromList(List(1, 2, 3))
|
34
|
-
CustomSet.member(set, 4) should be
|
34
|
+
CustomSet.member(set, 4) should be(false)
|
35
35
|
}
|
36
36
|
|
37
37
|
// Subset test cases - A set is a subset if all of its elements are contained in the other set
|
@@ -39,42 +39,42 @@ class CustomSetTest extends FunSuite with Matchers {
|
|
39
39
|
pending
|
40
40
|
val set1 = CustomSet.fromList(List())
|
41
41
|
val set2 = CustomSet.fromList(List())
|
42
|
-
CustomSet.isSubsetOf(set1, set2) should be
|
42
|
+
CustomSet.isSubsetOf(set1, set2) should be(true)
|
43
43
|
}
|
44
44
|
|
45
45
|
test("empty set is a subset of non-empty set") {
|
46
46
|
pending
|
47
47
|
val set1 = CustomSet.fromList(List())
|
48
48
|
val set2 = CustomSet.fromList(List(1))
|
49
|
-
CustomSet.isSubsetOf(set1, set2) should be
|
49
|
+
CustomSet.isSubsetOf(set1, set2) should be(true)
|
50
50
|
}
|
51
51
|
|
52
52
|
test("non-empty set is not a subset of empty set") {
|
53
53
|
pending
|
54
54
|
val set1 = CustomSet.fromList(List(1))
|
55
55
|
val set2 = CustomSet.fromList(List())
|
56
|
-
CustomSet.isSubsetOf(set1, set2) should be
|
56
|
+
CustomSet.isSubsetOf(set1, set2) should be(false)
|
57
57
|
}
|
58
58
|
|
59
59
|
test("set is a subset of set with exact same elements") {
|
60
60
|
pending
|
61
61
|
val set1 = CustomSet.fromList(List(1, 2, 3))
|
62
62
|
val set2 = CustomSet.fromList(List(1, 2, 3))
|
63
|
-
CustomSet.isSubsetOf(set1, set2) should be
|
63
|
+
CustomSet.isSubsetOf(set1, set2) should be(true)
|
64
64
|
}
|
65
65
|
|
66
66
|
test("set is a subset of larger set with same elements") {
|
67
67
|
pending
|
68
68
|
val set1 = CustomSet.fromList(List(1, 2, 3))
|
69
69
|
val set2 = CustomSet.fromList(List(4, 1, 2, 3))
|
70
|
-
CustomSet.isSubsetOf(set1, set2) should be
|
70
|
+
CustomSet.isSubsetOf(set1, set2) should be(true)
|
71
71
|
}
|
72
72
|
|
73
73
|
test("set is not a subset of set that does not contain its elements") {
|
74
74
|
pending
|
75
75
|
val set1 = CustomSet.fromList(List(1, 2, 3))
|
76
76
|
val set2 = CustomSet.fromList(List(4, 1, 3))
|
77
|
-
CustomSet.isSubsetOf(set1, set2) should be
|
77
|
+
CustomSet.isSubsetOf(set1, set2) should be(false)
|
78
78
|
}
|
79
79
|
|
80
80
|
// Disjoint test cases - Sets are disjoint if they share no elements
|
@@ -82,35 +82,35 @@ class CustomSetTest extends FunSuite with Matchers {
|
|
82
82
|
pending
|
83
83
|
val set1 = CustomSet.fromList(List())
|
84
84
|
val set2 = CustomSet.fromList(List())
|
85
|
-
CustomSet.isDisjointFrom(set1, set2) should be
|
85
|
+
CustomSet.isDisjointFrom(set1, set2) should be(true)
|
86
86
|
}
|
87
87
|
|
88
88
|
test("empty set is disjoint with non-empty set") {
|
89
89
|
pending
|
90
90
|
val set1 = CustomSet.fromList(List())
|
91
91
|
val set2 = CustomSet.fromList(List(1))
|
92
|
-
CustomSet.isDisjointFrom(set1, set2) should be
|
92
|
+
CustomSet.isDisjointFrom(set1, set2) should be(true)
|
93
93
|
}
|
94
94
|
|
95
95
|
test("non-empty set is disjoint with empty set") {
|
96
96
|
pending
|
97
97
|
val set1 = CustomSet.fromList(List(1))
|
98
98
|
val set2 = CustomSet.fromList(List())
|
99
|
-
CustomSet.isDisjointFrom(set1, set2) should be
|
99
|
+
CustomSet.isDisjointFrom(set1, set2) should be(true)
|
100
100
|
}
|
101
101
|
|
102
102
|
test("sets are not disjoint if they share an element") {
|
103
103
|
pending
|
104
104
|
val set1 = CustomSet.fromList(List(1, 2))
|
105
105
|
val set2 = CustomSet.fromList(List(2, 3))
|
106
|
-
CustomSet.isDisjointFrom(set1, set2) should be
|
106
|
+
CustomSet.isDisjointFrom(set1, set2) should be(false)
|
107
107
|
}
|
108
108
|
|
109
109
|
test("sets are disjoint if they share no elements") {
|
110
110
|
pending
|
111
111
|
val set1 = CustomSet.fromList(List(1, 2))
|
112
112
|
val set2 = CustomSet.fromList(List(3, 4))
|
113
|
-
CustomSet.isDisjointFrom(set1, set2) should be
|
113
|
+
CustomSet.isDisjointFrom(set1, set2) should be(true)
|
114
114
|
}
|
115
115
|
|
116
116
|
// Equal test cases - Sets with the same elements are equal
|
@@ -118,35 +118,42 @@ class CustomSetTest extends FunSuite with Matchers {
|
|
118
118
|
pending
|
119
119
|
val set1 = CustomSet.fromList(List())
|
120
120
|
val set2 = CustomSet.fromList(List())
|
121
|
-
CustomSet.isEqual(set1, set2) should be
|
121
|
+
CustomSet.isEqual(set1, set2) should be(true)
|
122
122
|
}
|
123
123
|
|
124
124
|
test("empty set is not equal to non-empty set") {
|
125
125
|
pending
|
126
126
|
val set1 = CustomSet.fromList(List())
|
127
127
|
val set2 = CustomSet.fromList(List(1, 2, 3))
|
128
|
-
CustomSet.isEqual(set1, set2) should be
|
128
|
+
CustomSet.isEqual(set1, set2) should be(false)
|
129
129
|
}
|
130
130
|
|
131
131
|
test("non-empty set is not equal to empty set") {
|
132
132
|
pending
|
133
133
|
val set1 = CustomSet.fromList(List(1, 2, 3))
|
134
134
|
val set2 = CustomSet.fromList(List())
|
135
|
-
CustomSet.isEqual(set1, set2) should be
|
135
|
+
CustomSet.isEqual(set1, set2) should be(false)
|
136
136
|
}
|
137
137
|
|
138
138
|
test("sets with the same elements are equal") {
|
139
139
|
pending
|
140
140
|
val set1 = CustomSet.fromList(List(1, 2))
|
141
141
|
val set2 = CustomSet.fromList(List(2, 1))
|
142
|
-
CustomSet.isEqual(set1, set2) should be
|
142
|
+
CustomSet.isEqual(set1, set2) should be(true)
|
143
143
|
}
|
144
144
|
|
145
145
|
test("sets with different elements are not equal") {
|
146
146
|
pending
|
147
147
|
val set1 = CustomSet.fromList(List(1, 2, 3))
|
148
148
|
val set2 = CustomSet.fromList(List(1, 2, 4))
|
149
|
-
CustomSet.isEqual(set1, set2) should be
|
149
|
+
CustomSet.isEqual(set1, set2) should be(false)
|
150
|
+
}
|
151
|
+
|
152
|
+
test("set is not equal to larger set with same elements") {
|
153
|
+
pending
|
154
|
+
val set1 = CustomSet.fromList(List(1, 2, 3))
|
155
|
+
val set2 = CustomSet.fromList(List(1, 2, 3, 4))
|
156
|
+
CustomSet.isEqual(set1, set2) should be(false)
|
150
157
|
}
|
151
158
|
|
152
159
|
// Add test cases - Unique elements can be added to a set
|
@@ -154,21 +161,21 @@ class CustomSetTest extends FunSuite with Matchers {
|
|
154
161
|
pending
|
155
162
|
val set = CustomSet.fromList(List())
|
156
163
|
val expected = CustomSet.fromList(List(3))
|
157
|
-
CustomSet.isEqual(CustomSet.insert(set, 3), expected) should be
|
164
|
+
CustomSet.isEqual(CustomSet.insert(set, 3), expected) should be(true)
|
158
165
|
}
|
159
166
|
|
160
167
|
test("add to non-empty set") {
|
161
168
|
pending
|
162
169
|
val set = CustomSet.fromList(List(1, 2, 4))
|
163
170
|
val expected = CustomSet.fromList(List(1, 2, 3, 4))
|
164
|
-
CustomSet.isEqual(CustomSet.insert(set, 3), expected) should be
|
171
|
+
CustomSet.isEqual(CustomSet.insert(set, 3), expected) should be(true)
|
165
172
|
}
|
166
173
|
|
167
174
|
test("adding an existing element does not change the set") {
|
168
175
|
pending
|
169
176
|
val set = CustomSet.fromList(List(1, 2, 3))
|
170
177
|
val expected = CustomSet.fromList(List(1, 2, 3))
|
171
|
-
CustomSet.isEqual(CustomSet.insert(set, 3), expected) should be
|
178
|
+
CustomSet.isEqual(CustomSet.insert(set, 3), expected) should be(true)
|
172
179
|
}
|
173
180
|
|
174
181
|
// Intersection test cases - Intersection returns a set of all shared elements
|
@@ -177,7 +184,8 @@ class CustomSetTest extends FunSuite with Matchers {
|
|
177
184
|
val set1 = CustomSet.fromList(List())
|
178
185
|
val set2 = CustomSet.fromList(List())
|
179
186
|
val expected = CustomSet.fromList(List())
|
180
|
-
CustomSet.isEqual(CustomSet.intersection(set1, set2), expected) should be
|
187
|
+
CustomSet.isEqual(CustomSet.intersection(set1, set2), expected) should be(
|
188
|
+
true)
|
181
189
|
}
|
182
190
|
|
183
191
|
test("intersection of an empty set and non-empty set is an empty set") {
|
@@ -185,7 +193,8 @@ class CustomSetTest extends FunSuite with Matchers {
|
|
185
193
|
val set1 = CustomSet.fromList(List())
|
186
194
|
val set2 = CustomSet.fromList(List(3, 2, 5))
|
187
195
|
val expected = CustomSet.fromList(List())
|
188
|
-
CustomSet.isEqual(CustomSet.intersection(set1, set2), expected) should be
|
196
|
+
CustomSet.isEqual(CustomSet.intersection(set1, set2), expected) should be(
|
197
|
+
true)
|
189
198
|
}
|
190
199
|
|
191
200
|
test("intersection of a non-empty set and an empty set is an empty set") {
|
@@ -193,7 +202,8 @@ class CustomSetTest extends FunSuite with Matchers {
|
|
193
202
|
val set1 = CustomSet.fromList(List(1, 2, 3, 4))
|
194
203
|
val set2 = CustomSet.fromList(List())
|
195
204
|
val expected = CustomSet.fromList(List())
|
196
|
-
CustomSet.isEqual(CustomSet.intersection(set1, set2), expected) should be
|
205
|
+
CustomSet.isEqual(CustomSet.intersection(set1, set2), expected) should be(
|
206
|
+
true)
|
197
207
|
}
|
198
208
|
|
199
209
|
test("intersection of two sets with no shared elements is an empty set") {
|
@@ -201,15 +211,18 @@ class CustomSetTest extends FunSuite with Matchers {
|
|
201
211
|
val set1 = CustomSet.fromList(List(1, 2, 3))
|
202
212
|
val set2 = CustomSet.fromList(List(4, 5, 6))
|
203
213
|
val expected = CustomSet.fromList(List())
|
204
|
-
CustomSet.isEqual(CustomSet.intersection(set1, set2), expected) should be
|
214
|
+
CustomSet.isEqual(CustomSet.intersection(set1, set2), expected) should be(
|
215
|
+
true)
|
205
216
|
}
|
206
217
|
|
207
|
-
test(
|
218
|
+
test(
|
219
|
+
"intersection of two sets with shared elements is a set of the shared elements") {
|
208
220
|
pending
|
209
221
|
val set1 = CustomSet.fromList(List(1, 2, 3, 4))
|
210
222
|
val set2 = CustomSet.fromList(List(3, 2, 5))
|
211
223
|
val expected = CustomSet.fromList(List(2, 3))
|
212
|
-
CustomSet.isEqual(CustomSet.intersection(set1, set2), expected) should be
|
224
|
+
CustomSet.isEqual(CustomSet.intersection(set1, set2), expected) should be(
|
225
|
+
true)
|
213
226
|
}
|
214
227
|
|
215
228
|
// Difference test cases - Difference (or Complement) of a set is a set of all elements that are only in the first set
|
@@ -218,7 +231,8 @@ class CustomSetTest extends FunSuite with Matchers {
|
|
218
231
|
val set1 = CustomSet.fromList(List())
|
219
232
|
val set2 = CustomSet.fromList(List())
|
220
233
|
val expected = CustomSet.fromList(List())
|
221
|
-
CustomSet.isEqual(CustomSet.difference(set1, set2), expected) should be
|
234
|
+
CustomSet.isEqual(CustomSet.difference(set1, set2), expected) should be(
|
235
|
+
true)
|
222
236
|
}
|
223
237
|
|
224
238
|
test("difference of empty set and non-empty set is an empty set") {
|
@@ -226,7 +240,8 @@ class CustomSetTest extends FunSuite with Matchers {
|
|
226
240
|
val set1 = CustomSet.fromList(List())
|
227
241
|
val set2 = CustomSet.fromList(List(3, 2, 5))
|
228
242
|
val expected = CustomSet.fromList(List())
|
229
|
-
CustomSet.isEqual(CustomSet.difference(set1, set2), expected) should be
|
243
|
+
CustomSet.isEqual(CustomSet.difference(set1, set2), expected) should be(
|
244
|
+
true)
|
230
245
|
}
|
231
246
|
|
232
247
|
test("difference of a non-empty set and an empty set is the non-empty set") {
|
@@ -234,15 +249,18 @@ class CustomSetTest extends FunSuite with Matchers {
|
|
234
249
|
val set1 = CustomSet.fromList(List(1, 2, 3, 4))
|
235
250
|
val set2 = CustomSet.fromList(List())
|
236
251
|
val expected = CustomSet.fromList(List(1, 2, 3, 4))
|
237
|
-
CustomSet.isEqual(CustomSet.difference(set1, set2), expected) should be
|
252
|
+
CustomSet.isEqual(CustomSet.difference(set1, set2), expected) should be(
|
253
|
+
true)
|
238
254
|
}
|
239
255
|
|
240
|
-
test(
|
256
|
+
test(
|
257
|
+
"difference of two non-empty sets is a set of elements that are only in the first set") {
|
241
258
|
pending
|
242
259
|
val set1 = CustomSet.fromList(List(3, 2, 1))
|
243
260
|
val set2 = CustomSet.fromList(List(2, 4))
|
244
261
|
val expected = CustomSet.fromList(List(1, 3))
|
245
|
-
CustomSet.isEqual(CustomSet.difference(set1, set2), expected) should be
|
262
|
+
CustomSet.isEqual(CustomSet.difference(set1, set2), expected) should be(
|
263
|
+
true)
|
246
264
|
}
|
247
265
|
|
248
266
|
// Union test cases - Union returns a set of all elements in either set
|
@@ -251,7 +269,7 @@ class CustomSetTest extends FunSuite with Matchers {
|
|
251
269
|
val set1 = CustomSet.fromList(List())
|
252
270
|
val set2 = CustomSet.fromList(List())
|
253
271
|
val expected = CustomSet.fromList(List())
|
254
|
-
CustomSet.isEqual(CustomSet.union(set1, set2), expected) should be
|
272
|
+
CustomSet.isEqual(CustomSet.union(set1, set2), expected) should be(true)
|
255
273
|
}
|
256
274
|
|
257
275
|
test("union of an empty set and non-empty set is the non-empty set") {
|
@@ -259,7 +277,7 @@ class CustomSetTest extends FunSuite with Matchers {
|
|
259
277
|
val set1 = CustomSet.fromList(List())
|
260
278
|
val set2 = CustomSet.fromList(List(2))
|
261
279
|
val expected = CustomSet.fromList(List(2))
|
262
|
-
CustomSet.isEqual(CustomSet.union(set1, set2), expected) should be
|
280
|
+
CustomSet.isEqual(CustomSet.union(set1, set2), expected) should be(true)
|
263
281
|
}
|
264
282
|
|
265
283
|
test("union of a non-empty set and empty set is the non-empty set") {
|
@@ -267,7 +285,7 @@ class CustomSetTest extends FunSuite with Matchers {
|
|
267
285
|
val set1 = CustomSet.fromList(List(1, 3))
|
268
286
|
val set2 = CustomSet.fromList(List())
|
269
287
|
val expected = CustomSet.fromList(List(1, 3))
|
270
|
-
CustomSet.isEqual(CustomSet.union(set1, set2), expected) should be
|
288
|
+
CustomSet.isEqual(CustomSet.union(set1, set2), expected) should be(true)
|
271
289
|
}
|
272
290
|
|
273
291
|
test("union of non-empty sets contains all unique elements") {
|
@@ -275,6 +293,6 @@ class CustomSetTest extends FunSuite with Matchers {
|
|
275
293
|
val set1 = CustomSet.fromList(List(1, 3))
|
276
294
|
val set2 = CustomSet.fromList(List(2, 3))
|
277
295
|
val expected = CustomSet.fromList(List(3, 2, 1))
|
278
|
-
CustomSet.isEqual(CustomSet.union(set1, set2), expected) should be
|
296
|
+
CustomSet.isEqual(CustomSet.union(set1, set2), expected) should be(true)
|
279
297
|
}
|
280
298
|
}
|