-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTest_day_8.cpp
More file actions
74 lines (56 loc) · 1.71 KB
/
Test_day_8.cpp
File metadata and controls
74 lines (56 loc) · 1.71 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
67
68
69
70
71
72
73
74
//
// Created by Ryan Avery on 12/6/2022.
//
#include <gtest/gtest.h>
#include <fstream>
#include <filesystem>
#include "day_8.h"
namespace Day8 {
std::string testInput = R"(30373
25512
65332
33549
35390)";
class TestDay8 : public ::testing::Test {
public:
TestDay8() : tv(testInput) {}
TreeViewer tv;
};
TEST_F(TestDay8, GetVisibleTrees) {
auto visible = tv.numVisibleTrees();
ASSERT_EQ(visible, 21);
}
TEST_F(TestDay8, GetScenicScore) {
ASSERT_EQ(tv.getScenicScore({1, 2}), 4);
ASSERT_EQ(tv.getScenicScore({3, 2}), 8);
}
TEST_F(TestDay8, GetHighestScenicScore) {
ASSERT_EQ(tv.getHighestScenicScore(), 8);
}
TEST(Day8Answer1, GetVisibleTrees) {
const std::filesystem::path dir = INPUTS_DIR;
std::ifstream inFile{dir / "input_day_8.txt"};
ASSERT_TRUE(inFile);
ASSERT_TRUE(inFile.is_open());
std::ostringstream buffer;
buffer << inFile.rdbuf();
std::string str{buffer.str()};
TreeViewer tv(str);
int num = tv.numVisibleTrees();
std::cout << "[ DAY 8 ] Visible trees = " << num << std::endl;
ASSERT_EQ(num, 1859);
}
TEST(Day8Answer2, GetHighestScenicScore) {
const std::filesystem::path dir = INPUTS_DIR;
std::ifstream inFile{dir / "input_day_8.txt"};
ASSERT_TRUE(inFile);
ASSERT_TRUE(inFile.is_open());
std::ostringstream buffer;
buffer << inFile.rdbuf();
std::string str{buffer.str()};
TreeViewer tv(str);
int num = tv.getHighestScenicScore();
std::cout << "[ DAY 8 ] Highest scenic score = " << num << std::endl;
ASSERT_EQ(num, 332640);
}
}