-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDayTwoParserTests.cpp
39 lines (31 loc) · 1.46 KB
/
DayTwoParserTests.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
//
// Created by Aidan Nagorcka-Smith on 30/12/2022.
//
#include <gtest/gtest.h>
#include <nanobench.h>
#include "DayTwoParser.h"
namespace AdventOfCode::DayTwo::Parser {
constexpr int kDayOneInputNumberOfRounds = 2500;
constexpr RockPaperScissors::Selection kRoundOnePlayerOneSelection = RockPaperScissors::Selection::kPaper;
constexpr RockPaperScissors::Selection kRoundOnePlayerTwoSelection = RockPaperScissors::Selection::kPaper;
TEST(DayTwoParser, Parses) {
auto rounds = parseFilePuzzleOne(kDayTwoInputFilePath);
EXPECT_EQ(kDayOneInputNumberOfRounds, rounds.size());
EXPECT_EQ(kRoundOnePlayerOneSelection, rounds.at(0).playerOneSelection());
EXPECT_EQ(kRoundOnePlayerTwoSelection, rounds.at(0).playerTwoSelection());
}
TEST(DayTwoParser, benchmarkParseComplete) {
ankerl::nanobench::Bench().run("Day 2 Parse - Batch", [&]() {
ankerl::nanobench::doNotOptimizeAway(Parser::parseFilePuzzleOne(Parser::kDayTwoInputFilePath));
});
}
TEST(DayTwoParser, benchmarkParseWithCallback) {
ankerl::nanobench::Bench().run("Day 2 Parse - Callback", [&]() {
std::vector<RockPaperScissors::Round> rounds;
Parser::parseFilePuzzleOne(Parser::kDayTwoInputFilePath, [&](const RockPaperScissors::Round &elf) {
rounds.push_back(elf);
});
ankerl::nanobench::doNotOptimizeAway(rounds);
});
}
} // AdventOfCode::DayTwo::Parser