get third test passing

This commit is contained in:
2024-10-27 21:18:59 +01:00
parent 76d0bd9f91
commit 1192350b3c

View File

@@ -9,11 +9,11 @@ pub struct TurningFunction {
}
impl TurningFunction {
pub fn new(trajectory: f32) -> Self {
pub fn new() -> Self {
TurningFunction {
steps: Vec::new(),
turns: Vec::new(),
trajectory,
trajectory: 0.0,
}
}
@@ -97,30 +97,29 @@ mod tests {
assert_relative_eq!(2.8, euclidean_distance(&p1, &p2), epsilon = 0.1);
}
// #[test]
// fn test_path_generator() {
// let from = [0.0, 0.0];
// let tf = TurningFunction::new(0.0);
// let to = [1.5, 2.3];
#[test]
fn test_path_generator() {
let from = [0.0, 0.0];
let mut tf = TurningFunction::new();
let to = [1.5, 2.3];
// let pg = PathGenerator {
// from,
// turning_function: tf,
// to,
// };
tf.add_increment(1, 0.5);
tf.add_increment(2, -0.3);
// let path = pg.generate_path();
let pg = PathGenerator {
from,
turning_function: tf,
to,
};
// // Test that the generated path starts at the "from" point
// assert_eq!(path.iter().first(), Some(&point(from[0], from[1])));
// // Test that the generated path ends at the "to" point
// assert_eq!(path.iter().last(), Some(&point(to[0], to[1])));
// }
let path = pg.generate_path();
let (first_endpoint, _) = path.first_endpoint().unwrap();
assert_eq!(first_endpoint, pg.from.into());
}
#[test]
fn test_turning_function_to_coords() {
let mut tf = TurningFunction::new(0.0);
let mut tf = TurningFunction::new();
tf.add_increment(1, 0.5);
tf.add_increment(2, -0.3);
let coords = tf.to_coordinates();