Use WHITE and BLACK constants where appropriate

This commit is contained in:
2021-07-17 16:41:22 -07:00
parent b37398ac40
commit 9f00485256
6 changed files with 26 additions and 25 deletions

View File

@@ -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);
}
}