From 02688030cb7b1de5c63732b8b820017391bfd2a0 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Wed, 6 Apr 2016 01:12:58 -0400 Subject: Add a couple tests for `build_alias` Create a new `tests` module. This lives in its own file. Not sure if this is idiomatic Rust, but I prefer the idea of my tests living in a different file from my code. This module gets included in `main.rs`. We `use` `build_alias` directly because it's currently a private function, so doing `use super::*` didn't import it. Not sure if I should be making it a public function in order to mitigate this. Add a couple of variant test cases to check the string transformation that this function should be doing. --- src/main.rs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index 3e4a343..92ea8e1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,8 @@ use std::io::{self, BufRead}; +#[cfg(test)] +mod tests; + fn handle_alias(s: &str) { let alias = build_alias(s); } -- cgit v1.2.3