#![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_2d_io_test() {
{
let path_expected = "tests/data/expected_pc_2d_save1.csv";
let path_tmp = "tests/tmp/pc_2d_save1.tmp";
let mut pc = PointCloud2D::<Point2D>::new();
for i in 0..10 {
let p = Point2D::new(0.1 * i as f64, 0.2 * i as f64);
pc.push(p);
}
if GENERATE_EXCEPTED_RESULT_FILES {
save_xy(&mut File::create(&path_expected).unwrap(), &pc, ";", "\n").unwrap();
}
save_xy(&mut File::create(&path_tmp).unwrap(), &pc, ";", "\n").unwrap();
assert_files_equal(path_expected, path_tmp);
}
{
let mut pc = PointCloud2D::<Point2D>::new();
load_xy(
&mut BufReader::new(File::open("tests/data/test_square.xy").unwrap()),
&mut pc,
)
.unwrap();
assert!(pc.len() == 20 * 20);
}
}