Skip to content

Commit

Permalink
feat: implement comparison tests between both parsers
Browse files Browse the repository at this point in the history
  • Loading branch information
mbaechler committed Nov 20, 2024
1 parent e72b1f0 commit 8ddd480
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tests/shared/src/test/scala/cron4s/CronSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,16 @@ object CronSpec extends TableDrivenPropertyChecks {
AnyNode[DayOfWeek]
)

val validExpressions = Table(
"expression",
"* 5 4 * * *",
"* 0 0,12 1 */2 *",
"* 5 4 * * sun",
"* 0 0,12 1 */2 *",
"0 0,5,10,15,20,25,30,35,40,45,50,55 * * * *",
"0 1 2-4 * 4,5,6 */3",
"1 5 4 * * mon-2,sun"
)
}

trait CronSpec extends Matchers { this: AnyFlatSpec =>
Expand Down Expand Up @@ -131,3 +141,13 @@ class ParserCombinatorsCronSpec extends AnyFlatSpec with CronSpec {
class AttoCronSpec extends AnyFlatSpec with CronSpec {
def parser = atto.Parser
}

class CronParserComparisonSpec extends AnyFlatSpec with Matchers {
import CronSpec._

"Parser-Combinators and Atto parsers" should "parse valid expressions with the same result" in {
forAll(CronSpec.validExpressions) { expr: String =>
parsing.parse(expr) shouldBe atto.Parser.parse(expr)
}
}
}

0 comments on commit 8ddd480

Please sign in to comment.