From 1f161aae93903dc8747f5a16c4d86cfccea6698b Mon Sep 17 00:00:00 2001 From: pacien Date: Sun, 14 Jan 2018 18:13:22 +0100 Subject: Implement board validator Signed-off-by: pacien --- .../umlv/java/wallj/board/BoardValidatorTest.java | 35 ++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 src/test/java/fr/umlv/java/wallj/board/BoardValidatorTest.java (limited to 'src/test/java/fr') diff --git a/src/test/java/fr/umlv/java/wallj/board/BoardValidatorTest.java b/src/test/java/fr/umlv/java/wallj/board/BoardValidatorTest.java new file mode 100644 index 0000000..7be657d --- /dev/null +++ b/src/test/java/fr/umlv/java/wallj/board/BoardValidatorTest.java @@ -0,0 +1,35 @@ +package fr.umlv.java.wallj.board; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +import java.io.IOException; +import java.net.URISyntaxException; +import java.nio.file.Path; +import java.nio.file.Paths; + +/** + * @author Pacien TRAN-GIRARD + */ +final class BoardValidatorTest { + + private Path getResourcePath(String str) throws URISyntaxException { + return Paths.get(getClass().getResource(str).toURI()); + } + + @Test + void testConstraints() throws URISyntaxException, IOException { + Board validBoard = BoardParser.parse(getResourcePath("/maps/bigValid.txt")); + Assertions.assertTrue(BoardValidator.Constraint.isBounded(validBoard)); + Assertions.assertTrue(BoardValidator.Constraint.isHollow(validBoard)); + Assertions.assertTrue(BoardValidator.Constraint.hasActualReachableBlocks(validBoard)); + Assertions.assertTrue(BoardValidator.Constraint.hasMandatoryBlocks(validBoard)); + + Board invalidBoard = BoardParser.parse(getResourcePath("/maps/bigInvalid.txt")); + Assertions.assertFalse(BoardValidator.Constraint.isBounded(invalidBoard)); + Assertions.assertFalse(BoardValidator.Constraint.isHollow(invalidBoard)); + Assertions.assertFalse(BoardValidator.Constraint.hasActualReachableBlocks(invalidBoard)); + Assertions.assertFalse(BoardValidator.Constraint.hasMandatoryBlocks(invalidBoard)); + } + +} -- cgit v1.2.3