Skip to content

Commit

Permalink
WIP: Int Selfie
Browse files Browse the repository at this point in the history
- Attemp to implement int selfie
  • Loading branch information
jknack committed Sep 18, 2023
1 parent 31ce925 commit 9fa1065
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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

/**
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
@@ -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
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
╔═ singleInt ═╗
678
╔═ [end of file] ═╗

0 comments on commit 9fa1065

Please sign in to comment.