|
| 1 | +import { assert } from 'chai'; |
| 2 | +import sinon from 'sinon'; |
| 3 | +import File from '../../../File.js'; |
| 4 | +import { assertOutputAnswer } from '../../../assertOutputAnswer.js'; |
| 5 | +import { execute } from '../../../../lib/training/medium/conwaySequence/conwaySequence.js'; |
| 6 | + |
| 7 | +/** |
| 8 | + * Tests for the "Conway sequence" puzzle. |
| 9 | + */ |
| 10 | +suite('Conway sequence', function() { |
| 11 | + const sandbox = sinon.createSandbox(); |
| 12 | + |
| 13 | + setup(function () { |
| 14 | + sandbox.stub(console, "log"); |
| 15 | + }); |
| 16 | + |
| 17 | + teardown(function () { |
| 18 | + sandbox.restore(); |
| 19 | + }); |
| 20 | + |
| 21 | + |
| 22 | + test('R=1 and L=11', function() { |
| 23 | + let inputFile = new File('./test/training/medium/conwaySequence/input/01 - r1 l11.txt'); |
| 24 | + |
| 25 | + execute(inputFile.readline.bind(inputFile)); |
| 26 | + |
| 27 | + assertOutputAnswer('./test/training/medium/conwaySequence/output/01 - r1 l11.txt'); |
| 28 | + }); |
| 29 | + |
| 30 | + test('R=2 and L=1', function() { |
| 31 | + let inputFile = new File('./test/training/medium/conwaySequence/input/02 - r2 l1.txt'); |
| 32 | + |
| 33 | + execute(inputFile.readline.bind(inputFile)); |
| 34 | + |
| 35 | + assertOutputAnswer('./test/training/medium/conwaySequence/output/02 - r2 l1.txt'); |
| 36 | + }); |
| 37 | + |
| 38 | + test('R=5 and L=10', function() { |
| 39 | + let inputFile = new File('./test/training/medium/conwaySequence/input/03 - r5 l10.txt'); |
| 40 | + |
| 41 | + execute(inputFile.readline.bind(inputFile)); |
| 42 | + |
| 43 | + assertOutputAnswer('./test/training/medium/conwaySequence/output/03 - r5 l10.txt'); |
| 44 | + }); |
| 45 | + |
| 46 | + test('R=25 and L=10', function() { |
| 47 | + let inputFile = new File('./test/training/medium/conwaySequence/input/04 - r25 l10.txt'); |
| 48 | + |
| 49 | + execute(inputFile.readline.bind(inputFile)); |
| 50 | + |
| 51 | + assertOutputAnswer('./test/training/medium/conwaySequence/output/04 - r25 l10.txt'); |
| 52 | + }); |
| 53 | + |
| 54 | + test('R=1 and L=25', function() { |
| 55 | + let inputFile = new File('./test/training/medium/conwaySequence/input/05 - r1 l25.txt'); |
| 56 | + |
| 57 | + execute(inputFile.readline.bind(inputFile)); |
| 58 | + |
| 59 | + assertOutputAnswer('./test/training/medium/conwaySequence/output/05 - r1 l25.txt'); |
| 60 | + }); |
| 61 | + |
| 62 | + test('R=33 and L=25', function() { |
| 63 | + let inputFile = new File('./test/training/medium/conwaySequence/input/06 - r33 l25.txt'); |
| 64 | + |
| 65 | + execute(inputFile.readline.bind(inputFile)); |
| 66 | + |
| 67 | + assertOutputAnswer('./test/training/medium/conwaySequence/output/06 - r33 l25.txt'); |
| 68 | + }); |
| 69 | +}); |
0 commit comments