-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathsimcUnitTests.em
153 lines (119 loc) · 3.05 KB
/
simcUnitTests.em
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
macro runAllUnitTests()
{
unitTest_str_lstrip()
unitTest_str_rstrip()
unitTest_str_contain()
unitTest_str_only_contain()
unitTest_str_strip()
unitTest_str_begin_with()
unitTest_str_end_with()
unitTest_str_rep()
unitTest_str_padding()
unitTest_str_subtract()
}
macro unitTest_str_subtract()
{
sSub = " * #include <IfAaSrio.h>"
s = __str_subtract(cat("success", sSub), sSub)
if s == "success"
inf("__str_subtract() passed")
else
err("__str_subtract() failed")
}
macro unitTest_str_padding()
{
sSub = " * #include <IfAaSrio.h>"
s = __str_padding(sSub, strlen(sSub)+3)
if s == cat(sSub, " ")
inf("__str_padding() passed")
else
err("__str_padding() failed")
}
macro unitTest_str_rep()
{
sSub = " * #include <IfAaSrio.h>"
s = __str_rep(sSub, 3)
if s == cat(cat(sSub, sSub), sSub)
inf("__str_rep() passed")
else
err("__str_rep() failed")
}
macro unitTest_str_begin_with()
{
sSub = " * #include <IfAaSrio.h>"
s = __str_begin_with(cat(sSub, "success"), sSub)
if s
inf("__str_begin_with() passed")
else
err("__str_begin_with() failed")
}
macro unitTest_str_end_with()
{
sSub = " * #include <IfAaSrio.h>"
s = __str_end_with(cat("success", sSub), sSub)
if s
inf("__str_end_with() passed")
else
err("__str_end_with() failed")
}
macro unitTest_str_lstrip()
{
sSub = " * #include <IfAaSrio.h>"
s = __str_lstrip(cat(sSub, "success"), sSub)
if s == "success"
inf("__str_lstrip() passed")
else
err("__str_lstrip() failed")
}
macro unitTest_str_rstrip()
{
sSub = " * #include <IfAaSrio.h>"
s = __str_rstrip(cat("success", sSub), sSub)
if s == "success"
inf("__str_rstrip() passed")
else
err("__str_rstrip() failed")
}
macro unitTest_str_contain()
{
sStr = ">"
sSubStr = ">"
if !__str_contain(sStr, sSubStr)
err("__str_contain() failed")
sStr = " * #include <IfAaSrio.h>"
sSubStr = " * #incl >"
if __str_contain(sStr, sSubStr)
err("__str_contain() failed")
inf("__str_contain() passed")
}
macro unitTest_str_only_contain()
{
sStr = "> !#$%%^&&*()"
sSubStr = ")(*&^%$#! >"
if !__str_only_contain(sStr, sSubStr)
err("__str_only_contain() failed")
sStr = " * #include <IfAaSrio.h>"
sSubStr = " * #incl <"
if __str_contain(sStr, sSubStr)
err("__str_only_contain() failed")
inf("__str_only_contain() passed")
}
macro unitTest_str_strip()
{
tag = " * #/<>"
s = cat(cat(tag, "success"), tag)
s = __str_strip(s, tag)
if s == "success"
inf("__str_strip() passed")
else
err("__str_strip() failed")
}
macro inf(message)
{
msg(message)
}
macro err(message)
{
msg(message)
stop
}