2 * Copyright (c) 2018-2019. Developed by Hedgecode.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package org.hedgecode.chess.qrcode;
21 import javax.imageio.ImageIO;
23 import org.hedgecode.chess.img.DiagramBuilder;
24 import org.hedgecode.chess.img.ImageFormat;
25 import org.junit.Assert;
26 import org.junit.Test;
27 import org.junit.runner.RunWith;
28 import org.junit.runners.JUnit4;
30 import org.hedgecode.chess.Builders;
31 import org.hedgecode.chess.Parsers;
32 import org.hedgecode.chess.position.Position;
35 * Tests for {@link ChessQRCodeWriter}.
37 * @author Dmitry Samoshin aka gotty
39 @RunWith(JUnit4.class)
40 public class ChessQRCodeWriterTest extends Assert {
42 private static final String QR_CODE_IMAGE_PATH = "./QRCodeTest.png";
45 public void generate() throws Exception {
46 //String expected = "rnbqkbnr/ppp1pppp/8/3p4/4P3/8/PPPP1PPP/RNBQKBNR w KQkq d6 0 2";
47 String expected = "1r2k1r1/pbppnp1p/1b3P2/8/Q7/B1PB1q2/P4PPP/3R2K1 w - - 0 21";
48 //String expected = "4kb1r/p2n1ppp/4q3/4p1B1/4P3/1Q6/PPP2PPP/2KR4 w k - 0 16";
50 Position expectedPosition = Parsers.FEN.parser().parse(
54 ChessQRCodeWriter.getInstance().write(
56 Builders.TCD.builder().build(expectedPosition),
61 File file = new File(QR_CODE_IMAGE_PATH);
62 String actual = ChessQRCodeReader.getInstance().read(
66 Position actualPosition = Parsers.TCD.parser().parse(
72 assertNotNull(actual);
73 assertEquals(expected, actual);
76 System.out.println(actual);
79 DiagramBuilder.getInstance().build(actualPosition, "test", "shade"),
81 new File("chessboard.png")
86 Builders.ASCII.builder().build(actualPosition)