aboutsummaryrefslogtreecommitdiff
path: root/test/test_2015.cpp
blob: 2aef8809b5a1f0747f75170c8492fcf5aab759ac (plain)
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
#include "2015/day1/aoc.h"
#include "2015/day2/aoc.h"
#include "2015/day3/aoc.h"
#include "2015/day4/aoc.h"
#include "catch.hpp"
#include <stdio.h>

TEST_CASE("Not Quite Lisp", "[day1]") {
  line_view lv = load_file("../src/2015/day1/input");
  REQUIRE(aoc2015::day1(lv) == 74);
  REQUIRE(aoc2015::day1(lv, -1) == 1795);
}

TEST_CASE("parse box", "[day2]") {
  line_view lv1{"27x2x5\n", 7};
  auto b1 = aoc2015::parse_day2(lv1);
  auto a1 = b1.l == 27 && b1.w == 2 && b1.h == 5;
  REQUIRE(a1);
  line_view lv2{"29x13x26\n", 9};
  auto b2 = aoc2015::parse_day2(lv2);
  auto a2 = b2.l == 29 && b2.w == 13 && b2.h == 26;
  REQUIRE(a2);
}

TEST_CASE("I Was Told There Would Be No Math", "[day2]") {
  line_view lv = load_file("../src/2015/day2/input");
  auto p = aoc2015::day2(lv);
  REQUIRE(p.first == 1586300);
  REQUIRE(p.second == 3737498);
}

TEST_CASE("Perfectly Spherical Houses in a Vacuum", "[day3]") {
  line_view lv = load_file("../src/2015/day3/input");
  auto p = aoc2015::day3(lv);
  REQUIRE(p.first == 2565);
  REQUIRE(p.second == 2639);
}

TEST_CASE("The Ideal Stocking Stuffer", "[day4]") {
  char s[] = "abcdef609043";
  uint8_t* md5 = md5String(s);
  for (auto i = 0; i < 16; i++) {
    printf("%x", md5[i]);
  }
}