summary refs log tree commit diff homepage
path: root/src
diff options
context:
space:
mode:
authorJune McEnroe <programble@gmail.com>2016-12-03 23:20:01 -0500
committerJune McEnroe <programble@gmail.com>2016-12-03 23:20:01 -0500
commit5c62892fbd2393036d3380c874eef59384ea3641 (patch)
tree26dbb86d4f0d9b06501bc4e1f9cd2d0f1f9252cc /src
parentAdd tests to day 1 (diff)
downloadaoc-5c62892fbd2393036d3380c874eef59384ea3641.tar.gz
aoc-5c62892fbd2393036d3380c874eef59384ea3641.zip
Add test to day 2
Diffstat (limited to 'src')
-rw-r--r--src/bin/day02.rs22
1 files changed, 16 insertions, 6 deletions
diff --git a/src/bin/day02.rs b/src/bin/day02.rs
index c5a7f11..21d101b 100644
--- a/src/bin/day02.rs
+++ b/src/bin/day02.rs
@@ -1,6 +1,6 @@
 use std::io::{self, Read};
 
-#[derive(Debug, Clone, Copy)]
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
 enum Keypad {
     K1, K2, K3,
     K4, K5, K6,
@@ -47,10 +47,7 @@ impl Keypad {
     }
 }
 
-fn main() {
-    let mut input = String::new();
-    io::stdin().read_to_string(&mut input).unwrap();
-
+fn solve(input: &str) -> Vec<Keypad> {
     let mut code = Vec::new();
     let mut key = Keypad::K5;
 
@@ -67,5 +64,18 @@ fn main() {
         code.push(key);
     }
 
-    println!("Part 1: {:?}", code);
+    code
+}
+
+fn main() {
+    let mut input = String::new();
+    io::stdin().read_to_string(&mut input).unwrap();
+
+    println!("Part 1: {:?}", solve(&input));
+}
+
+#[test]
+fn part1() {
+    use Keypad::*;
+    assert_eq!(vec![K1, K9, K8, K5], solve("ULL\nRRDDD\nLURDL\nUUUUD"));
 }