testing/alcohol_test2.scala
author Christian Urban <urbanc@in.tum.de>
Wed, 08 Nov 2017 13:57:13 +0000
changeset 130 7f3f01dfe738
parent 128 166bb9b6b20a
permissions -rw-r--r--
updated
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
128
166bb9b6b20a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     1
166bb9b6b20a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     2
import io.Source
166bb9b6b20a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     3
import scala.util._
166bb9b6b20a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     4
166bb9b6b20a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     5
val file_population_test = "population.csv"
166bb9b6b20a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     6
val file_alcohol_test = "alcohol.csv"
166bb9b6b20a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     7
166bb9b6b20a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     8
166bb9b6b20a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     9
def get_csv_file_test(file: String) : List[String] = 
166bb9b6b20a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    10
  Source.fromFile(file)("ISO-8859-1").getLines.toList
166bb9b6b20a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    11
166bb9b6b20a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    12
val alcs_test = get_csv_file_test(file_alcohol_test)
166bb9b6b20a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    13
val pops_test = get_csv_file_test(file_population_test)
166bb9b6b20a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    14
166bb9b6b20a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    15
assert(CW6b.process_alcs(alcs_test.drop(1))(0) == ("Afghanistan", 0.0))
166bb9b6b20a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    16
166bb9b6b20a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    17
assert(CW6b.process_pops(pops_test.drop(1))("Micronesia") == 104015)