{ Solutions to the Advent Of Code. Copyright (C) 2023 Stefan Müller This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . } unit UScratchcardsTestCases; {$mode ObjFPC}{$H+} interface uses Classes, SysUtils, fpcunit, testregistry, USolver, UBaseTestCases, UScratchcards; type { TScratchcardsBaseTestCase } TScratchcardsBaseTestCase = class(TBaseTestCase) protected procedure Setup; override; end; { TScratchcardsFullDataTestCase } TScratchcardsFullDataTestCase = class(TScratchcardsBaseTestCase) protected procedure Setup; override; published procedure TestPart1; procedure TestPart2; end; { TScratchcardsExampleTestCase } TScratchcardsExampleTestCase = class(TScratchcardsBaseTestCase) protected procedure Setup; override; published procedure TestPart1; procedure TestPart2; end; implementation { TScratchcardsBaseTestCase } procedure TScratchcardsBaseTestCase.Setup; begin inherited Setup; FSolver := TScratchcards.Create; end; { TScratchcardsFullDataTestCase } procedure TScratchcardsFullDataTestCase.Setup; begin inherited Setup; FEngine.ProcessData(FSolver); end; procedure TScratchcardsFullDataTestCase.TestPart1; begin AssertEquals(21821, FSolver.GetResultPart1); end; procedure TScratchcardsFullDataTestCase.TestPart2; begin AssertEquals(-1, FSolver.GetResultPart2); end; { TScratchcardsExampleTestCase } procedure TScratchcardsExampleTestCase.Setup; begin inherited Setup; FSolver.Init; FSolver.ProcessDataLine('Card 1: 41 48 83 86 17 | 83 86 6 31 17 9 48 53'); FSolver.ProcessDataLine('Card 2: 13 32 20 16 61 | 61 30 68 82 17 32 24 19'); FSolver.ProcessDataLine('Card 3: 1 21 53 59 44 | 69 82 63 72 16 21 14 1'); FSolver.ProcessDataLine('Card 4: 41 92 73 84 69 | 59 84 76 51 58 5 54 83'); FSolver.ProcessDataLine('Card 5: 87 83 26 28 32 | 88 30 70 12 93 22 82 36'); FSolver.ProcessDataLine('Card 6: 31 18 13 56 72 | 74 77 10 23 35 67 36 11'); FSolver.Finish; end; procedure TScratchcardsExampleTestCase.TestPart1; begin AssertEquals(13, FSolver.GetResultPart1); end; procedure TScratchcardsExampleTestCase.TestPart2; begin AssertEquals(-1, FSolver.GetResultPart2); end; initialization RegisterTest(TScratchcardsFullDataTestCase); RegisterTest(TScratchcardsExampleTestCase); end.