Skip to content

Commit

Permalink
nit
Browse files Browse the repository at this point in the history
  • Loading branch information
bowenliang123 committed Sep 22, 2023
1 parent 8d0c22d commit c1edce2
Showing 1 changed file with 6 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,32 +111,29 @@ object AssertionUtils {
*/
def assertContains(actual: TraversableOnce[AnyRef], expected: AnyRef*)(implicit
prettifier: Prettifier,
pos: Position): Unit = {
val actualSeq = actual.toSeq
pos: Position): Unit =
withClue(s", expected containing [${expected.mkString(", ")}]") {
val actualSeq = actual.toSeq
expected.foreach { elem => assert(actualSeq.contains(elem))(prettifier, pos) }
}
}

/**
* Asserts the string matches the regex
*/
def assertMatches(actual: String, regex: Regex)(implicit
prettifier: Prettifier,
pos: Position): Unit =
withClue(s"'$actual' expected to match the regex '$regex'") {
assert(actual.matches(regex.regex))(prettifier, pos)
}
withClue(s"'$actual' expected to match the regex '$regex'")(
assert(actual.matches(regex.regex))(prettifier, pos))

/**
* Asserts the string does not match the regex
*/
def assertNotMatches(actual: String, regex: Regex)(implicit
prettifier: Prettifier,
pos: Position): Unit =
withClue(s"'$actual' expected not to match the regex '$regex'") {
assert(!actual.matches(regex.regex))(prettifier, pos)
}
withClue(s"'$actual' expected not to match the regex '$regex'")(
assert(!actual.matches(regex.regex))(prettifier, pos))

/**
* Asserts that the given function throws an exception of the given type
Expand Down

0 comments on commit c1edce2

Please sign in to comment.