diff --git a/selfie-runner-junit5/src/main/kotlin/com/diffplug/selfie/Selfie.kt b/selfie-runner-junit5/src/main/kotlin/com/diffplug/selfie/Selfie.kt index 993ec0a5..7d620e20 100644 --- a/selfie-runner-junit5/src/main/kotlin/com/diffplug/selfie/Selfie.kt +++ b/selfie-runner-junit5/src/main/kotlin/com/diffplug/selfie/Selfie.kt @@ -16,6 +16,7 @@ package com.diffplug.selfie import com.diffplug.selfie.junit5.Router +import org.junit.jupiter.api.Assertions.assertEquals import org.opentest4j.AssertionFailedError /** @@ -68,8 +69,13 @@ class BinarySelfie(private val actual: ByteArray) : DiskSelfie(Snapshot.of(actua } fun expectSelfie(actual: ByteArray) = BinarySelfie(actual) -class IntSelfie(private val actual: Int) { - fun toBe(expected: Int): Int = TODO() +class IntSelfie(private val actual: Int) : DiskSelfie(Snapshot.of(actual.toString())) { + infix fun toBe(expected: Int): Int { + // TODO: Is this right? + val snapshot = toMatchDisk() + assertEquals(expected, snapshot.value.valueString().toInt()) + return expected + } fun toBe_TODO(): Int = TODO() } fun expectSelfie(actual: Int) = IntSelfie(actual) diff --git a/undertest-junit5/src/test/kotlin/undertest/junit5/UT_IntSelfieTest.kt b/undertest-junit5/src/test/kotlin/undertest/junit5/UT_IntSelfieTest.kt new file mode 100644 index 00000000..6a600a95 --- /dev/null +++ b/undertest-junit5/src/test/kotlin/undertest/junit5/UT_IntSelfieTest.kt @@ -0,0 +1,12 @@ +package undertest.junit5 +// spotless:off +import com.diffplug.selfie.expectSelfie +import kotlin.test.Test + +// spotless:on + +class UT_IntSelfieTest { + @Test fun singleInt() { + expectSelfie(678) toBe 678 + } +} diff --git a/undertest-junit5/src/test/kotlin/undertest/junit5/__snapshots__/UT_IntSelfieTest.ss b/undertest-junit5/src/test/kotlin/undertest/junit5/__snapshots__/UT_IntSelfieTest.ss new file mode 100644 index 00000000..7e438d52 --- /dev/null +++ b/undertest-junit5/src/test/kotlin/undertest/junit5/__snapshots__/UT_IntSelfieTest.ss @@ -0,0 +1,3 @@ +╔═ singleInt ═╗ +678 +╔═ [end of file] ═╗