use cucoqu::cu2qu::CurvesToQuadratic; use cucoqu::point; use cucoqu::Cubic; use cucoqu::Point; use cucoqu::Quad; fn expected_result() -> [[Quad; 5]; 4] { [ [ [point![50.0, 0.0], point![46.45721, 19.64031], point![39.897583, 30.799238]], [ point![39.897583, 30.799238], point![39.897583, 30.799238], point![30.799238, 39.897575], ], [ point![30.799238, 39.897575], point![30.799238, 39.897575], point![19.640306, 46.457207], ], [point![19.640306, 46.457207], point![19.640306, 46.457207], point![6.898932, 50.0]], [point![6.898932, 50.0], point![6.898932, 50.0], point![0.0, 50.0]], ], [ [point![0.0, 50.0], point![-19.64031, 46.45721], point![-30.799238, 39.897583]], [ point![-30.799238, 39.897583], point![-30.799238, 39.897583], point![-39.897575, 30.799238], ], [ point![-39.897575, 30.799238], point![-39.897575, 30.799238], point![-46.457207, 19.640306], ], [ point![-46.457207, 19.640306], point![-46.457207, 19.640306], point![-50.0, 6.898932], ], [point![-50.0, 6.898932], point![-50.0, 6.898932], point![-50.0, 0.0]], ], [ [point![-50.0, 0.0], point![-46.45721, -19.64031], point![-39.897583, -30.799238]], [ point![-39.897583, -30.799238], point![-39.897583, -30.799238], point![-30.799238, -39.897575], ], [ point![-30.799238, -39.897575], point![-30.799238, -39.897575], point![-19.640306, -46.457207], ], [ point![-19.640306, -46.457207], point![-19.640306, -46.457207], point![-6.898932, -50.0], ], [point![-6.898932, -50.0], point![-6.898932, -50.0], point![-0.0, -50.0]], ], [ [point![-0.0, -50.0], point![19.64031, -46.45721], point![30.799238, -39.897583]], [ point![30.799238, -39.897583], point![30.799238, -39.897583], point![39.897575, -30.799238], ], [ point![39.897575, -30.799238], point![39.897575, -30.799238], point![46.457207, -19.640306], ], [ point![46.457207, -19.640306], point![46.457207, -19.640306], point![50.0, -6.898932], ], [point![50.0, -6.898932], point![50.0, -6.898932], point![50.0, 0.0]], ], ] } #[test] fn test_convert() { static TEST_DATA: &[Cubic] = &[ [ point![50.0, 0.0], point![50.0, 27.5957512247], point![27.5957512247, 50.0], point![0.0, 50.0], ], [ point![0.0, 50.0], point![-27.5957512247, 50.0], point![-50.0, 27.5957512247], point![-50.0, 0.0], ], [ point![-50.0, 0.0], point![-50.0, -27.5957512247], point![-27.5957512247, -50.0], point![-0.0, -50.0], ], [ point![-0.0, -50.0], point![27.5957512247, -50.0], point![50.0, -27.5957512247], point![50.0, 0.0], ], ]; let output = TEST_DATA.to_vec(); let output = output.curves_to_quadratic(vec![0.001; 4]).unwrap(); //eprintln!("{:?}", &output); assert_eq!(&output, &expected_result()); }