Skip to content

Commit af77ec9

Browse files
committed
Add simple unit test for math::clamp
1 parent 030ca78 commit af77ec9

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/math.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,3 +147,20 @@ pub fn rand_angle_spread_deg(angle: f32, half_angle_spread: f32) -> f32 {
147147

148148
angle + s
149149
}
150+
151+
#[cfg(test)]
152+
mod tests {
153+
use super::*;
154+
155+
#[test]
156+
fn test_clamp() {
157+
let mut result = clamp(1.2, 1.0, 2.0);
158+
assert!(result == 1.2);
159+
160+
result = clamp(2.5, 1.0, 2.0);
161+
assert!(result == 2.0);
162+
163+
result = clamp(0.8, 1.0, 2.0);
164+
assert!(result == 1.0);
165+
}
166+
}

0 commit comments

Comments
 (0)