diff --git a/.drone-ci.yml b/.drone-ci.yml new file mode 100644 index 0000000..1c679d7 --- /dev/null +++ b/.drone-ci.yml @@ -0,0 +1,10 @@ +kind: pipeline +type: kubernetes +name: default + +steps: + - name: test + image: rust:1.56 + commands: + - cargo build --verbose --all + - cargo test --verbose --all diff --git a/input/day1 b/input/day01 similarity index 100% rename from input/day1 rename to input/day01 diff --git a/src/day1.rs b/src/day01.rs similarity index 78% rename from src/day1.rs rename to src/day01.rs index 8e61700..9367924 100644 --- a/src/day1.rs +++ b/src/day01.rs @@ -1,9 +1,7 @@ -use std::fs::read_to_string; - #[derive(Eq, PartialEq, Ord, PartialOrd, Clone)] -pub struct Day1(Vec); +pub struct Day01(Vec); -impl crate::day::Day for Day1 { +impl crate::day::Day for Day01 { fn init(f: String) -> Self { let v = f.split('\n').map(|x| x.parse::().unwrap()).collect::>(); Self(v) @@ -36,20 +34,20 @@ fn increments((a, b): (i32, i32), c: &i32) -> (i32, i32) { #[cfg(test)] pub mod tests { use std::fs::read_to_string; - use super::Day1; + use super::Day01; use crate::day::Day; #[test] pub fn part1_real() { - let f = read_to_string("./input/day1").expect("Could not load input"); - let d = Day1::init(f); + let f = read_to_string("./input/day01").expect("Could not load input"); + let d = Day01::init(f); assert_eq!("1466", d.part1()) } #[test] pub fn part2_real() { - let f = read_to_string("./input/day1").expect("Could not load input"); - let d = Day1::init(f); + let f = read_to_string("./input/day01").expect("Could not load input"); + let d = Day01::init(f); assert_eq!("1491", d.part2()) } @@ -57,7 +55,7 @@ pub mod tests { pub fn part1_test() { let v = vec![199, 200, 208, 210, 200, 207, 240, 269, 260, 263]; let strs = v.iter().map(i32::to_string).collect::>().join("\n"); - let d = Day1::init(strs); + let d = Day01::init(strs); assert_eq!("7", d.part1()) } @@ -65,7 +63,7 @@ pub mod tests { pub fn part2_test() { let v = vec![199, 200, 208, 210, 200, 207, 240, 269, 260, 263]; let strs = v.iter().map(i32::to_string).collect::>().join("\n"); - let d = Day1::init(strs); + let d = Day01::init(strs); assert_eq!("5", d.part2()) } } \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 6bcd23b..24e676e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,12 +1,11 @@ use std::fs::read_to_string; -use std::time::SystemTime; use chrono::Datelike; -use clap::{App, Arg, SubCommand}; -use crate::day1::Day1; +use clap::{App, Arg}; +use crate::day01::Day01; use crate::day::Day; mod day; -mod day1; +mod day01; fn load_input(day: &str) -> String { read_to_string(format!("./input/day{}", day)).expect("Could not load input") @@ -41,9 +40,9 @@ fn main() { .multiple(true)) .get_matches(); - let days: Vec> = vec![Box::new(Day1::init(load_input("1")))]; + let days: Vec> = vec![Box::new(Day01::init(load_input("01")))]; - let verbosity = matches.occurrences_of("v"); + let _verbosity = matches.occurrences_of("v"); if matches.is_present("all") { let l = days.len(); println!("running {} days!", l);