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