mirror of
https://gitlab.com/arnekeller/kit-programmieren-ws1920-final2.git
synced 2024-11-08 18:00:37 +00:00
Increase test coverage
This commit is contained in:
parent
f39fdee4c9
commit
ed5170ebfc
@ -78,5 +78,5 @@ survived
|
||||
tiger
|
||||
survived
|
||||
thunderstorm
|
||||
lose
|
||||
lost
|
||||
Error, can not get resources: game not started
|
||||
|
82
game_over_no_materials_input.txt
Normal file
82
game_over_no_materials_input.txt
Normal file
@ -0,0 +1,82 @@
|
||||
start wood,wood,wood,wood,wood,wood,wood,wood,wood,wood,wood,wood,wood,plastic,plastic,plastic,plastic,plastic,plastic,plastic,plastic,plastic,plastic,plastic,plastic,plastic,plastic,plastic,plastic,metal,metal,metal,metal,metal,metal,metal,metal,metal,metal,metal,metal,metal,metal,metal,metal,spider,spider,spider,spider,spider,snake,snake,snake,snake,snake,tiger,tiger,tiger,tiger,tiger,thunderstorm,wood,wood,wood
|
||||
draw
|
||||
draw
|
||||
draw
|
||||
draw
|
||||
draw
|
||||
draw
|
||||
draw
|
||||
draw
|
||||
draw
|
||||
draw
|
||||
draw
|
||||
draw
|
||||
draw
|
||||
draw
|
||||
draw
|
||||
draw
|
||||
draw
|
||||
draw
|
||||
draw
|
||||
draw
|
||||
draw
|
||||
draw
|
||||
draw
|
||||
draw
|
||||
draw
|
||||
draw
|
||||
draw
|
||||
draw
|
||||
draw
|
||||
draw
|
||||
draw
|
||||
draw
|
||||
draw
|
||||
draw
|
||||
draw
|
||||
draw
|
||||
draw
|
||||
draw
|
||||
draw
|
||||
draw
|
||||
draw
|
||||
draw
|
||||
draw
|
||||
draw
|
||||
draw
|
||||
draw
|
||||
rollD4 1
|
||||
draw
|
||||
rollD4 1
|
||||
draw
|
||||
rollD4 2
|
||||
draw
|
||||
rollD4 3
|
||||
draw
|
||||
rollD4 4
|
||||
draw
|
||||
rollD6 2
|
||||
draw
|
||||
rollD6 3
|
||||
draw
|
||||
rollD6 4
|
||||
draw
|
||||
rollD6 5
|
||||
draw
|
||||
rollD6 6
|
||||
draw
|
||||
rollD8 4
|
||||
draw
|
||||
rollD8 5
|
||||
draw
|
||||
rollD8 6
|
||||
draw
|
||||
rollD8 7
|
||||
draw
|
||||
rollD8 8
|
||||
draw
|
||||
draw
|
||||
draw
|
||||
draw
|
||||
build club
|
||||
list-resources
|
82
game_over_no_materials_output.txt
Normal file
82
game_over_no_materials_output.txt
Normal file
@ -0,0 +1,82 @@
|
||||
OK
|
||||
wood
|
||||
wood
|
||||
wood
|
||||
wood
|
||||
wood
|
||||
wood
|
||||
wood
|
||||
wood
|
||||
wood
|
||||
wood
|
||||
wood
|
||||
wood
|
||||
wood
|
||||
plastic
|
||||
plastic
|
||||
plastic
|
||||
plastic
|
||||
plastic
|
||||
plastic
|
||||
plastic
|
||||
plastic
|
||||
plastic
|
||||
plastic
|
||||
plastic
|
||||
plastic
|
||||
plastic
|
||||
plastic
|
||||
plastic
|
||||
plastic
|
||||
metal
|
||||
metal
|
||||
metal
|
||||
metal
|
||||
metal
|
||||
metal
|
||||
metal
|
||||
metal
|
||||
metal
|
||||
metal
|
||||
metal
|
||||
metal
|
||||
metal
|
||||
metal
|
||||
metal
|
||||
metal
|
||||
spider
|
||||
lose
|
||||
spider
|
||||
lose
|
||||
spider
|
||||
lose
|
||||
spider
|
||||
survived
|
||||
spider
|
||||
survived
|
||||
snake
|
||||
lose
|
||||
snake
|
||||
lose
|
||||
snake
|
||||
survived
|
||||
snake
|
||||
survived
|
||||
snake
|
||||
survived
|
||||
tiger
|
||||
lose
|
||||
tiger
|
||||
survived
|
||||
tiger
|
||||
survived
|
||||
tiger
|
||||
survived
|
||||
tiger
|
||||
survived
|
||||
thunderstorm
|
||||
wood
|
||||
wood
|
||||
wood
|
||||
lost
|
||||
Error, can not get resources: game not started
|
@ -34,6 +34,11 @@ class MainTest {
|
||||
cmpInOut("game_over_no_actions_input.txt", "game_over_no_actions_output.txt");
|
||||
}
|
||||
|
||||
@Test
|
||||
void gameOverNoMaterials() throws IOException {
|
||||
cmpInOut("game_over_no_materials_input.txt", "game_over_no_materials_output.txt");
|
||||
}
|
||||
|
||||
@Test
|
||||
void genericTest() throws IOException {
|
||||
cmpInOut("generic_test_input.txt", "generic_test_output.txt");
|
||||
@ -44,6 +49,11 @@ class MainTest {
|
||||
cmpInOut("generic_waf2_test_input.txt", "generic_waf2_test_output.txt");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCoverage() throws IOException {
|
||||
cmpInOut("testcoverage_input.txt", "testcoverage_output.txt");
|
||||
}
|
||||
|
||||
private void cmpInOut(String in, String out) throws IOException {
|
||||
System.setIn(new ByteArrayInputStream(readFile(in)));
|
||||
ByteArrayOutputStream output = new ByteArrayOutputStream();
|
||||
|
@ -14,7 +14,7 @@ public enum Card {
|
||||
}
|
||||
|
||||
public boolean needsDiceRoll() {
|
||||
return this.equals(SPIDER) || this.equals(SNAKE) || this.equals(TIGER);
|
||||
return this.diceSizeNeeded() > 0;
|
||||
}
|
||||
|
||||
public int diceSizeNeeded() {
|
||||
|
@ -33,9 +33,6 @@ public class CardGame {
|
||||
* @return whether the game could be successfully started
|
||||
*/
|
||||
public boolean start(Deque<Card> cardStack) throws LogicException {
|
||||
if (cardStack == null) {
|
||||
throw new LogicException("can not initialize game with null cards");
|
||||
}
|
||||
if (gameStarted()) {
|
||||
return false;
|
||||
}
|
||||
@ -66,7 +63,7 @@ public class CardGame {
|
||||
items.remove(FIREPLACE);
|
||||
}
|
||||
if (currentCardStack.isEmpty() && getBuildableItems().isEmpty()) {
|
||||
endGame(); // TODO: somehow print "lose" ??? (after the card!) [awaiting ILIAS..]
|
||||
endGame(); // TODO: somehow print "lost" ??? (after the card!) [awaiting ILIAS..]
|
||||
}
|
||||
return card;
|
||||
}
|
||||
@ -135,7 +132,7 @@ public class CardGame {
|
||||
minimumDiceRoll = 4;
|
||||
} else if (currentCardStack != null && currentCardStack.isEmpty() && getBuildableItems().isEmpty()) {
|
||||
endGame();
|
||||
return "lose";
|
||||
return "lost";
|
||||
}
|
||||
return "OK";
|
||||
} else {
|
||||
|
@ -95,7 +95,7 @@ public enum Item {
|
||||
case BALLON:
|
||||
return "ballon";
|
||||
default:
|
||||
return null;
|
||||
return super.toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
84
testcoverage_input.txt
Normal file
84
testcoverage_input.txt
Normal file
@ -0,0 +1,84 @@
|
||||
quit game
|
||||
build?!
|
||||
start spider,spider,spider,spider,spider,snake,snake,snake,snake,snake,tiger,tiger,tiger,tiger,thunderstorm,tiger,metal,metal,metal,wood,wood,wood,wood,metal,metal,plastic,plastic,wood,wood,wood,wood,wood,wood,wood,plastic,plastic,plastic,plastic,plastic,plastic,plastic,plastic,plastic,plastic,plastic,plastic,plastic,plastic,wood,wood,metal,metal,wood,wood,wood,metal,metal,metal,metal,metal,metal,metal,metal,metal
|
||||
draw
|
||||
rollD4 1
|
||||
draw
|
||||
rollD4 2
|
||||
draw
|
||||
rollD4 3
|
||||
draw
|
||||
rollD4 4
|
||||
draw
|
||||
rollD4 4
|
||||
draw
|
||||
rollD6 1
|
||||
draw
|
||||
rollD6 3
|
||||
draw
|
||||
rollD6 4
|
||||
draw
|
||||
rollD6 5
|
||||
draw
|
||||
rollD6 6
|
||||
draw
|
||||
rollD8 4
|
||||
draw
|
||||
rollD8 5
|
||||
draw
|
||||
rollD8 6
|
||||
draw
|
||||
rollD8 7
|
||||
draw
|
||||
draw
|
||||
rollD8 1
|
||||
draw
|
||||
draw
|
||||
draw
|
||||
draw
|
||||
draw
|
||||
draw
|
||||
draw
|
||||
draw
|
||||
draw
|
||||
draw
|
||||
draw
|
||||
draw
|
||||
draw
|
||||
draw
|
||||
draw
|
||||
draw
|
||||
draw
|
||||
draw
|
||||
draw
|
||||
draw
|
||||
draw
|
||||
draw
|
||||
draw
|
||||
draw
|
||||
draw
|
||||
draw
|
||||
draw
|
||||
draw
|
||||
draw
|
||||
draw
|
||||
draw
|
||||
draw
|
||||
draw
|
||||
draw
|
||||
draw
|
||||
draw
|
||||
draw
|
||||
draw
|
||||
draw
|
||||
draw
|
||||
draw
|
||||
draw
|
||||
draw
|
||||
draw
|
||||
draw
|
||||
draw
|
||||
draw
|
||||
draw
|
||||
draw
|
||||
quit
|
83
testcoverage_output.txt
Normal file
83
testcoverage_output.txt
Normal file
@ -0,0 +1,83 @@
|
||||
Error, input after quit command
|
||||
Error, invalid build? argument: none expected
|
||||
OK
|
||||
spider
|
||||
lose
|
||||
spider
|
||||
lose
|
||||
spider
|
||||
survived
|
||||
spider
|
||||
survived
|
||||
spider
|
||||
survived
|
||||
snake
|
||||
lose
|
||||
snake
|
||||
lose
|
||||
snake
|
||||
survived
|
||||
snake
|
||||
survived
|
||||
snake
|
||||
survived
|
||||
tiger
|
||||
lose
|
||||
tiger
|
||||
survived
|
||||
tiger
|
||||
survived
|
||||
tiger
|
||||
survived
|
||||
thunderstorm
|
||||
tiger
|
||||
lose
|
||||
metal
|
||||
metal
|
||||
metal
|
||||
wood
|
||||
wood
|
||||
wood
|
||||
wood
|
||||
metal
|
||||
metal
|
||||
plastic
|
||||
plastic
|
||||
wood
|
||||
wood
|
||||
wood
|
||||
wood
|
||||
wood
|
||||
wood
|
||||
wood
|
||||
plastic
|
||||
plastic
|
||||
plastic
|
||||
plastic
|
||||
plastic
|
||||
plastic
|
||||
plastic
|
||||
plastic
|
||||
plastic
|
||||
plastic
|
||||
plastic
|
||||
plastic
|
||||
plastic
|
||||
plastic
|
||||
wood
|
||||
wood
|
||||
metal
|
||||
metal
|
||||
wood
|
||||
wood
|
||||
wood
|
||||
metal
|
||||
metal
|
||||
metal
|
||||
metal
|
||||
metal
|
||||
metal
|
||||
metal
|
||||
metal
|
||||
metal
|
||||
Error, no card to draw exists
|
Loading…
Reference in New Issue
Block a user