|
| 1 | +const { describe, it } = require('node:test') |
| 2 | +const assert = require('node:assert/strict') |
| 3 | + |
| 4 | +const { readFileSync } = require('fs') |
| 5 | +const { join } = require('path') |
| 6 | + |
| 7 | +const solutions = require('./nqla.repo') |
| 8 | + |
| 9 | +const bigInputPath = join(__dirname, '../input-big.txt') |
| 10 | +const bigInput = readFileSync(bigInputPath, 'utf-8') |
| 11 | + |
| 12 | +for (const { fun, id } of solutions) { |
| 13 | + describe(`Advent of Code 'Not Quite Lisp (part a)' solution '${id}'`, () => { |
| 14 | + it('Solves empty string', () => { |
| 15 | + assert.equal(fun(''), 0) |
| 16 | + }) |
| 17 | + |
| 18 | + it('Solves string of length 1', () => { |
| 19 | + assert.equal(fun('('), 1) |
| 20 | + assert.equal(fun(')'), -1) |
| 21 | + }) |
| 22 | + |
| 23 | + it('Solves string of length 4', () => { |
| 24 | + assert.equal(fun('(())'), 0) |
| 25 | + assert.equal(fun('()()'), 0) |
| 26 | + assert.equal(fun('((()'), 2) |
| 27 | + assert.equal(fun('))))'), -4) |
| 28 | + }) |
| 29 | + |
| 30 | + it('Solves big input', () => { |
| 31 | + assert.equal(fun(bigInput), 232) |
| 32 | + }) |
| 33 | + }) |
| 34 | +} |
0 commit comments