mirror of
https://github.com/bertptrs/adventofcode.git
synced 2025-12-25 21:00:31 +01:00
Remove C++ solutions
This commit is contained in:
@@ -1 +0,0 @@
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
100756
|
||||
@@ -1 +0,0 @@
|
||||
33583
|
||||
@@ -1,2 +0,0 @@
|
||||
R75,D30,R83,U83,L12,D49,R71,U7,L72
|
||||
U62,R66,U55,R34,D71,R55,D58,R83
|
||||
@@ -1 +0,0 @@
|
||||
159
|
||||
@@ -1,2 +0,0 @@
|
||||
R98,U47,R26,D63,R33,U87,L62,D20,R33,U53,R51
|
||||
U98,R91,D20,R16,D67,R40,U7,R15,U6,R7
|
||||
@@ -1 +0,0 @@
|
||||
135
|
||||
@@ -1,2 +0,0 @@
|
||||
R8,U5,L5,D3
|
||||
U7,R6,D4,L4
|
||||
@@ -1 +0,0 @@
|
||||
6
|
||||
@@ -1 +0,0 @@
|
||||
03-1-1.in
|
||||
@@ -1 +0,0 @@
|
||||
610
|
||||
@@ -1 +0,0 @@
|
||||
03-1-2.in
|
||||
@@ -1 +0,0 @@
|
||||
410
|
||||
@@ -1 +0,0 @@
|
||||
03-1-3.in
|
||||
@@ -1 +0,0 @@
|
||||
30
|
||||
@@ -1,11 +0,0 @@
|
||||
COM)B
|
||||
B)C
|
||||
C)D
|
||||
D)E
|
||||
E)F
|
||||
B)G
|
||||
G)H
|
||||
D)I
|
||||
E)J
|
||||
J)K
|
||||
K)L
|
||||
@@ -1 +0,0 @@
|
||||
42
|
||||
@@ -1,13 +0,0 @@
|
||||
COM)B
|
||||
B)C
|
||||
C)D
|
||||
D)E
|
||||
E)F
|
||||
B)G
|
||||
G)H
|
||||
D)I
|
||||
E)J
|
||||
J)K
|
||||
K)L
|
||||
K)YOU
|
||||
I)SAN
|
||||
@@ -1 +0,0 @@
|
||||
4
|
||||
@@ -1 +0,0 @@
|
||||
3,15,3,16,1002,16,10,16,1,16,15,15,4,15,99,0,0
|
||||
@@ -1 +0,0 @@
|
||||
43210
|
||||
@@ -1,2 +0,0 @@
|
||||
3,23,3,24,1002,24,10,24,1002,23,-1,23,
|
||||
101,5,23,23,1,24,23,23,4,23,99,0,0
|
||||
@@ -1 +0,0 @@
|
||||
54321
|
||||
@@ -1,2 +0,0 @@
|
||||
3,31,3,32,1002,32,10,32,1001,31,-2,31,1007,31,0,33,
|
||||
1002,33,7,33,1,33,31,31,1,32,31,31,4,31,99,0,0,0
|
||||
@@ -1 +0,0 @@
|
||||
65210
|
||||
@@ -1,2 +0,0 @@
|
||||
3,26,1001,26,-4,26,3,27,1002,27,2,27,1,27,26,
|
||||
27,4,27,1001,28,-1,28,1005,28,6,99,0,0,5
|
||||
@@ -1 +0,0 @@
|
||||
139629729
|
||||
@@ -1,3 +0,0 @@
|
||||
3,52,1001,52,-5,52,3,53,1,52,56,54,1007,54,5,55,1005,55,26,1001,54,
|
||||
-5,54,1105,1,12,1,53,54,53,1008,54,0,55,1001,55,1,55,2,53,55,53,4,
|
||||
53,1001,56,-1,56,1005,56,6,99,0,0,0,0,10
|
||||
@@ -1 +0,0 @@
|
||||
18216
|
||||
@@ -1,5 +0,0 @@
|
||||
.#..#
|
||||
.....
|
||||
#####
|
||||
....#
|
||||
...##
|
||||
@@ -1 +0,0 @@
|
||||
8
|
||||
@@ -1,10 +0,0 @@
|
||||
......#.#.
|
||||
#..#.#....
|
||||
..#######.
|
||||
.#.#.###..
|
||||
.#..#.....
|
||||
..#....#.#
|
||||
#..#....#.
|
||||
.##.#..###
|
||||
##...#..#.
|
||||
.#....####
|
||||
@@ -1 +0,0 @@
|
||||
33
|
||||
@@ -1,10 +0,0 @@
|
||||
#.#...#.#.
|
||||
.###....#.
|
||||
.#....#...
|
||||
##.#.#.#.#
|
||||
....#.#.#.
|
||||
.##..###.#
|
||||
..#...##..
|
||||
..##....##
|
||||
......#...
|
||||
.####.###.
|
||||
@@ -1 +0,0 @@
|
||||
35
|
||||
@@ -1,10 +0,0 @@
|
||||
.#..#..###
|
||||
####.###.#
|
||||
....###.#.
|
||||
..###.##.#
|
||||
##.##.#.#.
|
||||
....###..#
|
||||
..#.#..#.#
|
||||
#..#.#.###
|
||||
.##...##.#
|
||||
.....#.#..
|
||||
@@ -1 +0,0 @@
|
||||
41
|
||||
@@ -1,20 +0,0 @@
|
||||
.#..##.###...#######
|
||||
##.############..##.
|
||||
.#.######.########.#
|
||||
.###.#######.####.#.
|
||||
#####.##.#.##.###.##
|
||||
..#####..#.#########
|
||||
####################
|
||||
#.####....###.#.#.##
|
||||
##.#################
|
||||
#####.##.###..####..
|
||||
..######..##.#######
|
||||
####.##.####...##..#
|
||||
.#####..#.######.###
|
||||
##...#.##########...
|
||||
#.##########.#######
|
||||
.####.#.###.###.#.##
|
||||
....##.##.###..#####
|
||||
.#.#.###########.###
|
||||
#.#.#.#####.####.###
|
||||
###.##.####.##.#..##
|
||||
@@ -1 +0,0 @@
|
||||
210
|
||||
@@ -1,4 +0,0 @@
|
||||
<x=-1, y=0, z=2>
|
||||
<x=2, y=-10, z=-7>
|
||||
<x=4, y=-8, z=8>
|
||||
<x=3, y=5, z=-1>
|
||||
@@ -1 +0,0 @@
|
||||
2772
|
||||
@@ -1,4 +0,0 @@
|
||||
<x=-8, y=-10, z=0>
|
||||
<x=5, y=5, z=10>
|
||||
<x=2, y=-7, z=3>
|
||||
<x=9, y=-8, z=-3>
|
||||
@@ -1 +0,0 @@
|
||||
4686774924
|
||||
@@ -1,6 +0,0 @@
|
||||
10 ORE => 10 A
|
||||
1 ORE => 1 B
|
||||
7 A, 1 B => 1 C
|
||||
7 A, 1 C => 1 D
|
||||
7 A, 1 D => 1 E
|
||||
7 A, 1 E => 1 FUEL
|
||||
@@ -1 +0,0 @@
|
||||
31
|
||||
@@ -1,7 +0,0 @@
|
||||
9 ORE => 2 A
|
||||
8 ORE => 3 B
|
||||
7 ORE => 5 C
|
||||
3 A, 4 B => 1 AB
|
||||
5 B, 7 C => 1 BC
|
||||
4 C, 1 A => 1 CA
|
||||
2 AB, 3 BC, 4 CA => 1 FUEL
|
||||
@@ -1 +0,0 @@
|
||||
165
|
||||
@@ -1,9 +0,0 @@
|
||||
157 ORE => 5 NZVS
|
||||
165 ORE => 6 DCFZ
|
||||
44 XJWVT, 5 KHKGT, 1 QDVJ, 29 NZVS, 9 GPVTF, 48 HKGWZ => 1 FUEL
|
||||
12 HKGWZ, 1 GPVTF, 8 PSHF => 9 QDVJ
|
||||
179 ORE => 7 PSHF
|
||||
177 ORE => 5 HKGWZ
|
||||
7 DCFZ, 7 PSHF => 2 XJWVT
|
||||
165 ORE => 2 GPVTF
|
||||
3 DCFZ, 7 NZVS, 5 HKGWZ, 10 PSHF => 8 KHKGT
|
||||
@@ -1 +0,0 @@
|
||||
13312
|
||||
@@ -1,12 +0,0 @@
|
||||
2 VPVL, 7 FWMGM, 2 CXFTF, 11 MNCFX => 1 STKFG
|
||||
17 NVRVD, 3 JNWZP => 8 VPVL
|
||||
53 STKFG, 6 MNCFX, 46 VJHF, 81 HVMC, 68 CXFTF, 25 GNMV => 1 FUEL
|
||||
22 VJHF, 37 MNCFX => 5 FWMGM
|
||||
139 ORE => 4 NVRVD
|
||||
144 ORE => 7 JNWZP
|
||||
5 MNCFX, 7 RFSQX, 2 FWMGM, 2 VPVL, 19 CXFTF => 3 HVMC
|
||||
5 VJHF, 7 MNCFX, 9 VPVL, 37 CXFTF => 6 GNMV
|
||||
145 ORE => 6 MNCFX
|
||||
1 NVRVD => 8 CXFTF
|
||||
1 VJHF, 6 MNCFX => 4 RFSQX
|
||||
176 ORE => 6 VJHF
|
||||
@@ -1 +0,0 @@
|
||||
180697
|
||||
@@ -1,17 +0,0 @@
|
||||
171 ORE => 8 CNZTR
|
||||
7 ZLQW, 3 BMBT, 9 XCVML, 26 XMNCP, 1 WPTQ, 2 MZWV, 1 RJRHP => 4 PLWSL
|
||||
114 ORE => 4 BHXH
|
||||
14 VRPVC => 6 BMBT
|
||||
6 BHXH, 18 KTJDG, 12 WPTQ, 7 PLWSL, 31 FHTLT, 37 ZDVW => 1 FUEL
|
||||
6 WPTQ, 2 BMBT, 8 ZLQW, 18 KTJDG, 1 XMNCP, 6 MZWV, 1 RJRHP => 6 FHTLT
|
||||
15 XDBXC, 2 LTCX, 1 VRPVC => 6 ZLQW
|
||||
13 WPTQ, 10 LTCX, 3 RJRHP, 14 XMNCP, 2 MZWV, 1 ZLQW => 1 ZDVW
|
||||
5 BMBT => 4 WPTQ
|
||||
189 ORE => 9 KTJDG
|
||||
1 MZWV, 17 XDBXC, 3 XCVML => 2 XMNCP
|
||||
12 VRPVC, 27 CNZTR => 2 XDBXC
|
||||
15 KTJDG, 12 BHXH => 5 XCVML
|
||||
3 BHXH, 2 VRPVC => 7 MZWV
|
||||
121 ORE => 7 VRPVC
|
||||
7 XCVML => 6 RJRHP
|
||||
5 BHXH, 4 VRPVC => 5 LTCX
|
||||
@@ -1 +0,0 @@
|
||||
2210736
|
||||
@@ -1 +0,0 @@
|
||||
14-1-3.in
|
||||
@@ -1 +0,0 @@
|
||||
82892753
|
||||
@@ -1 +0,0 @@
|
||||
14-1-4.in
|
||||
@@ -1 +0,0 @@
|
||||
5586022
|
||||
@@ -1 +0,0 @@
|
||||
14-1-5.in
|
||||
@@ -1 +0,0 @@
|
||||
460664
|
||||
@@ -1 +0,0 @@
|
||||
80871224585914546619083218645595
|
||||
@@ -1 +0,0 @@
|
||||
24176176
|
||||
@@ -1 +0,0 @@
|
||||
19617804207202209144916044189917
|
||||
@@ -1 +0,0 @@
|
||||
73745418
|
||||
@@ -1 +0,0 @@
|
||||
69317163492948606335995924319873
|
||||
@@ -1 +0,0 @@
|
||||
52432133
|
||||
@@ -1,3 +0,0 @@
|
||||
#########
|
||||
#b.A.@.a#
|
||||
#########
|
||||
@@ -1 +0,0 @@
|
||||
8
|
||||
@@ -1,5 +0,0 @@
|
||||
########################
|
||||
#f.D.E.e.C.b.A.@.a.B.c.#
|
||||
######################.#
|
||||
#d.....................#
|
||||
########################
|
||||
@@ -1 +0,0 @@
|
||||
86
|
||||
@@ -1,5 +0,0 @@
|
||||
########################
|
||||
#...............b.C.D.f#
|
||||
#.######################
|
||||
#.....@.a.B.c.d.A.e.F.g#
|
||||
########################
|
||||
@@ -1 +0,0 @@
|
||||
132
|
||||
@@ -1,9 +0,0 @@
|
||||
#################
|
||||
#i.G..c...e..H.p#
|
||||
########.########
|
||||
#j.A..b...f..D.o#
|
||||
########@########
|
||||
#k.E..a...g..B.n#
|
||||
########.########
|
||||
#l.F..d...h..C.m#
|
||||
#################
|
||||
@@ -1 +0,0 @@
|
||||
136
|
||||
@@ -1,6 +0,0 @@
|
||||
########################
|
||||
#@..............ac.GI.b#
|
||||
###d#e#f################
|
||||
###A#B#C################
|
||||
###g#h#i################
|
||||
########################
|
||||
@@ -1 +0,0 @@
|
||||
81
|
||||
@@ -1,7 +0,0 @@
|
||||
###############
|
||||
#d.ABC.#.....a#
|
||||
######...######
|
||||
######.@.######
|
||||
######...######
|
||||
#b.....#.....c#
|
||||
###############
|
||||
@@ -1 +0,0 @@
|
||||
24
|
||||
@@ -1,19 +0,0 @@
|
||||
A
|
||||
A
|
||||
#######.#########
|
||||
#######.........#
|
||||
#######.#######.#
|
||||
#######.#######.#
|
||||
#######.#######.#
|
||||
##### B ###.#
|
||||
BC...## C ###.#
|
||||
##.## ###.#
|
||||
##...DE F ###.#
|
||||
##### G ###.#
|
||||
#########.#####.#
|
||||
DE..#######...###.#
|
||||
#.#########.###.#
|
||||
FG..#########.....#
|
||||
###########.#####
|
||||
Z
|
||||
Z
|
||||
@@ -1 +0,0 @@
|
||||
23
|
||||
@@ -1,37 +0,0 @@
|
||||
A
|
||||
A
|
||||
#################.#############
|
||||
#.#...#...................#.#.#
|
||||
#.#.#.###.###.###.#########.#.#
|
||||
#.#.#.......#...#.....#.#.#...#
|
||||
#.#########.###.#####.#.#.###.#
|
||||
#.............#.#.....#.......#
|
||||
###.###########.###.#####.#.#.#
|
||||
#.....# A C #.#.#.#
|
||||
####### S P #####.#
|
||||
#.#...# #......VT
|
||||
#.#.#.# #.#####
|
||||
#...#.# YN....#.#
|
||||
#.###.# #####.#
|
||||
DI....#.# #.....#
|
||||
#####.# #.###.#
|
||||
ZZ......# QG....#..AS
|
||||
###.### #######
|
||||
JO..#.#.# #.....#
|
||||
#.#.#.# ###.#.#
|
||||
#...#..DI BU....#..LF
|
||||
#####.# #.#####
|
||||
YN......# VT..#....QG
|
||||
#.###.# #.###.#
|
||||
#.#...# #.....#
|
||||
###.### J L J #.#.###
|
||||
#.....# O F P #.#...#
|
||||
#.###.#####.#.#####.#####.###.#
|
||||
#...#.#.#...#.....#.....#.#...#
|
||||
#.#####.###.###.#.#.#########.#
|
||||
#...#.#.....#...#.#.#.#.....#.#
|
||||
#.###.#####.###.###.#.#.#######
|
||||
#.#.........#...#.............#
|
||||
#########.###.###.#############
|
||||
B J C
|
||||
U P P
|
||||
@@ -1 +0,0 @@
|
||||
58
|
||||
@@ -1,37 +0,0 @@
|
||||
Z L X W C
|
||||
Z P Q B K
|
||||
###########.#.#.#.#######.###############
|
||||
#...#.......#.#.......#.#.......#.#.#...#
|
||||
###.#.#.#.#.#.#.#.###.#.#.#######.#.#.###
|
||||
#.#...#.#.#...#.#.#...#...#...#.#.......#
|
||||
#.###.#######.###.###.#.###.###.#.#######
|
||||
#...#.......#.#...#...#.............#...#
|
||||
#.#########.#######.#.#######.#######.###
|
||||
#...#.# F R I Z #.#.#.#
|
||||
#.###.# D E C H #.#.#.#
|
||||
#.#...# #...#.#
|
||||
#.###.# #.###.#
|
||||
#.#....OA WB..#.#..ZH
|
||||
#.###.# #.#.#.#
|
||||
CJ......# #.....#
|
||||
####### #######
|
||||
#.#....CK #......IC
|
||||
#.###.# #.###.#
|
||||
#.....# #...#.#
|
||||
###.### #.#.#.#
|
||||
XF....#.# RF..#.#.#
|
||||
#####.# #######
|
||||
#......CJ NM..#...#
|
||||
###.#.# #.###.#
|
||||
RE....#.# #......RF
|
||||
###.### X X L #.#.#.#
|
||||
#.....# F Q P #.#.#.#
|
||||
###.###########.###.#######.#########.###
|
||||
#.....#...#.....#.......#...#.....#.#...#
|
||||
#####.#.###.#######.#######.###.###.#.#.#
|
||||
#.......#.......#.#.#.#.#...#...#...#.#.#
|
||||
#####.###.#####.#.#.#.#.###.###.#.###.###
|
||||
#.......#.....#.#...#...............#...#
|
||||
#############.#.#.###.###################
|
||||
A O F N
|
||||
A A D M
|
||||
@@ -1 +0,0 @@
|
||||
396
|
||||
@@ -1,5 +0,0 @@
|
||||
....#
|
||||
#..#.
|
||||
#..##
|
||||
..#..
|
||||
#....
|
||||
@@ -1 +0,0 @@
|
||||
2129920
|
||||
@@ -1,78 +0,0 @@
|
||||
#include <gtest/gtest.h>
|
||||
#include "utils.hpp"
|
||||
|
||||
using aoc2019::run_intcode;
|
||||
using aoc2019::IntCodeComputer;
|
||||
|
||||
auto run_program(std::vector<int64_t> program, std::deque<int64_t> input) {
|
||||
std::deque<std::int64_t> output;
|
||||
IntCodeComputer computer(std::move(program), std::move(input));
|
||||
computer.connectOutput(output);
|
||||
computer.run();
|
||||
return output;
|
||||
}
|
||||
|
||||
TEST(Intcode, TestReproduceInput) {
|
||||
const std::vector<int64_t> program = {109, 1, 204, -1, 1001, 100, 1, 100, 1008, 100, 16, 101, 1006, 101, 0, 99};
|
||||
const std::deque<int64_t> expected(program.begin(), program.end());
|
||||
|
||||
ASSERT_EQ(expected, run_program(program, {}));
|
||||
}
|
||||
|
||||
TEST(Intcode, TestLargeMultiplication) {
|
||||
const std::vector<int64_t> program = {1102, 34915192, 34915192, 7, 4, 7, 99, 0};
|
||||
|
||||
ASSERT_EQ(1219070632396864, run_program(program, {}).front());
|
||||
}
|
||||
|
||||
TEST(Intcode, TestLargeNumber) {
|
||||
const std::vector<int64_t> program = {104, 1125899906842624, 99};
|
||||
|
||||
ASSERT_EQ(1125899906842624, run_program(program, {}).front());
|
||||
}
|
||||
|
||||
TEST(Intcode, TestPositionEquality) {
|
||||
const std::vector<int64_t> program = {3, 9, 8, 9, 10, 9, 4, 9, 99, -1, 8};
|
||||
|
||||
ASSERT_EQ(1, run_program(program, {8}).front());
|
||||
ASSERT_EQ(0, run_program(program, {9}).front());
|
||||
}
|
||||
|
||||
TEST(Intcode, TestPositionLess) {
|
||||
const std::vector<int64_t> program = {3, 9, 7, 9, 10, 9, 4, 9, 99, -1, 8};
|
||||
|
||||
ASSERT_EQ(1, run_program(program, {7}).front());
|
||||
ASSERT_EQ(0, run_program(program, {9}).front());
|
||||
}
|
||||
|
||||
TEST(Intcode, TestImmediateEquality) {
|
||||
const std::vector<int64_t> program = {3, 3, 1108, -1, 8, 3, 4, 3, 99};
|
||||
|
||||
ASSERT_EQ(1, run_program(program, {8}).front());
|
||||
ASSERT_EQ(0, run_program(program, {9}).front());
|
||||
}
|
||||
|
||||
TEST(Intcode, TestImmediateLess) {
|
||||
const std::vector<int64_t> program = {3, 3, 1107, -1, 8, 3, 4, 3, 99};
|
||||
|
||||
ASSERT_EQ(1, run_program(program, {7}).front());
|
||||
ASSERT_EQ(0, run_program(program, {9}).front());
|
||||
}
|
||||
|
||||
TEST(Intcode, TestComplicatedConditional) {
|
||||
const std::vector<std::int64_t> program = {3, 21, 1008, 21, 8, 20, 1005, 20, 22, 107, 8, 21, 20, 1006, 20, 31,
|
||||
1106, 0, 36, 98, 0, 0, 1002, 21, 125, 20, 4, 20, 1105, 1, 46, 104,
|
||||
999, 1105, 1, 46, 1101, 1000, 1, 20, 4, 20, 1105, 1, 46, 98, 99};
|
||||
auto pcopy = program;
|
||||
|
||||
auto output = run_intcode(pcopy, {7});
|
||||
ASSERT_EQ(999, output.front());
|
||||
|
||||
pcopy = program;
|
||||
output = run_intcode(pcopy, {9});
|
||||
ASSERT_EQ(1001, output.front());
|
||||
|
||||
pcopy = program;
|
||||
output = run_intcode(pcopy, {8});
|
||||
ASSERT_EQ(1000, output.front());
|
||||
}
|
||||
@@ -1,110 +0,0 @@
|
||||
#include <cassert>
|
||||
#include <cctype>
|
||||
#include <cstring>
|
||||
#include <charconv>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <gtest/gtest.h>
|
||||
#include "implementations.hpp"
|
||||
|
||||
class SolutionsTest : public testing::TestWithParam<std::string> {
|
||||
public:
|
||||
static std::string nameInstantiatedTest(const testing::TestParamInfo<SolutionsTest::ParamType> ¶mInfo);
|
||||
|
||||
protected:
|
||||
std::string input_data = "";
|
||||
std::string output_data = "";
|
||||
aoc2019::solution_t implementation = nullptr;
|
||||
|
||||
// Read input data
|
||||
void SetUp() override;
|
||||
|
||||
private:
|
||||
static void readToString(const std::string &name, std::string &target);
|
||||
|
||||
static std::tuple<int, bool, std::string> parseInputName(const std::string &name);
|
||||
};
|
||||
|
||||
void SolutionsTest::SetUp() {
|
||||
const auto input_name = GetParam();
|
||||
const auto output_name = input_name.substr(0, input_name.length() - 3) + ".out";
|
||||
|
||||
int day;
|
||||
bool part2;
|
||||
std::tie(day, part2, std::ignore) = parseInputName(input_name);
|
||||
implementation = aoc2019::get_implementation(day, part2);
|
||||
|
||||
readToString(input_name, input_data);
|
||||
readToString(output_name, output_data);
|
||||
}
|
||||
|
||||
void SolutionsTest::readToString(const std::string &name, std::string &target) {
|
||||
std::ifstream source(name);
|
||||
|
||||
target.assign(std::istreambuf_iterator<char>(source),
|
||||
std::istreambuf_iterator<char>());
|
||||
}
|
||||
|
||||
std::tuple<int, bool, std::string> SolutionsTest::parseInputName(const std::string &name) {
|
||||
const char *base_name = name.c_str();
|
||||
if (const auto last_slash = name.rfind('/'); last_slash != std::string::npos) {
|
||||
base_name += last_slash + 1;
|
||||
}
|
||||
int day, part;
|
||||
auto res = std::from_chars(base_name, base_name + 2, day);
|
||||
assert(res.ec == std::errc());
|
||||
res = std::from_chars(base_name + 3, base_name + 4, part);
|
||||
assert(res.ec == std::errc());
|
||||
|
||||
return {day, part == 2, std::string(base_name + 5, (const char*) std::strchr(base_name, '.'))};
|
||||
}
|
||||
|
||||
std::string SolutionsTest::nameInstantiatedTest(const testing::TestParamInfo<SolutionsTest::ParamType> ¶mInfo) {
|
||||
int day;
|
||||
bool part2;
|
||||
std::string sampleName;
|
||||
|
||||
std::tie(day, part2, sampleName) = parseInputName(paramInfo.param);
|
||||
|
||||
std::stringstream nameBuilder;
|
||||
|
||||
nameBuilder << "Day" << day << "Part" << (part2 ? 2 : 1) << "Sample";
|
||||
|
||||
std::copy_if(sampleName.cbegin(), sampleName.cend(), std::ostream_iterator<char>(nameBuilder), [](char c) {
|
||||
return std::isalnum(c);
|
||||
});
|
||||
|
||||
return nameBuilder.str();
|
||||
}
|
||||
|
||||
TEST_P(SolutionsTest, TestExpectedOutcome) {
|
||||
std::stringstream input_buffer, output_buffer;
|
||||
|
||||
// Sanity check, don't call null implementation
|
||||
ASSERT_NE(implementation, nullptr);
|
||||
|
||||
input_buffer.str(input_data);
|
||||
|
||||
implementation(input_buffer, output_buffer);
|
||||
|
||||
ASSERT_EQ(output_data, output_buffer.str());
|
||||
}
|
||||
|
||||
static std::vector<std::string> get_samples() {
|
||||
std::vector<std::string> samples;
|
||||
for (const auto &entry : std::filesystem::directory_iterator(TEST_SAMPLES_DIR)) {
|
||||
if (entry.path().filename().extension() == ".in") {
|
||||
samples.push_back(entry.path().string());
|
||||
}
|
||||
}
|
||||
|
||||
// Ensure a consistent order.
|
||||
std::sort(samples.begin(), samples.end());
|
||||
|
||||
return samples;
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(DaysTest, SolutionsTest,
|
||||
testing::ValuesIn(get_samples()),
|
||||
SolutionsTest::nameInstantiatedTest);
|
||||
Reference in New Issue
Block a user