1
0
Fork 0
mirror of https://github.com/pgpainless/pgpainless.git synced 2024-12-24 11:57:59 +01:00

100% coverage of RegexSet class

This commit is contained in:
Paul Schaub 2023-07-15 17:27:17 +02:00
parent 31a7a822ac
commit 8aa3df5878
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311

View file

@ -2,6 +2,7 @@ package org.pgpainless.wot.network
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test
import org.pgpainless.wot.dsl.NetworkDSL import org.pgpainless.wot.dsl.NetworkDSL
import kotlin.test.assertEquals
import kotlin.test.assertFalse import kotlin.test.assertFalse
import kotlin.test.assertTrue import kotlin.test.assertTrue
@ -64,4 +65,23 @@ class RegexSetTest: NetworkDSL {
assertTrue { regex.matches("Alice <alice@pgpainless.org>") } assertTrue { regex.matches("Alice <alice@pgpainless.org>") }
assertFalse { regex.matches("<alice@pgpainless\\.org>") } assertFalse { regex.matches("<alice@pgpainless\\.org>") }
} }
@Test
fun `verify that wildcard()_toString() equals empty string`() {
val regex = RegexSet.wildcard()
assertEquals("", regex.toString())
}
@Test
fun `verify that single regex _toString() returns the regex`() {
val regex = domainRegex("pgpainless.org")
assertEquals("<[^>]+[@.]pgpainless\\.org>\$", regex.toString())
}
@Test
fun `verify that multiple regex _toString returns comma separated values`() {
val list = listOf("<[^>]+[@.]pgpainless\\.org>\$", "<[^>]+[@.]example\\.com>\$")
val regex = RegexSet.fromExpressionList(list)
assertEquals("<[^>]+[@.]pgpainless\\.org>\$, <[^>]+[@.]example\\.com>\$", regex.toString())
}
} }