Skip to content

Commit

Permalink
Improved a test for ticket #43
Browse files Browse the repository at this point in the history
  • Loading branch information
Dean Wampler committed Apr 3, 2022
1 parent c91dbcf commit 3e33103
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class FoldRegexPatternsSuite extends FunSuite:
type KV = (String,String)

// Parse each line, skipping expected
val kvPairs =
val actual =
properties.split("\n").
zipWithIndex.
foldLeft(Vector.empty[Either[Error,KV]]) { case (vect, (line, n)) =>
Expand All @@ -32,10 +32,11 @@ class FoldRegexPatternsSuite extends FunSuite:
case kvRegex(key, value) => vect :+ Right(key.trim -> value.trim)
case _ => vect :+ Left(n+1, line.trim)
}
assert(kvPairs == Vector(
val expected = Vector(
Right("book.name" -> "Programming Scala, Third Edition"),
Right("book.authors" -> "Dean Wampler"),
Left(6 -> "an unexpected line"),
Right("book.publisher" -> "O'Reilly"),
Right("book.publication-year" -> "2021")))
Right("book.publication-year" -> "2021"))
assert(actual == expected, "Actual:\n$actual\nExpected:\n$expected")
}

0 comments on commit 3e33103

Please sign in to comment.