[gnome-nibbles/arnaudb/rework-warps] Add some tests.
- From: Arnaud B. <arnaudb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-nibbles/arnaudb/rework-warps] Add some tests.
- Date: Wed, 1 Jul 2020 15:03:55 +0000 (UTC)
commit 76b1562cefac526d9f0c3cc0c4466cdb8626cd9d
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date: Wed Jul 1 16:47:33 2020 +0200
Add some tests.
src/nibbles-test.vala | 161 +++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 160 insertions(+), 1 deletion(-)
---
diff --git a/src/nibbles-test.vala b/src/nibbles-test.vala
index 8d1eaf5..d1ba881 100644
--- a/src/nibbles-test.vala
+++ b/src/nibbles-test.vala
@@ -85,6 +85,7 @@ namespace NibblesTest
assert_true (worm.lives == 6);
assert_true (worm.score == 0);
+// Test.message (@"worm $(worm.id) start: ($(worm.head.x), $(worm.head.y))");
assert_true (worm.head.x == worm_test.start_x && worm.head.y == worm_test.start_y);
}
@@ -100,15 +101,20 @@ namespace NibblesTest
Worm worm = game.worms.@get (i);
WormTest worm_test = worms [i];
+// Test.message (@"worm $(worm.id) final lives: $(worm.lives)");
+// Test.message (@"worm $(worm.id) final score: $(worm.score)");
assert_true (worm.lives == worm_test.final_lives);
assert_true (worm.score == worm_test.final_score);
}
+// Test.message (@"applied bonus: $applied_bonus");
assert_true (applied_bonus == final_bonuses);
foreach (Worm worm in game.worms)
worm.disconnect (worms_handlers [worm.id]);
game.disconnect (game_handler_1);
game.disconnect (game_handler_2);
+
+ Test.message ("");
}
/*\
@@ -117,14 +123,29 @@ namespace NibblesTest
private static void test_games ()
{
+ Test.message ("test board 008");
test_board (level_008, /* regular bonus = 8 + numworms */ 12, /* final bonuses */ 15,
{ WormTest () { start_x = 4, start_y = 14, final_lives = 6, final_score = 11 },
WormTest () { start_x = 18, start_y = 31, final_lives = 5, final_score = 14 },
WormTest () { start_x = 9, start_y = 39, final_lives = 6, final_score = 119 },
WormTest () { start_x = 51, start_y = 45, final_lives = 6, final_score = 19 }});
+
+ Test.message ("test board 011");
+ test_board (level_011, /* regular bonus = 8 + numworms */ 12, /* final bonuses */ 18,
+ { WormTest () { start_x = 15, start_y = 9, final_lives = 5, final_score = 12 },
+ WormTest () { start_x = 44, start_y = 9, final_lives = 6, final_score = 0 },
+ WormTest () { start_x = 76, start_y = 9, final_lives = 6, final_score = 0 },
+ WormTest () { start_x = 15, start_y = 56, final_lives = 6, final_score = 115 }});
+
+ Test.message ("test board 025");
+ test_board (level_025, /* regular bonus = 8 + numworms */ 12, /* final bonuses */ 14,
+ { WormTest () { start_x = 11, start_y = 6, final_lives = 5, final_score = 5 },
+ WormTest () { start_x = 80, start_y = 6, final_lives = 6, final_score = 26 },
+ WormTest () { start_x = 14, start_y = 37, final_lives = 6, final_score = 22 },
+ WormTest () { start_x = 79, start_y = 27, final_lives = 6, final_score = 22 }});
}
- private const string [] level_008 = {
+ private const string [] level_008 = { // test because it has warps, left-to-right and top-to-bottom; not
the exact code of the level (old style warps)
"┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛........┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓",
"┃..........................................................................................┃",
"┃..........................................................................................┃",
@@ -193,6 +214,144 @@ namespace NibblesTest
"┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓........┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛"
};
+ private const string [] level_011 = { // test because it uses the two kind of warps
+ "┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓",
+ "┃.............................┃┃............................┃┃.............................┃",
+ "┃.............................┃┃............................┃┃.............................┃",
+ "┃.............................┃┃............................┃┃.............................┃",
+ "┃..............▼..............┃┃............▼...............┃┃..............▼..............┃",
+ "┃.............................┃┃............................┃┃.............................┃",
+ "┃.............................┃┃............................┃┃.............................┃",
+ "┃.............................┃┃......++............++......┃┃.............................┃",
+ "┃.............................┃┃......+R............+S......┃┃.............................┃",
+ "┃.............................┃┃............................┃┃.............................┃",
+ "┃.............................┃┃............................┃┃.............................┃",
+ "┃..............u..............┃┃............................┃┃..............t..............┃",
+ "┃.............................┃┃............................┃┃.............................┃",
+ "┃.............................┃┃............................┃┃.............................┃",
+ "┃.............................┃┃............................┃┃.............................┃",
+ "┃.............................┃┗━┓........................┏━┛┃.............................┃",
+ "┃.............................┗━━┛........................┗━━┛.............................┃",
+ "┃..........................................................................................┃",
+ "┃..........................................................................................┃",
+ "┃..........................................................................................┃",
+ "┃..........................................................................................┃",
+ "┣━━━━━━━━━━━━━━━━━━━━━┓.........┏┳┳┳┳┓....................┏┓.........┏━━━━━━━━━━━━━━━━━━━━━┫",
+ "┣━━━━━━━━━━━━━━━━━━━━┓┃.........┗╋╋╋╋╋┓..................┏╋┛.........┃┏━━━━━━━━━━━━━━━━━━━━┫",
+ "┃....................┃┃..........┗╋╋╋╋╋┓................┏╋┛..........┃┃....................┃",
+ "┃....................┗┛...........┗╋╋╋╋╋┓..............┏╋┛...........┗┛....................┃",
+ "┃..................................┗╋╋╋╋╋┓............┏╋┛..................................┃",
+ "┃...................................┗╋╋╋╋╋┓..........┏╋┛...................................┃",
+ "┃....................................┗╋╋╋╋╋┓........┏╋┛....................................┃",
+ "┃.....................................┗╋╋╋╋╋┓......┏╋┛.....................................┃",
+ "┃......................................┗╋╋╋╋╋┓....┏╋┛......................................┃",
+ "┃.......................................┗╋╋╋╋╋┓..┏╋┛.......................................┃",
+ "┃........................................┗╋╋╋╋┛.┏╋┛........................................┃",
+ "┃.........++..............................┗╋╋┛.┏╋┛..............................++.........┃",
+ "┃.........+V..............................┏╋┛.┏╋╋┓..............................+V.........┃",
+ "┃........................................┏╋┛.┏╋╋╋╋┓........................................┃",
+ "┃.......................................┏╋┛..┗╋╋╋╋╋┓.......................................┃",
+ "┃......................................┏╋┛....┗╋╋╋╋╋┓......................................┃",
+ "┃.....................................┏╋┛......┗╋╋╋╋╋┓.....................................┃",
+ "┃....................................┏╋┛........┗╋╋╋╋╋┓....................................┃",
+ "┃...................................┏╋┛..........┗╋╋╋╋╋┓...................................┃",
+ "┃..................................┏╋┛............┗╋╋╋╋╋┓..................................┃",
+ "┃....................┏┓...........┏╋┛..............┗╋╋╋╋╋┓...........┏┓....................┃",
+ "┃....................┃┃..........┏╋┛................┗╋╋╋╋╋┓..........┃┃....................┃",
+ "┣━━━━━━━━━━━━━━━━━━━━┛┃.........┏╋┛..................┗╋╋╋╋╋┓.........┃┗━━━━━━━━━━━━━━━━━━━━┫",
+ "┣━━━━━━━━━━━━━━━━━━━━━┛.........┗┛....................┗┻┻┻┻┛.........┗━━━━━━━━━━━━━━━━━━━━━┫",
+ "┃..........................................................................................┃",
+ "┃..........................................................................................┃",
+ "┃..........................................................................................┃",
+ "┃..........................................................................................┃",
+ "┃.............................┏━━┓........................┏━━┓.............................┃",
+ "┃.............................┃┏━┛........................┗━┓┃.............................┃",
+ "┃.............................┃┃............................┃┃.............................┃",
+ "┃.............................┃┃............................┃┃.............................┃",
+ "┃.............................┃┃............................┃┃.............................┃",
+ "┃.............................┃┃............................┃┃.............................┃",
+ "┃..............s..............┃┃............................┃┃..............r..............┃",
+ "┃.............................┃┃............................┃┃.............................┃",
+ "┃.............................┃┃......++............++......┃┃.............................┃",
+ "┃.............................┃┃......+T............+U......┃┃.............................┃",
+ "┃.............................┃┃............................┃┃.............................┃",
+ "┃.............................┃┃............................┃┃.............................┃",
+ "┃..............▲..............┃┃................▲...........┃┃..............▲..............┃",
+ "┃.............................┃┃............................┃┃.............................┃",
+ "┃.............................┃┃............................┃┃.............................┃",
+ "┃.............................┃┃............................┃┃.............................┃",
+ "┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┻┻━━━━━━━━━━━━━━━━━━━━━━━━━━━━┻┻━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛"
+ };
+
+ private const string [] level_025 = { // test for ensuring the two first worms do not kill themselves
+ "┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓",
+ "┃..........................................................................................┃",
+ "┃..........................................................................................┃",
+ "┃..........................................................................................┃",
+ "┃..........................................┏┓..┏┓..........................................┃",
+ "┃....┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┻┛..┗┻━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓....┃",
+ "┃....┃▶..............................................................................◀┃....┃",
+ "┃....┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳┓..┏┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛....┃",
+ "┃..........................................┗┛..┗┛..........................................┃",
+ "┃..........................................................................................┃",
+ "┃..........................................................................................┃",
+ "┃..........................................................................................┃",
+ "┃..........................................................................................┃",
+ "┃..........................................................................................┃",
+ "┃..........................................................................................┃",
+ "┃..........................................................................................┃",
+ "┃..........................................................................................┃",
+ "┃..........................................................................................┃",
+ "┃..........................................................................................┃",
+ "┃...............................┏┳━━┳┓.┏┳━━┳┓..┏┳━━┳┓.┏┳━━┳┓...............................┃",
+ "┃...............................┣┛..┗┛.┗┛..┗┫..┣┛..┗┛.┗┛..┗┫...............................┃",
+ "┃...............................┃...........┃..┃...........┃...............................┃",
+ "┃...............................┃...........┃..┃...........┃...............................┃",
+ "┃...............................┣┓.........┏┫..┣┓.........┏┫...............................┃",
+ "┃...............................┗┛.........┗┛..┗┛.........┗┛...............................┃",
+ "┃..........................................................................................┃",
+ "┃...............................┏┓.........┏┓..┏┓.........┏┓...............................┃",
+ "┃...............................┣┛.........┗┫..┣┛.........┗┫...............................┃",
+ "┃...............................┃...........┃..┃...........┃...............................┃",
+ "┃...............................┃...........┃..┃...........┃...............................┃",
+ "┃...............................┣┓..┏┓.┏┓..┏┫..┣┓..┏┓.┏┓..┏┫...............................┃",
+ "┃...............................┗┻━━┻┛.┗┻━━┻┛..┗┻━━┻┛.┗┻━━┻┛...............................┃",
+ "┃.............▼................................................................▲...........┃",
+ "┃..........................................................................................┃",
+ "┃...............................┏┳━━┳┓.┏┳━━┳┓..┏┳━━┳┓.┏┳━━┳┓...............................┃",
+ "┃...............................┣┛..┗┛.┗┛..┗┫..┣┛..┗┛.┗┛..┗┫...............................┃",
+ "┃...............................┃...........┃..┃...........┃...............................┃",
+ "┃...............................┃...........┃..┃...........┃...............................┃",
+ "┃...............................┣┓.........┏┫..┣┓.........┏┫...............................┃",
+ "┃...............................┗┛.........┗┛..┗┛.........┗┛...............................┃",
+ "┃..........................................................................................┃",
+ "┃...............................┏┓.........┏┓..┏┓.........┏┓...............................┃",
+ "┃...............................┣┛.........┗┫..┣┛.........┗┫...............................┃",
+ "┃...............................┃...........┃..┃...........┃...............................┃",
+ "┃...............................┃...........┃..┃...........┃...............................┃",
+ "┃...............................┣┓..┏┓.┏┓..┏┫..┣┓..┏┓.┏┓..┏┫...............................┃",
+ "┃...............................┗┻━━┻┛.┗┻━━┻┛..┗┻━━┻┛.┗┻━━┻┛...............................┃",
+ "┃..........................................................................................┃",
+ "┃..........................................................................................┃",
+ "┃..........................................................................................┃",
+ "┃..........................................................................................┃",
+ "┃..........................................................................................┃",
+ "┃..........................................................................................┃",
+ "┃..........................................................................................┃",
+ "┃..........................................................................................┃",
+ "┃..........................................................................................┃",
+ "┃..........................................................................................┃",
+ "┃..........................................┏┓..┏┓..........................................┃",
+ "┃....┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┻┛..┗┻━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓....┃",
+ "┃....┃▶..............................................................................◀┃....┃",
+ "┃....┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳┓..┏┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛....┃",
+ "┃..........................................┗┛..┗┛..........................................┃",
+ "┃..........................................................................................┃",
+ "┃..........................................................................................┃",
+ "┃..........................................................................................┃",
+ "┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛"
+ };
+
/*\
* * test heads
\*/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]