Skip to content

Commit 0cbe3b0

Browse files
committed
add boilerplate for tests + move template to a new file
1 parent 618531b commit 0cbe3b0

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

cargo-aoc/src/app.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ pub fn execute_credentials(args: &Credentials) {
4141
/// Executes the "input" subcommand of the app
4242
pub fn execute_input(args: &Input) -> Result<(), Box<dyn Error>> {
4343
// Gets the token or exit if it's not referenced.
44-
let token = CredentialsManager::new().get_session_token().expect(
45-
"Error: you need to setup your AOC token using \"cargo aoc credentials {token}\"",
46-
);
44+
let token = CredentialsManager::new()
45+
.get_session_token()
46+
.expect("Error: you need to setup your AOC token using \"cargo aoc credentials {token}\"");
4747

4848
let pm = ProjectManager::new()?;
4949

cargo-aoc/template/src/day.rs.tpl

+14-7
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,38 @@
11
use aoc_runner_derive::{aoc, aoc_generator};
2-
#[aoc_generator({DAY})]
2+
#[aoc_generator(REP)]
33
fn parse(input: &str) -> String {
44
todo!()
55
}
66

7-
#[aoc({DAY}, part1)]
7+
#[aoc(REP, part1)]
88
fn part1(input: &str) -> String {
99
todo!()
1010
}
1111

12-
#[aoc({DAY}, part2)]
12+
#[aoc(REP, part2)]
1313
fn part2(input: &str) -> String {
1414
todo!()
1515
}
1616

17-
1817
#[cfg(test)]
1918
mod tests {
2019
use super::*;
2120
2221
#[test]
2322
fn part1_example() {
24-
assert_eq!(part1(&parse("<EXAMPLE>")), "<RESULT>");
23+
let input = "";
24+
let output = "";
25+
26+
let input = parse(input);
27+
assert_eq!(part1(input), output);
2528
}
2629

2730
#[test]
2831
fn part2_example() {
29-
assert_eq!(part2(&parse("<EXAMPLE>")), "<RESULT>");
32+
let input = "";
33+
let output = "";
34+
35+
let input = parse(input);
36+
assert_eq!(part2(input), output);
3037
}
31-
}
38+
}

0 commit comments

Comments
 (0)