cargo fmt

This commit is contained in:
2022-05-03 23:12:34 +02:00
parent a2bbd1d431
commit bdb6e60e98
+100 -22
View File
@@ -30,7 +30,14 @@ impl Population {
height: i32,
plague: Disease,
) -> Self {
let mut the_humans: Vec<Human> = vec![Human{x: 0, y: 0, present_state: State::Normal}; (width * height) as usize];
let mut the_humans: Vec<Human> = vec![
Human {
x: 0,
y: 0,
present_state: State::Normal
};
(width * height) as usize
];
for x in 0..width {
for y in 0..height {
let idx = human_idx(x, y, width);
@@ -116,7 +123,7 @@ impl Population {
stats[0] += 1;
}
State::Infected => {
people_to_check.push(Point{ x: h.x, y: h.y });
people_to_check.push(Point { x: h.x, y: h.y });
stats[1] += 1;
}
State::Immune => {
@@ -345,7 +352,7 @@ mod tests {
let mut stats: Stats;
for _ in 0..10 {
humans.push(Human{
humans.push(Human {
present_state: State::Normal,
x: 0,
y: 0,
@@ -388,7 +395,6 @@ mod tests {
assert_eq!(population.humans[idx].y, h.y, "coordinates should match");
}
assert_eq!(population.humans.len(), (width * height) as usize);
}
#[test]
@@ -505,15 +511,51 @@ mod tests {
// start with normal population
population.humans = vec![
Human{present_state: State::Normal, x: 0, y: 0},
Human{present_state: State::Normal, x: 1, y: 0},
Human{present_state: State::Normal, x: 2, y: 0},
Human{present_state: State::Normal, x: 0, y: 1},
Human{present_state: State::Infected, x: 1, y: 1},
Human{present_state: State::Normal, x: 2, y: 1},
Human{present_state: State::Normal, x: 0, y: 2},
Human{present_state: State::Normal, x: 1, y: 2},
Human{present_state: State::Normal, x: 2, y: 2},
Human {
present_state: State::Normal,
x: 0,
y: 0,
},
Human {
present_state: State::Normal,
x: 1,
y: 0,
},
Human {
present_state: State::Normal,
x: 2,
y: 0,
},
Human {
present_state: State::Normal,
x: 0,
y: 1,
},
Human {
present_state: State::Infected,
x: 1,
y: 1,
},
Human {
present_state: State::Normal,
x: 2,
y: 1,
},
Human {
present_state: State::Normal,
x: 0,
y: 2,
},
Human {
present_state: State::Normal,
x: 1,
y: 2,
},
Human {
present_state: State::Normal,
x: 2,
y: 2,
},
];
stats = humans_stats(&population.humans);
println!("stats after init: {:?}", stats);
@@ -550,15 +592,51 @@ mod tests {
// start with normal population
population.humans = vec![
Human{present_state: State::Normal, x: 0, y: 0},
Human{present_state: State::Normal, x: 1, y: 0},
Human{present_state: State::Normal, x: 2, y: 0},
Human{present_state: State::Normal, x: 0, y: 1},
Human{present_state: State::Infected, x: 1, y: 1},
Human{present_state: State::Normal, x: 2, y: 1},
Human{present_state: State::Normal, x: 0, y: 2},
Human{present_state: State::Normal, x: 1, y: 2},
Human{present_state: State::Normal, x: 2, y: 2},
Human {
present_state: State::Normal,
x: 0,
y: 0,
},
Human {
present_state: State::Normal,
x: 1,
y: 0,
},
Human {
present_state: State::Normal,
x: 2,
y: 0,
},
Human {
present_state: State::Normal,
x: 0,
y: 1,
},
Human {
present_state: State::Infected,
x: 1,
y: 1,
},
Human {
present_state: State::Normal,
x: 2,
y: 1,
},
Human {
present_state: State::Normal,
x: 0,
y: 2,
},
Human {
present_state: State::Normal,
x: 1,
y: 2,
},
Human {
present_state: State::Normal,
x: 2,
y: 2,
},
];
stats = humans_stats(&population.humans);
println!("stats after init: {:?}", stats);