Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Selfie.expectSelfie for easy "multi-asserts" #416

Merged
merged 2 commits into from
Jun 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading