Skip to content

Commit

Permalink
Added Selfie.expectSelfie for easy "multi-asserts" (#416)
Browse files Browse the repository at this point in the history
  • Loading branch information
nedtwigg authored Jun 3, 2024
2 parents b5c408f + fb49674 commit 735c188
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions jvm/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]
### Added
- Added `Selfie.expectSelfies(Iterable<T> items, Function<T, String> toString)` for doing easy "multi-asserts". ([#416](https://github.com/diffplug/selfie/pull/416))
- For java versions which don't support multiline string literals, we now encode multiline strings like so: ([#406](https://github.com/diffplug/selfie/pull/406))
- ```java
toBe("line1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ object Selfie {
@JvmStatic fun expectSelfie(actual: Int) = IntSelfie(actual)
@JvmStatic fun expectSelfie(actual: Boolean) = BooleanSelfie(actual)

@JvmStatic
fun <T> expectSelfies(items: Iterable<T>, toString: (T) -> String): StringSelfie {
val snapshots = items.joinToString("\n", transform = toString)
return expectSelfie(snapshots)
}

@JvmStatic
fun cacheSelfie(toCache: Cacheable<String>) = cacheSelfie(Roundtrip.identity(), toCache)

Expand Down

0 comments on commit 735c188

Please sign in to comment.