Skip to content

Commit 7f5ae27

Browse files
Add test for checking that the loop command can loop only once/fall through
1 parent c7aa502 commit 7f5ae27

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

tests/expected/test_kb_cmd.expect

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ loop test starting
22
loop test completed
33
nesting test starting
44
nesting test completed
5+
single iteration test starting
6+
single iteration test completed
57
char table test starting
68
char table test completed
79
word test starting

tests/src/test_kb_cmd.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ testEnd(loopTest, "loop test")
3838
testStart(nestingTest, "nesting test")
3939
testEnd(nestingTest, "nesting test")
4040

41+
// Single Iteration prints
42+
testStart(singleIterationTest, "single iteration test")
43+
testEnd(singleIterationTest, "single iteration test")
44+
4145
// Char table prints
4246
testStart(charTableTest, "char table test")
4347
testEnd(charTableTest, "char table test")
@@ -75,6 +79,11 @@ int testNestedLoop(int) {
7579
return 0;
7680
}
7781

82+
int testSingleIteration(int) {
83+
ASSERT_M(v == 1, "Expected to loop 1 time, looped %i time(s) instead", v);
84+
return 0;
85+
}
86+
7887
// Char table testing
7988
int capitalShiftTest(int) {
8089
ASSERT(Key_a == charToPressCMD['a'].c);
@@ -124,6 +133,15 @@ void test_main() {
124133
funcCMD(testNestedLoop),
125134
funcCMD(nestingTestEnd),
126135

136+
funcCMD(vReset),
137+
// Single iteration test
138+
funcCMD(singleIterationTestStart),
139+
loopStartCMD(1),
140+
funcCMD(vInc),
141+
loopEndCMD(),
142+
funcCMD(testSingleIteration),
143+
funcCMD(singleIterationTestEnd),
144+
127145
// Char table values test
128146
funcCMD(charTableTestStart),
129147
funcCMD(capitalShiftTest),

0 commit comments

Comments
 (0)