aboutsummaryrefslogtreecommitdiff
path: root/src/test/scala/firrtlTests/FileUtilsSpec.scala
blob: 1a23fb489405e5946bc09b5ea9bbf5cc6a707533 (plain)
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
37
38
39
40
41
42
43
44
45
46
// See LICENSE for license details.

package firrtlTests

import org.scalatest.{FlatSpec, Matchers}

import firrtl.FileUtils

class FileUtilsSpec extends FlatSpec with Matchers {

  private val sampleAnnotations: String = "annotations/SampleAnnotations.anno"
  private val sampleAnnotationsFileName: String = s"src/test/resources/$sampleAnnotations"

  behavior of "FileUtils.getLines"

  it should "read from a string filename" in {
    FileUtils.getLines(sampleAnnotationsFileName).size should be > 0
  }

  it should "read from a Java file" in {
    FileUtils.getLines(new java.io.File(sampleAnnotationsFileName)).size should be > 0
  }

  behavior of "FileUtils.getText"

  it should "read from a string filename" in {
    FileUtils.getText(sampleAnnotationsFileName).size should be > 0
  }

  it should "read from a Java file" in {
    FileUtils.getText(new java.io.File(sampleAnnotationsFileName)).size should be > 0
  }

  behavior of "FileUtils.getLinesResource"

  it should "read from a resource" in {
    FileUtils.getLinesResource(s"/$sampleAnnotations").size should be > 0
  }

  behavior of "FileUtils.getTextResource"

  it should "read from a resource" in {
    FileUtils.getTextResource(s"/$sampleAnnotations").split("\n").size should be > 0
  }

}