-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTest_day_6.cpp
More file actions
66 lines (54 loc) · 1.92 KB
/
Test_day_6.cpp
File metadata and controls
66 lines (54 loc) · 1.92 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
//
// Created by Ryan Avery on 12/6/2022.
//
#include <gtest/gtest.h>
#include <fstream>
#include <filesystem>
#include "day_6.h"
namespace Day6 {
class TestDay6 : public ::testing::Test {
public:
TestDay6() {}
};
TEST_F(TestDay6, TestSopAndSomExamples) {
std::vector<std::tuple<std::string, int, int>> data = {
{"mjqjpqmgbljsphdztnvjfqwrcgsmlb", 7, 19},
{"bvwbjplbgvbhsrlpgdmjqwftvncz", 5, 23},
{"nppdvjthqldpwncqszvftbrmjlhg", 6, 23},
{"nznrnfrfntjfmvfwmzdfjlvtqnbhcprsg", 10, 29},
{"zcfzfwzzqfrljwzlrfnpqdbhtmscgvjw", 11, 26},
};
for(const auto [inStr, expectedSop, expectedSom]: data)
{
DataStream stream(inStr);
ASSERT_EQ(stream.getSopMarkerPos(), expectedSop);
ASSERT_EQ(stream.getSomMarkerPos(), expectedSom);
}
}
TEST(Day6Answer1, StartOfPacketMarkerPos) {
const std::filesystem::path dir = INPUTS_DIR;
std::ifstream inFile{dir / "input_day_6.txt"};
ASSERT_TRUE(inFile);
ASSERT_TRUE(inFile.is_open());
std::ostringstream buffer;
buffer << inFile.rdbuf();
std::string str{buffer.str()};
DataStream ds(str);
auto sop = ds.getSopMarkerPos();
std::cout << "[ DAY 6 ] Start of packet marker pos = " << sop << std::endl;
ASSERT_EQ(sop, 1833);
}
TEST(Day6Answer2, StartOfMessageMarkerPos) {
const std::filesystem::path dir = INPUTS_DIR;
std::ifstream inFile{dir / "input_day_6.txt"};
ASSERT_TRUE(inFile);
ASSERT_TRUE(inFile.is_open());
std::ostringstream buffer;
buffer << inFile.rdbuf();
std::string str{buffer.str()};
DataStream ds(str);
auto som = ds.getSomMarkerPos();
std::cout << "[ DAY 6 ] Start of message marker pos = " << som << std::endl;
ASSERT_EQ(som, 3425);
}
}