PPaste!

Home - All the pastes - Authored by Thooms

Raw version

 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
36
package problems

import org.scalatest._

class SolutionsSpecs extends FlatSpec with Matchers {
  "P01_Last" should "behave fine" in {
    Solutions.last(List()) should be(None)
    Solutions.last(List(0)) should be(Some(0))
    Solutions.last(List(0, 1)) should be(Some(1))
  }

  "P02_Penultimate" should "behave fine" in {
    Solutions.penultimate(List()) should be(None)
    Solutions.penultimate(List(0)) should be(None)
    Solutions.penultimate(List(0, 1)) should be(Some(0))
    Solutions.penultimate(List(0, 1, 2)) should be(Some(1))
  }

  "P03_Nth" should "behave fine" in {
    Solutions.nth(-1, List(0)) should be(None)
    Solutions.nth(2, List()) should be(None)
    Solutions.nth(1, List(0)) should be(None)
    Solutions.nth(1, List(0, 1, 2)) should be(Some(1))
  }

  "P04_Length" should "behave fine" in {
    Solutions.length(List()) should be(0)
    Solutions.length(List(0, 1)) should be(2)
  }

  "P05_Reverse" should "behave fine" in {
    Solutions.reverse(List()) should be(List())
    Solutions.reverse(List(0)) should be(List(0))
    Solutions.reverse(List(0, 1)) should be(List(1, 0))
  }
}