summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2017-09-02 15:00:17 +0200
committerMatthias Beyer <mail@beyermatthias.de>2017-09-02 15:01:21 +0200
commit44eef9d89190e269ab9dabe65bd13577ec8a1e2a (patch)
treef2f6df6996adf13c0261c189d067d24d550f495c
parentcc389194172e30703902a6af7e86b2ce67c0a673 (diff)
Add test for adding multiple times
-rw-r--r--src/lib.rs2
-rw-r--r--src/timetype.rs23
2 files changed, 25 insertions, 0 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 1b9f0d7..f923136 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -2,4 +2,6 @@
extern crate chrono;
pub mod timetype;
+pub mod error;
+pub mod result;
diff --git a/src/timetype.rs b/src/timetype.rs
index 21c80a2..3c676ae 100644
--- a/src/timetype.rs
+++ b/src/timetype.rs
@@ -6,6 +6,7 @@ use chrono::NaiveDateTime;
use std::ops::Add;
/// A Type of Time, currently based on chrono::NaiveDateTime
+#[derive(Debug)]
pub enum TimeType {
Seconds(usize),
Minutes(usize),
@@ -52,5 +53,27 @@ mod tests {
}
}
+ #[test]
+ fn test_addition_of_seconds_multiple() {
+ let a = TT::Seconds(0);
+ let b = TT::Seconds(1);
+ let c = TT::Seconds(2);
+
+ let d = a + b + c;
+
+ match d {
+ TT::Addition(a, b) => {
+ match (*a, *b) {
+ (TT::Addition(c, d), TT::Seconds(2)) => match (*c, *d) {
+ (TT::Seconds(0), TT::Seconds(1)) => assert!(true),
+ _ => assert!(false, "Addition failed"),
+ },
+ (a, b) => assert!(false, "Addition failed: \n a = {:?}\n b = {:?}", a, b),
+ }
+ }
+ _ => assert!(false, "Addition failed, returned non-Addition type"),
+ }
+ }
+
}