diff --git a/src/collections.rs b/src/collections.rs deleted file mode 100644 index a79f86f..0000000 --- a/src/collections.rs +++ /dev/null @@ -1,4 +0,0 @@ - -fn hello_world(){ - -} \ No newline at end of file diff --git a/src/iterate.rs b/src/iterate.rs new file mode 100644 index 0000000..6555c3a --- /dev/null +++ b/src/iterate.rs @@ -0,0 +1,25 @@ + +mod iterate { + struct Counter { + count: u32, + } + + impl Counter { + fn new() -> Counter { + Counter { count: 0 } + } + } + + impl Iterator for Counter { + type Item = u32; + + fn next(&mut self) -> Option { + if self.count < 5 { + self.count += 1; + Some(self.count) + } else { + None + } + } + } +} \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index cf7d1d7..eb5e2ab 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,7 +2,7 @@ use std::io; use std::cmp::Ordering; use rand::Rng; -mod collections; +mod iterate; fn main() { basics(); @@ -178,4 +178,14 @@ fn nullables() { let _some_string = Some("a string"); let _absent_number: Option = None; +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test1() { + assert_eq!(2, 1 + 1); + } } \ No newline at end of file diff --git a/tests/add_tests.rs b/tests/add_tests.rs new file mode 100644 index 0000000..1cd5940 --- /dev/null +++ b/tests/add_tests.rs @@ -0,0 +1,7 @@ +mod scaffold; + +#[test] +fn add_test_1() { + scaffold::setup(); + assert_eq!(4, 2 + 2); +} \ No newline at end of file diff --git a/tests/scaffold/mod.rs b/tests/scaffold/mod.rs new file mode 100644 index 0000000..251919d --- /dev/null +++ b/tests/scaffold/mod.rs @@ -0,0 +1,4 @@ + +pub fn setup() { + println!("During test"); +} \ No newline at end of file