Skip to content

Instantly share code, notes, and snippets.

@HappyCerberus
Created December 1, 2021 11:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save HappyCerberus/633e7bdd2e2674c57a02c9d8f13e4277 to your computer and use it in GitHub Desktop.
Save HappyCerberus/633e7bdd2e2674c57a02c9d8f13e4277 to your computer and use it in GitHub Desktop.
AOC 2021 - test day1 part1
#include "trivial.h"
#include <gtest/gtest.h>
#include <sstream>
TEST(TrivialTest, Simple) {
std::vector<std::pair<std::string, uint32_t>> inputs = {
{"", 0}, // empty input 0 increasing
{"0", 0}, // single element 0 increasing
{"0 1", 1}, // two elements, with increase
{"0 1 0 1 0 1 0 1", 4}, // alternating, 4 repetitions
{"0 0 0 0 0 0", 0}, // monotonic, no increase
{"0 1 2 3", 3}, // increasing sequence - 3 increases
{"3 2 1 0", 0}, // decreasing sequence - 0 increases
};
for (auto &i : inputs) {
std::stringstream s(i.first);
EXPECT_EQ(count_increasing(s), i.second) << " on input " << i.first;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment