X-Git-Url: https://git.hedgecode.org/?p=chesshog.git;a=blobdiff_plain;f=chesshog-uci%2Fsrc%2Ftest%2Fjava%2Forg%2Fhedgecode%2Fchess%2Fuci%2Fcommand%2FAbstractCommandTest.java;fp=chesshog-uci%2Fsrc%2Ftest%2Fjava%2Forg%2Fhedgecode%2Fchess%2Fuci%2Fcommand%2FAbstractCommandTest.java;h=3ca6fd5b75f2e0910a532957e386c7a7437e9c4e;hp=0000000000000000000000000000000000000000;hb=1c1d899a4dc4144e6b8ec93c0afcda09b38b5f6f;hpb=1fbf14530416c16f1c6fa5ee3e589482dd722a5d diff --git a/chesshog-uci/src/test/java/org/hedgecode/chess/uci/command/AbstractCommandTest.java b/chesshog-uci/src/test/java/org/hedgecode/chess/uci/command/AbstractCommandTest.java new file mode 100644 index 0000000..3ca6fd5 --- /dev/null +++ b/chesshog-uci/src/test/java/org/hedgecode/chess/uci/command/AbstractCommandTest.java @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2018-2019. Developed by Hedgecode. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.hedgecode.chess.uci.command; + +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +import org.hedgecode.chess.uci.Acceptor; +import org.hedgecode.chess.uci.Engine; + +/** + * Tests for {@link AbstractCommand}. + * + * @author Dmitry Samoshin aka gotty + */ +@RunWith(JUnit4.class) +public class AbstractCommandTest extends Assert { + + @Test + public void testParseMove() throws Exception { + + String[] correctMoves = {"e2e4", "e7e5", "e1g1", "e7e8q", "0000"}; + for (String correctMove : correctMoves) { + Move move = new AbstractCommand() { + @Override + public void exec(Engine engine, Acceptor acceptor, String params) { + throw new RuntimeException("Don't supported in test class!"); + } + }.parseMove(correctMove); + + assertNotNull(move); + } + + String[] incorrectMoves = {"00e2", "e0e5", "e1j1", "a1a9", "e7e8k"}; + for (String incorrectMove : incorrectMoves) { + Move move = new AbstractCommand() { + @Override + public void exec(Engine engine, Acceptor acceptor, String params) { + throw new RuntimeException("Don't supported in test class!"); + } + }.parseMove(incorrectMove); + + assertNull(move); + } + } + +} \ No newline at end of file