Skip to content

Commit 8e82958

Browse files
committed
Add tests
1 parent 3d675a2 commit 8e82958

File tree

4 files changed

+82
-0
lines changed

4 files changed

+82
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
'test_type': 'runtime',
3+
'output': """
4+
The discount for 1 items is 0%
5+
The discount for 3 items is 0%
6+
The discount for 4 items is 10%
7+
The discount for 7 items is 10%
8+
The discount for 10 items is 10%
9+
The discount for 11 items is 15%
10+
The discount for 20 items is 15%
11+
The discount for 50 items is 15%
12+
switch_expressions.amx returns 0
13+
""",
14+
'should_fail': False
15+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#include <console>
2+
3+
GetDiscount(numitems)
4+
{
5+
assert(numitems > 0);
6+
return switch (numitems;
7+
1, 2, 3: 0;
8+
4..10: 10;
9+
_: 15;
10+
);
11+
}
12+
13+
PrintDiscount(numitems)
14+
{
15+
printf("The discount for %d items is %d%c\n", numitems, GetDiscount(numitems), '%');
16+
}
17+
18+
main()
19+
{
20+
PrintDiscount(1);
21+
PrintDiscount(3);
22+
PrintDiscount(4);
23+
PrintDiscount(7);
24+
PrintDiscount(10);
25+
PrintDiscount(11);
26+
PrintDiscount(20);
27+
PrintDiscount(50);
28+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
'test_type': 'pcode_check',
3+
'code_pattern': r"""
4+
[0-9a-f]+ proc
5+
[0-9a-f]+ load.s.pri 0000000c
6+
[0-9a-f]+ switch [0-9a-f]+
7+
[0-9a-f]+ zero.pri
8+
[0-9a-f]+ jump [0-9a-f]+
9+
[0-9a-f]+ const.pri 0000000a
10+
[0-9a-f]+ jump [0-9a-f]+
11+
[0-9a-f]+ const.pri 0000000f
12+
[0-9a-f]+ jump [0-9a-f]+
13+
[0-9a-f]+ casetbl 0000000a [0-9a-f]+
14+
00000001 [0-9a-f]+
15+
00000002 [0-9a-f]+
16+
00000003 [0-9a-f]+
17+
00000004 [0-9a-f]+
18+
00000005 [0-9a-f]+
19+
00000006 [0-9a-f]+
20+
00000007 [0-9a-f]+
21+
00000008 [0-9a-f]+
22+
00000009 [0-9a-f]+
23+
0000000a [0-9a-f]+
24+
[0-9a-f]+ retn
25+
"""
26+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
GetDiscount(numitems)
2+
{
3+
return switch (numitems;
4+
1, 2, 3: 0;
5+
4..10: 10;
6+
_: 15;
7+
);
8+
}
9+
10+
main()
11+
{
12+
GetDiscount(1);
13+
}

0 commit comments

Comments
 (0)