-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathStringRegexSpec.scala
More file actions
43 lines (37 loc) · 904 Bytes
/
StringRegexSpec.scala
File metadata and controls
43 lines (37 loc) · 904 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package net.wiringbits.spra.admin
import net.wiringbits.spra.admin.utils.StringRegex
import org.scalatest.matchers.must.Matchers.{be, must}
import org.scalatest.wordspec.AnyWordSpec
class StringRegexSpec extends AnyWordSpec {
"dateRegex" should {
val dateRegex = StringRegex.dateRegex
val valid = List(
"2023-01-20",
"2012-03-01",
"2020-09-19",
"2024-12-31",
"2002-02-23"
)
val invalid = List(
"aaaa-bb-cc",
"2022-a3-23",
"20e1-03-23",
"2004-01-c4",
"2012-01-23-a",
"20230223",
"??????????",
"asdfghjkl",
"ABCDEFGHI"
)
valid.foreach { value =>
s"accept valid value: $value" in {
dateRegex.matches(value) must be(true)
}
}
invalid.foreach { value =>
s"reject invalid value: $value" in {
dateRegex.matches(value) must be(false)
}
}
}
}