From 6794104cc456bd86a802acd82cf6651e51ed953a Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sun, 19 Nov 2017 13:56:34 +0100 Subject: Fix: Offset problem The core iterator did not yield the base on the first iteration. This is fixed with this commit, using a flag to check whether it already yielded the base and if, start incrementing. Not a clean solution, but a working one. --- src/parser.rs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'src/parser.rs') diff --git a/src/parser.rs b/src/parser.rs index 723f4f3..5d518f5 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -785,7 +785,7 @@ mod tests { assert!(ui.is_ok(), "Not okay: {:#?}", ui); let mut ui = ui.unwrap(); - for hour in 1..10 { // 10 is randomly chosen (fair dice roll... ) + for hour in 0..10 { // 10 is randomly chosen (fair dice roll... ) let n = ui.next().unwrap(); assert!(n.is_ok(), "Not ok: {:#?}", n); let tt = n.unwrap(); @@ -809,7 +809,7 @@ mod tests { assert!(ui.is_ok(), "Not okay: {:#?}", ui); let mut ui = ui.unwrap(); - for min in (1..60).into_iter().filter(|n| n % 2 == 0) { + for min in (0..59).into_iter().filter(|n| n % 2 == 0) { let n = ui.next().unwrap(); assert!(n.is_ok(), "Not ok: {:#?}", n); let tt = n.unwrap(); @@ -833,7 +833,7 @@ mod tests { assert!(ui.is_ok(), "Not okay: {:#?}", ui); let mut ui = ui.unwrap(); - for day in 2..30 { + for day in 1..29 { let n = ui.next().unwrap(); assert!(n.is_ok(), "Not ok: {:#?}", n); let tt = n.unwrap(); @@ -857,7 +857,7 @@ mod tests { assert!(ui.is_ok(), "Not okay: {:#?}", ui); let mut ui = ui.unwrap(); - for week in 1..3 { + for week in 0..3 { let n = ui.next().unwrap(); assert!(n.is_ok(), "Not ok: {:#?}", n); let tt = n.unwrap(); @@ -890,8 +890,8 @@ mod tests { let mut ui = ui.unwrap(); println!("Okay: {:#?}", ui); - for hour in 1..10 { // 10 is randomly chosen (fair dice roll... ) - if hour > 5 - 1 { + for hour in 0..10 { // 10 is randomly chosen (fair dice roll... ) + if hour > 4 { let n = ui.next(); assert!(n.is_none(), "Is Some, should be None: {:?}", n); return; @@ -920,8 +920,8 @@ mod tests { assert!(ui.is_ok(), "Not okay: {:#?}", ui); let mut ui = ui.unwrap(); - for min in (1..60).into_iter().filter(|n| n % 2 == 0) { - if min > 10 - 1 { + for min in (0..60).into_iter().filter(|n| n % 2 == 0) { + if min > 9 { let n = ui.next(); assert!(n.is_none(), "Is Some, should be None: {:?}", n); return; @@ -950,8 +950,8 @@ mod tests { assert!(ui.is_ok(), "Not okay: {:#?}", ui); let mut ui = ui.unwrap(); - for day in 2..30 { - if day > 5 - 1 { + for day in 1..30 { + if day > 4 { let n = ui.next(); assert!(n.is_none(), "Is Some, should be None: {:?}", n); return; @@ -980,8 +980,8 @@ mod tests { assert!(ui.is_ok(), "Not okay: {:#?}", ui); let mut ui = ui.unwrap(); - for week in 1..3 { - if (week * 7 + 1) > 14 { + for week in 0..3 { + if (week * 7) > 13 { let n = ui.next(); assert!(n.is_none(), "Is Some, should be None: {:?}", n); return; -- cgit v1.2.3