Skip to content
Snippets Groups Projects
Commit 902811a8 authored by Niraj Rana Bhat's avatar Niraj Rana Bhat
Browse files

build.gradle updated to support gradle 8 and unit tests added for tesing...

build.gradle updated to support gradle 8 and unit tests added for tesing incomplete boxes, complete boxes and detecting redrawn lines
parent d5dce69d
No related branches found
No related tags found
No related merge requests found
......@@ -39,7 +39,7 @@ task fatJar(type: Jar) {
manifest {
attributes 'Main-Class': 'dotsandboxes.Main'
}
baseName = 'executable-jar'
archiveBaseName = 'executable-jar'
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
from { configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } }
with jar
......
......@@ -4,6 +4,8 @@ import org.junit.jupiter.api.*;
import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assumptions.*;
import java.beans.Transient;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
......@@ -15,17 +17,47 @@ public class DotsAndBoxesGridTest {
private static final Logger logger = LogManager.getLogger(DotsAndBoxesGridTest.class);
/*
* Tests are functions that have an @Test annotation before them.
* The typical format of a test is that it contains some code that does something, and then one
* or more assertions to check that a condition holds.
*
* This is a dummy test just to show that the test suite itself runs
* Code to test that boxComplete returns true for boxes that are complete
*/
@Test
public void testTestSuiteRuns() {
logger.info("Dummy test to show the test suite runs");
assertTrue(true);
public void boxCompleteDetectsCompletedBoxes(){
DotsAndBoxesGrid tGrid = new DotsAndBoxesGrid(5, 5, 2);
tGrid.drawHorizontal(0, 0, 0);
tGrid.drawHorizontal(0, 1, 0);
tGrid.drawVertical(0, 0, 0);
tGrid.drawVertical(1, 0, 0);
assertTrue(tGrid.boxComplete(0, 0));
}
// FIXME: You need to write tests for the two known bugs in the code.
/*
* Code to test that boxComplete returns false for boxes that are not complete
*/
@Test
public void boxCompleteDetectsIncompleteBoxes(){
DotsAndBoxesGrid tBoxesGrid = new DotsAndBoxesGrid(5,5 , 2);
assertFalse(tBoxesGrid.boxComplete(0, 0));
tBoxesGrid.drawHorizontal(0, 0, 0);
assertFalse(tBoxesGrid.boxComplete(0, 0));
tBoxesGrid.drawHorizontal(0, 1, 0);
assertFalse(tBoxesGrid.boxComplete(0, 0));
tBoxesGrid.drawVertical(0, 0, 0);
assertFalse(tBoxesGrid.boxComplete(0, 0));
}
/*
* Code to test if a line is drawn on top of an existing line is detected
*/
@Test
public void drawMethodsDetectRedrawnLines(){
DotsAndBoxesGrid tGrid = new DotsAndBoxesGrid(5, 5, 2);
tGrid.drawHorizontal(0, 0, 0);
assertThrows(IllegalStateException.class, () -> {
tGrid.drawHorizontal(0, 0, 0);
});
tGrid.drawVertical(0, 0, 0);
assertThrows(IllegalStateException.class, () -> {
tGrid.drawVertical(0, 0, 0);
});
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment