summaryrefslogtreecommitdiffstats
path: root/src/parser.rs
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2017-11-19 13:56:34 +0100
committerMatthias Beyer <mail@beyermatthias.de>2017-11-19 14:46:25 +0100
commit6794104cc456bd86a802acd82cf6651e51ed953a (patch)
tree927c0954108c1d1ce7985f30e12122da6ff8b802 /src/parser.rs
parent27d98f1416b879438e185368c7a1e42d1162338d (diff)
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.
Diffstat (limited to 'src/parser.rs')
-rw-r--r--src/parser.rs24
1 files changed, 12 insertions, 12 deletions
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;