Closed philippmossier closed 2 years ago
Hi!
The test input worked for me on that day. It seems you have a lot of spaces or tabs in your test data, is that there in your actual code as well? Because that will be part of the string literal and add "weird whitespace". Try removing all spaces before the lines after the first.
It has to do with how trimTestInput
option works - it will trim empty lines at the beginning and the end of the input and will remove the indents only if the indents are the same, so you can nicely format the input, while not messing deliberate differences in indentation. In your example, the first line of the test input is not indented as far as JS template string is concerned.
In the JS template strings all white spaces are a part of the string, so without the trimTestInput
option the input would have to look like this:
run({
part1: {
tests: [
{
input: `00100
11110
10110
10111
10101
01111
00111
11100
10000
11001
00010
01010`,
expected: 150,
},
],
solution: part1,
},
trimTestInputs: false,
})
/*
Produces input:
00100
11110
10110
10111
10101
01111
00111
11100
10000
11001
00010
01010
*/
With trimTestInput: true
it can look like this:
run({
part1: {
tests: [
{
input: `
00100
11110
10110
10111
10101
01111
00111
11100
10000
11001
00010
01010
`,
expected: 150,
},
],
solution: part1,
},
trimTestInputs: true,
})
/*
Produces input:
00100
11110
10110
10111
10101
01111
00111
11100
10000
11001
00010
01010
*/
But not like this:
run({
part1: {
tests: [
{
input: `00100
11110
10110
10111
10101
01111
00111
11100
10000
11001
00010
01010
`,
expected: 150,
},
],
solution: part1,
},
part2: {
tests: [
// { input: ``, expected: "" },
],
solution: part2,
},
trimTestInputs: true,
})
/*
Produces input:
00100
11110
10110
10111
10101
01111
00111
11100
10000
11001
00010
01010
*/
I added a relevant section to the README: https://github.com/caderek/aocrunner#trimtestinputs
Closing, let me know if something is not clear.
PS: There is a new handy feature, so I recommend you to update the runner ;)
Hi,
let me say thank you for this package first. I'm really enjoying it. I found one issue with test input when using template literals. It looks like it adds some wierd whitespace or uses something als instead of \n when using multiline strings. Had this issue on day03 part1.