-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTaggedStringTest.ql
More file actions
30 lines (26 loc) · 918 Bytes
/
TaggedStringTest.ql
File metadata and controls
30 lines (26 loc) · 918 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
import qtil.strings.TaggedString
import qtil.testing.Qnit
class Tag extends string {
Tag() { this in ["tagA", "tagB"] }
string toString() { result = super.toString() }
}
class TestMakeTwoArguments extends Test, Case {
override predicate run(Qnit test) {
if
exists(Tagged<Tag>::String str | str.make("tagA", "string value") |
str.getTag() = "tagA" and str.getStr() = "string value"
)
then test.pass("make(tag, str) works correctly")
else test.fail("make(tag, str) didn't work correctly")
}
}
class TestMakeOneArgument extends Test, Case {
override predicate run(Qnit test) {
if
exists(Tagged<Tag>::String str | str.make("string value").isTagged("tagA") |
str.getTag() = "tagA" and str.getStr() = "string value"
)
then test.pass("make(str).isTagged(tag) works correctly")
else test.fail("make(str).isTagged(tag) didn't work correctly")
}
}