-
Notifications
You must be signed in to change notification settings - Fork 0
/
P09Suite.scala
35 lines (28 loc) · 1.06 KB
/
P09Suite.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package s99.p09
import org.scalatest.FunSuite
import org.scalatest.junit.JUnitRunner
import org.junit.runner.RunWith
import P09._
@RunWith(classOf[JUnitRunner])
class P09Suite extends FunSuite {
test("Pack on empty list returns List(List())") {
val input = List()
val answer = List(List())
assert(answer === pack(input))
}
test("Pack on single element list returns list of list of 1 element") {
val input = List(1)
val answer = List(List(1))
assert(answer === pack(input))
}
test("Pack on multiple repeating element list returns proper packed lists") {
val input = List('a', 'a', 'a', 'a', 'b', 'c', 'c', 'a', 'a', 'd', 'e', 'e', 'e', 'e')
val answer = List(List('a', 'a', 'a', 'a'), List('b'), List('c', 'c'), List('a', 'a'), List('d'), List('e', 'e', 'e', 'e'))
assert(answer === pack(input))
}
test("Pack on mutiple non-repeating multiple element list returns packed list") {
val input = List(1, 2, 3, 4, 5)
val answer = List(List(1), List(2), List(3), List(4), List(5))
assert(answer === pack(input))
}
}