forked from Maxluli/RustyPropagation
move asserts to tests
This commit is contained in:
+8
-6
@@ -38,12 +38,6 @@ impl Population {
|
|||||||
the_humans[idx].y = y;
|
the_humans[idx].y = y;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for h in the_humans.iter() {
|
|
||||||
let idx = human_idx(h.x, h.y, width);
|
|
||||||
assert_eq!(the_humans[idx].x, h.x);
|
|
||||||
assert_eq!(the_humans[idx].y, h.y);
|
|
||||||
}
|
|
||||||
assert_eq!(the_humans.len(), (width * height) as usize);
|
|
||||||
Self {
|
Self {
|
||||||
start_infected_ratio: start_infected_ratio,
|
start_infected_ratio: start_infected_ratio,
|
||||||
start_immune_ratio: start_immune_ratio,
|
start_immune_ratio: start_immune_ratio,
|
||||||
@@ -373,6 +367,7 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn population_new() {
|
fn population_new() {
|
||||||
let disease = Disease::new(20, 10, 5, String::from("Covid 44"));
|
let disease = Disease::new(20, 10, 5, String::from("Covid 44"));
|
||||||
|
let (width, height) = (5, 7);
|
||||||
let population = Population::new(20, 10, 5, 5, 7, disease);
|
let population = Population::new(20, 10, 5, 5, 7, disease);
|
||||||
assert_eq!(population.humans.len(), 5 * 7);
|
assert_eq!(population.humans.len(), 5 * 7);
|
||||||
for human in population.humans.iter() {
|
for human in population.humans.iter() {
|
||||||
@@ -381,6 +376,13 @@ mod tests {
|
|||||||
"all humans should be normal"
|
"all humans should be normal"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
for h in population.humans.iter() {
|
||||||
|
let idx = human_idx(h.x, h.y, width);
|
||||||
|
assert_eq!(population.humans[idx].x, h.x, "coordinates should match");
|
||||||
|
assert_eq!(population.humans[idx].y, h.y, "coordinates should match");
|
||||||
|
}
|
||||||
|
assert_eq!(population.humans.len(), (width * height) as usize);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|||||||
Reference in New Issue
Block a user