lights: moving another doctest to unit
This commit is contained in:
parent
9006671a26
commit
1c2caf2cc5
@ -13,21 +13,6 @@ pub struct PointLight {
|
|||||||
impl PointLight {
|
impl PointLight {
|
||||||
/// Creates a new `PositionLight` at the given `position` and with the given
|
/// Creates a new `PositionLight` at the given `position` and with the given
|
||||||
/// `intensity`.
|
/// `intensity`.
|
||||||
///
|
|
||||||
/// # Examples
|
|
||||||
/// ```
|
|
||||||
/// use rtchallenge::{
|
|
||||||
/// lights::PointLight,
|
|
||||||
/// tuples::{Color, Tuple},
|
|
||||||
/// WHITE,
|
|
||||||
/// };
|
|
||||||
///
|
|
||||||
/// let intensity = WHITE;
|
|
||||||
/// let position = Tuple::point(0., 0., 0.);
|
|
||||||
/// let light = PointLight::new(position, intensity);
|
|
||||||
/// assert_eq!(light.position, position);
|
|
||||||
/// assert_eq!(light.intensity, intensity);
|
|
||||||
/// ```
|
|
||||||
pub fn new<C>(position: Tuple, intensity: C) -> PointLight
|
pub fn new<C>(position: Tuple, intensity: C) -> PointLight
|
||||||
where
|
where
|
||||||
C: Into<Color>,
|
C: Into<Color>,
|
||||||
@ -38,3 +23,17 @@ impl PointLight {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use crate::{lights::PointLight, tuples::point, WHITE};
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn new() {
|
||||||
|
let intensity = WHITE;
|
||||||
|
let position = point(0., 0., 0.);
|
||||||
|
let light = PointLight::new(position, intensity);
|
||||||
|
assert_eq!(light.position, position);
|
||||||
|
assert_eq!(light.intensity, intensity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user