Skip to content

Commit 4601bd1

Browse files
committed
split tests
1 parent 391350c commit 4601bd1

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/test/scala/testIO.scala

+8-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
package introprog
22

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

5-
class TestIO extends munit.FunSuite {
6-
test("TestIO: createDirIfNotExist, saveString, appendString, loadLines, appendLines") {
7-
val existed = IO.createDirIfNotExist(tmpDir)
6+
class TestIO extends munit.FunSuite:
7+
8+
test("TestIO: createDirIfNotExist"):
9+
val existed = createTmp()
810
assert(IO.isExisting(tmpDir), s"dir should exists: $tmpDir")
11+
12+
test("TestIO: saveString, loadString, appendString, loadLines, appendLines"):
13+
createTmp()
914
val s1 = "hello"
1015
val fn = s"$tmpDir/hello.txt"
1116
IO.saveString(s1, fileName = fn)
@@ -21,5 +26,3 @@ class TestIO extends munit.FunSuite {
2126
assertEquals(s5, "hello!\nline2\n", s"loadLines not as expected: $s5")
2227
IO.appendLines(Seq(),fileName = fn) // nothing should be added, not even newline
2328
assertEquals(s5, IO.loadString(fileName = fn), s"loadLines not as expected: $s5")
24-
}
25-
}

0 commit comments

Comments
 (0)