From 40a3a9268686744b97219f8c6308c78ef143ec81 Mon Sep 17 00:00:00 2001 From: CyB3RC0nN0R Date: Mon, 21 Oct 2019 21:45:38 +0200 Subject: [PATCH] Added PGNDatabaseTest and test file --- test/dev/kske/chess/pgn/PGNDatabaseTest.java | 36 ++++++++++++++++++++ test_res/test.pgn | 18 ++++++++++ 2 files changed, 54 insertions(+) create mode 100644 test/dev/kske/chess/pgn/PGNDatabaseTest.java create mode 100644 test_res/test.pgn diff --git a/test/dev/kske/chess/pgn/PGNDatabaseTest.java b/test/dev/kske/chess/pgn/PGNDatabaseTest.java new file mode 100644 index 0000000..35e31e1 --- /dev/null +++ b/test/dev/kske/chess/pgn/PGNDatabaseTest.java @@ -0,0 +1,36 @@ +package dev.kske.chess.pgn; + +import static org.junit.jupiter.api.Assertions.fail; + +import java.io.File; +import java.io.FileNotFoundException; + +import org.junit.jupiter.api.Test; + +import dev.kske.chess.exception.ChessException; + +/** + * Project: Chess
+ * File: PGNDatabaseTest.java
+ * Created: 4 Oct 2019
+ * Author: Kai S. K. Engelbart + */ +class PGNDatabaseTest { + + /** + * Test method for {@link dev.kske.chess.pgn.PGNDatabase#load(java.io.File)}. + * + * @throws ChessException + * @throws FileNotFoundException + */ + @Test + void testLoad() { + PGNDatabase db = new PGNDatabase(); + try { + db.load(new File(getClass().getClassLoader().getResource("test.pgn").getFile())); + } catch (FileNotFoundException | ChessException e) { + e.printStackTrace(); + fail(e); + } + } +} diff --git a/test_res/test.pgn b/test_res/test.pgn new file mode 100644 index 0000000..cb2e4ab --- /dev/null +++ b/test_res/test.pgn @@ -0,0 +1,18 @@ +[Event "Test Game"] +[Site "Test Environment"] +[Date "2019.10.04"] +[Round "1"] +[Result "1-0"] +[White "Kai Engelbart"] +[Black "Kai Engelbart 2"] + +1. e4 c5 2. Nf3 e6 3. d4 cxd4 4. Nxd4 a6 5. Bd3 Nf6 6. O-O d6 +7. c4 Bd7 8. Nc3 Nc6 9. Be3 Be7 10. h3 Ne5 11. Be2 Rc8 12. Qb3 +Qc7 13. Rac1 O-O 14. f4 Nc6 15. Nf3 Qb8 16. Qd1 Be8 17. Qd2 +Na5 18. b3 b6 19. Bd3 Nc6 20. Qf2 b5 21. Rfd1 Nb4 22. Bf1 bxc4 +23. bxc4 a5 24. Nd4 Qa8 25. Qf3 Na6 26. Ndb5 Nc5 27. e5 dxe5 +28. Qxa8 Rxa8 29. fxe5 Nfe4 30. Nd6 Bc6 31. Ncxe4 Nxe4 32. c5 +Ng3 33. Bc4 h5 34. Bf2 h4 35. Bxg3 hxg3 36. Bb5 Bxb5 37. Nxb5 +f6 38. Rd7 Bd8 39. Rc3 fxe5 40. Rxg3 Rf7 41. Rxf7 Kxf7 42. c6 +Bb6+ 43. Kf1 Kf8 44. c7 Rc8 45. a4 e4 46. Ke2 e5 47. Rg6 Bd4 +48. h4 Bb2 1-0 \ No newline at end of file