File: t4147.scala

package info (click to toggle)
scala 2.11.12-4
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster
  • size: 62,776 kB
  • sloc: java: 13,415; xml: 3,252; sh: 1,620; python: 756; makefile: 38; awk: 36; ansic: 6
file content (36 lines) | stat: -rw-r--r-- 822 bytes parent folder | download | duplicates (4)
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



import scala.collection._



object Test {

  def main(args: Array[String]) {
    checkElementsAreSorted()
    checkRangedImpl()
  }

  def checkElementsAreSorted() {
    val tree = mutable.SortedSet[Int]()
    tree ++= List(4, 3, 1, 6, 7, 5, 2)
    assert(tree == immutable.SortedSet(1, 2, 3, 4, 5, 6, 7))
    assert(tree.size == 7)
  }

  def checkRangedImpl() {
    val tree = mutable.SortedSet[Int](3, 1, 6, 7, 5, 2)
    val projection = tree.rangeImpl(Some(3), Some(6))
    assert(projection == immutable.SortedSet(3, 5))
    assert(projection.size == 2)

    // Let's check that modification are taken into account
    tree add 4
    assert(tree == immutable.SortedSet(1, 2, 3, 4, 5, 6, 7))
    assert(projection == immutable.SortedSet(3, 4, 5))
    assert(tree.size == 7)
    assert(projection.size == 3)
  }

}