Skip to content

Commit

Permalink
split tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bjornregnell committed Jun 11, 2024
1 parent 391350c commit 4601bd1
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/test/scala/testIO.scala
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
package introprog

val tmpDir = "target/tmp"
def createTmp(): Boolean = IO.createDirIfNotExist(tmpDir)

class TestIO extends munit.FunSuite {
test("TestIO: createDirIfNotExist, saveString, appendString, loadLines, appendLines") {
val existed = IO.createDirIfNotExist(tmpDir)
class TestIO extends munit.FunSuite:

test("TestIO: createDirIfNotExist"):
val existed = createTmp()
assert(IO.isExisting(tmpDir), s"dir should exists: $tmpDir")

test("TestIO: saveString, loadString, appendString, loadLines, appendLines"):
createTmp()
val s1 = "hello"
val fn = s"$tmpDir/hello.txt"
IO.saveString(s1, fileName = fn)
Expand All @@ -21,5 +26,3 @@ class TestIO extends munit.FunSuite {
assertEquals(s5, "hello!\nline2\n", s"loadLines not as expected: $s5")
IO.appendLines(Seq(),fileName = fn) // nothing should be added, not even newline
assertEquals(s5, IO.loadString(fileName = fn), s"loadLines not as expected: $s5")
}
}

0 comments on commit 4601bd1

Please sign in to comment.