-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from BME-MIT-IET/map-and-waterflow-unittests
Map and waterflow unittests
- Loading branch information
Showing
9 changed files
with
461 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#/bin/bash | ||
NEW_DISPLAY=42 | ||
DONE="no" | ||
|
||
umask 0077 | ||
mkdir -p "$HOME/.vnc" | ||
chmod go-rwx "$HOME/.vnc" | ||
vncpasswd -f <<<"$password" >"$HOME/.vnc/passwd" | ||
|
||
while [ "$DONE" == "no" ] | ||
do | ||
out=$(xdpyinfo -display :${NEW_DISPLAY} 2>&1) | ||
if [[ "$out" == name* ]] || [[ "$out" == Invalid* ]] | ||
then | ||
# command succeeded; or failed with access error; display exists | ||
(( NEW_DISPLAY+=1 )) | ||
else | ||
# display doesn't exist | ||
DONE="yes" | ||
fi | ||
done | ||
|
||
echo "Using first available display :${NEW_DISPLAY}" | ||
|
||
OLD_DISPLAY=${DISPLAY} | ||
vncserver ":${NEW_DISPLAY}" -localhost -geometry 1600x1200 -depth 16 | ||
export DISPLAY=:${NEW_DISPLAY} | ||
|
||
"$@" | ||
|
||
export DISPLAY=${OLD_DISPLAY} | ||
vncserver -kill ":${NEW_DISPLAY}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
import static org.junit.jupiter.api.Assertions.assertFalse; | ||
|
||
public class MapTest extends MapTestBase | ||
{ | ||
@Test | ||
@DisplayName("Map Initialization Test") | ||
public void MapInitTest() | ||
{ | ||
TestNeighbors(); | ||
|
||
TestPumpBreak(); | ||
|
||
TestHole(); | ||
|
||
TestSliminess(); | ||
|
||
TestStickiness(); | ||
} | ||
|
||
private void TestNeighbors() | ||
{ | ||
assertAll("Pipe Neighbors Test", | ||
() -> assertTrue(w.getNeighbors().contains(pi1)), | ||
() -> assertTrue(w.getNeighbors().contains(pi3)), | ||
|
||
() -> assertTrue(pi1.getNeighbors().contains(w)), | ||
() -> assertTrue(pi1.getNeighbors().contains(p1)), | ||
|
||
() -> assertTrue(pi2.getNeighbors().contains(p1)), | ||
() -> assertTrue(pi2.getNeighbors().contains(c)), | ||
|
||
() -> assertTrue(pi3.getNeighbors().contains(w)), | ||
() -> assertTrue(pi3.getNeighbors().contains(p2)), | ||
|
||
() -> assertTrue(pi4.getNeighbors().contains(p2)), | ||
() -> assertTrue(pi4.getNeighbors().contains(c)), | ||
|
||
() -> assertTrue(c.getNeighbors().contains(pi2)), | ||
() -> assertTrue(c.getNeighbors().contains(pi4)) | ||
); | ||
} | ||
|
||
private void TestStickiness() | ||
{ | ||
assertEquals(0, pi1.getSticky()); | ||
assertEquals(0, pi2.getSticky()); | ||
assertEquals(0, pi3.getSticky()); | ||
assertEquals(0, pi4.getSticky()); | ||
|
||
pi3.stick(); | ||
|
||
assertEquals(0, pi1.getSticky()); | ||
assertEquals(0, pi2.getSticky()); | ||
assertEquals(0, pi4.getSticky()); | ||
assertNotEquals(0, pi3.getSticky()); | ||
} | ||
|
||
private void TestHole() | ||
{ | ||
//Only pi4 should be broken | ||
assertFalse(pi1.getHoleOnPipe()); | ||
assertFalse(pi2.getHoleOnPipe()); | ||
assertFalse(pi3.getHoleOnPipe()); | ||
assertTrue(pi4.getHoleOnPipe()); | ||
} | ||
|
||
private void TestSliminess() | ||
{ | ||
assertEquals(0, pi1.getSlimey()); | ||
assertEquals(0, pi2.getSlimey()); | ||
assertEquals(0, pi3.getSlimey()); | ||
assertEquals(0, pi4.getSlimey()); | ||
|
||
pi2.slime(); | ||
|
||
assertEquals(0, pi1.getSlimey()); | ||
assertEquals(0, pi3.getSlimey()); | ||
assertEquals(0, pi4.getSlimey()); | ||
assertNotEquals(0, pi2.getSlimey()); | ||
} | ||
|
||
private void TestPumpBreak() | ||
{ | ||
//Pumps are Not broken at first | ||
assertFalse(p1.getBroken()); | ||
assertFalse(p2.getBroken()); | ||
|
||
//If we break one it should be broken | ||
p2.breakPump(); | ||
|
||
assertTrue(p2.getBroken()); | ||
assertFalse(p1.getBroken()); | ||
} | ||
} |
Oops, something went wrong.