#![deny(warnings)]
use rust_3d::{io::*, test_helper::*, *};
use std::{fs::File, io::BufReader};
static GENERATE_EXCEPTED_RESULT_FILES: bool = false;
#[test]
fn point_cloud_3d_io_test() {
{
let path_expected = "tests/data/expected_pc_3d_save1.csv";
let path_tmp = "tests/tmp/pc_3d_save1.tmp";
let mut pc = PointCloud3D::<Point3D>::new();
for i in 0..10 {
let p = Point3D::new(0.1 * i as f64, 0.2 * i as f64, 0.3 * i as f64);
pc.push(p);
}
if GENERATE_EXCEPTED_RESULT_FILES {
save_xyz(&mut File::create(&path_expected).unwrap(), &pc, ";", "\n").unwrap();
}
save_xyz(&mut File::create(&path_tmp).unwrap(), &pc, ";", "\n").unwrap();
assert_files_equal(path_expected, path_tmp);
}
{
let mut pc = PointCloud3D::<Point3D>::new();
load_xyz(
&mut BufReader::new(File::open("tests/data/test_cube.xyz").unwrap()),
&mut pc,
)
.unwrap();
assert!(pc.len() == 20 * 20 * 20);
}
}