Use WHITE and BLACK constants where appropriate
This commit is contained in:
@@ -74,17 +74,16 @@ impl Canvas {
|
||||
mod tests {
|
||||
use super::Canvas;
|
||||
|
||||
use crate::tuples::Color;
|
||||
use crate::{tuples::Color, BLACK};
|
||||
|
||||
#[test]
|
||||
fn create_canvas() {
|
||||
let bg = Color::new(0.0, 0.0, 0.0);
|
||||
let bg = BLACK;
|
||||
let c = Canvas::new(10, 20, bg);
|
||||
assert_eq!(c.width, 10);
|
||||
assert_eq!(c.height, 20);
|
||||
let black = Color::new(0., 0., 0.);
|
||||
for (i, p) in c.pixels.iter().enumerate() {
|
||||
assert_eq!(p, &black, "pixel {} not {:?}: {:?}", i, &black, p);
|
||||
assert_eq!(p, &BLACK, "pixel {} not {:?}: {:?}", i, &BLACK, p);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user