1
0
Fork 0
mirror of https://github.com/pgpainless/pgpainless.git synced 2024-12-25 04:17:59 +01:00

Atomize PathsTest

This commit is contained in:
Paul Schaub 2023-07-03 15:56:40 +02:00
parent 5d1377c438
commit 49b8a28f6e
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311

View file

@ -23,13 +23,13 @@ class PathsTest {
private val alice_bob_2 = Certification(alice, bob, 160, Depth.limited(1)) private val alice_bob_2 = Certification(alice, bob, 160, Depth.limited(1))
@Test @Test
fun emptyPathsTest() { fun `verify that an empty Paths object has an amount of zero`() {
val empty = Paths() val empty = Paths()
assertEquals(0, empty.amount) assertEquals(0, empty.amount)
} }
@Test @Test
fun singlePathTest() { fun `verify that the amount of a Paths containing a single Path equals the Path's amount`() {
val path = Path(alice).apply { append(alice_bob_1) } val path = Path(alice).apply { append(alice_bob_1) }
val single = Paths().apply { add(path, 140) } val single = Paths().apply { add(path, 140) }
@ -37,7 +37,7 @@ class PathsTest {
} }
@Test @Test
fun twoPathsTest() { fun `verify that the amounts of two Path objects sum up`() {
val path1 = Path(alice).apply { append(alice_bob_1) } val path1 = Path(alice).apply { append(alice_bob_1) }
val path2 = Path(alice).apply { append(alice_bob_2) } val path2 = Path(alice).apply { append(alice_bob_2) }
val twoPaths = Paths().apply { val twoPaths = Paths().apply {
@ -49,7 +49,7 @@ class PathsTest {
} }
@Test @Test
fun notEnoughAmountTest() { fun `verify that a Path cannot be added if its amount is less than the method argument armound`() {
val path = Path(alice).apply { append(alice_bob_1) } val path = Path(alice).apply { append(alice_bob_1) }
val paths = Paths() val paths = Paths()
assertThrows<IllegalArgumentException> { assertThrows<IllegalArgumentException> {
@ -57,6 +57,9 @@ class PathsTest {
} }
} }
fun Certification(issuer: CertSynopsis, target: CertSynopsis, amount: Int, depth: Depth): Certification = /**
* Factory method to create a [Certification] more easily for test purposes.
*/
private fun Certification(issuer: CertSynopsis, target: CertSynopsis, amount: Int, depth: Depth): Certification =
Certification(issuer, target, null, Date(), null, true, amount, depth, RegexSet.wildcard()) Certification(issuer, target, null, Date(), null, true, amount, depth, RegexSet.wildcard())
} }