Skip to content

Commit

Permalink
Got remaining contain value matcher to work with escaping string anal…
Browse files Browse the repository at this point in the history
…ysis.
  • Loading branch information
cheeseng committed Apr 15, 2024
1 parent 07b88e0 commit bf12784
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,11 @@ final class ContainWord {
new Matcher[U] {
def apply(left: U): MatchResult = {
val valueMapping = implicitly[ValueMapping[U]]
MatchResult(
new ContainingStringMatchResult(
valueMapping.containsValue(left, expectedValue),
Resources.rawDidNotContainValue,
Resources.rawContainedValue,
Vector(left, expectedValue),
Vector(left, expectedValue)
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,10 @@ class ShouldContainValueSpec extends AnyFunSpec with ReturnsNormallyThrowsAssert
Map(b -> a) should contain value (b)
}
e.analysis should be (Vector("LHS contains at least one entry with characters that might cause problem, the escaped string: \"test\" -> \"\\u0000test\""))
val e2 = intercept[TestFailedException] {
Map(b -> a) should (contain value (b))
}
e2.analysis should be (Vector("LHS contains at least one entry with characters that might cause problem, the escaped string: \"test\" -> \"\\u0000test\""))
}
}

Expand Down Expand Up @@ -398,6 +402,10 @@ class ShouldContainValueSpec extends AnyFunSpec with ReturnsNormallyThrowsAssert
mutable.Map(b -> a) should contain value (b)
}
e.analysis should be (Vector("LHS contains at least one entry with characters that might cause problem, the escaped string: \"test\" -> \"\\u0000test\""))
val e2 = intercept[TestFailedException] {
mutable.Map(b -> a) should (contain value (b))
}
e2.analysis should be (Vector("LHS contains at least one entry with characters that might cause problem, the escaped string: \"test\" -> \"\\u0000test\""))
}
}

Expand Down Expand Up @@ -550,6 +558,10 @@ class ShouldContainValueSpec extends AnyFunSpec with ReturnsNormallyThrowsAssert
scala.collection.Map(b -> a) should contain value (b)
}
e.analysis should be (Vector("LHS contains at least one entry with characters that might cause problem, the escaped string: \"test\" -> \"\\u0000test\""))
val e2 = intercept[TestFailedException] {
scala.collection.Map(b -> a) should (contain value (b))
}
e2.analysis should be (Vector("LHS contains at least one entry with characters that might cause problem, the escaped string: \"test\" -> \"\\u0000test\""))
}
}

Expand Down Expand Up @@ -703,6 +715,10 @@ class ShouldContainValueSpec extends AnyFunSpec with ReturnsNormallyThrowsAssert
HashMap(b -> a) should contain value (b)
}
e.analysis should be (Vector("LHS contains at least one entry with characters that might cause problem, the escaped string: \"test\" -> \"\\u0000test\""))
val e2 = intercept[TestFailedException] {
HashMap(b -> a) should (contain value (b))
}
e2.analysis should be (Vector("LHS contains at least one entry with characters that might cause problem, the escaped string: \"test\" -> \"\\u0000test\""))
}
}

Expand Down Expand Up @@ -868,6 +884,10 @@ class ShouldContainValueSpec extends AnyFunSpec with ReturnsNormallyThrowsAssert
mutable.HashMap(b -> a) should contain value (b)
}
e.analysis should be (Vector("LHS contains at least one entry with characters that might cause problem, the escaped string: \"test\" -> \"\\u0000test\""))
val e2 = intercept[TestFailedException] {
mutable.HashMap(b -> a) should (contain value (b))
}
e2.analysis should be (Vector("LHS contains at least one entry with characters that might cause problem, the escaped string: \"test\" -> \"\\u0000test\""))
}
}

Expand Down Expand Up @@ -1035,6 +1055,12 @@ class ShouldContainValueSpec extends AnyFunSpec with ReturnsNormallyThrowsAssert
jMap should contain value (b)
}
e.analysis should be (Vector("LHS contains at least one entry with characters that might cause problem, the escaped string: \"test\" -> \"\\u0000test\""))
val e2 = intercept[TestFailedException] {
val jMap: java.util.Map[String, String] = new java.util.HashMap
jMap.put(b, a)
jMap should (contain value (b))
}
e2.analysis should be (Vector("LHS contains at least one entry with characters that might cause problem, the escaped string: \"test\" -> \"\\u0000test\""))
}
}
// SKIP-SCALATESTJS,NATIVE-END
Expand Down

0 comments on commit bf12784

Please sign in to comment.