use crate::tests::toolkit::{generic_rinex_comparison, random_name};
use crate::*;
use std::path::Path;
fn testbench(path: &str) {
println!("Parsing model \"{}\"", path);
let model = if path.ends_with(".gz") {
Rinex::from_gzip_file(path)
} else {
Rinex::from_file(path)
};
let model = model.unwrap();
let tmp_path = format!("test-{}.rnx", random_name(5));
model.to_file(&tmp_path).unwrap();
let dut = Rinex::from_file(&tmp_path).unwrap();
generic_rinex_comparison(&dut, &model);
println!("Formatting test passed for \"{}\"", path);
let _ = std::fs::remove_file(tmp_path);
}
#[test]
fn obs_v2() {
let prefix = Path::new(env!("CARGO_MANIFEST_DIR"))
.join("data")
.join("OBS")
.join("V2");
for file in [
"AJAC3550.21O",
"aopr0010.17o",
"barq071q.19o",
"delf0010.21o",
"npaz3550.21o",
"rovn0010.21o",
"wsra0010.21o",
"zegv0010.21o",
] {
let path = prefix.to_path_buf().join(file);
let fullpath = path.to_string_lossy();
testbench(fullpath.as_ref());
}
}
#[test]
fn obs_v3() {
let folder = env!("CARGO_MANIFEST_DIR").to_owned() + "/data/OBS/V3/";
for file in std::fs::read_dir(folder).unwrap() {
let fp = file.unwrap();
let fp = fp.path();
let fp_str = fp.to_string_lossy().to_string();
if fp_str.ends_with("240506_glacier_station.obs.gz") {
continue;
}
if fp_str.ends_with("gps_10MSps.23O.gz") {
continue;
}
if fp_str.ends_with("GEOP092I.24o.gz") {
continue;
}
if fp_str.ends_with("gps.23O.gz") {
continue;
}
testbench(fp.to_str().unwrap());
}
}
#[test]
fn meteo_v2() {
let folder = env!("CARGO_MANIFEST_DIR").to_owned() + "/data/MET/V2/";
for file in std::fs::read_dir(folder).unwrap() {
let fp = file.unwrap();
let fp = fp.path();
testbench(fp.to_str().unwrap());
}
}
#[test]
fn meteo_v3() {
let folder = env!("CARGO_MANIFEST_DIR").to_owned() + "/data/MET/V3/";
for file in std::fs::read_dir(folder).unwrap() {
let fp = file.unwrap();
let fp = fp.path();
testbench(fp.to_str().unwrap());
}
}
#[test]
fn meteo_v4() {
let folder = env!("CARGO_MANIFEST_DIR").to_owned() + "/data/MET/V4/";
for file in std::fs::read_dir(folder).unwrap() {
let fp = file.unwrap();
let fp = fp.path();
testbench(fp.to_str().unwrap());
}
}
#[test]
#[ignore]
fn clocks_v2() {
let folder = env!("CARGO_MANIFEST_DIR").to_owned() + "/data/CLK/V2/";
for file in std::fs::read_dir(folder).unwrap() {
let fp = file.unwrap();
let fp = fp.path();
testbench(fp.to_str().unwrap());
}
}
#[test]
fn nav_v2() {
let folder = env!("CARGO_MANIFEST_DIR").to_owned() + "/data/NAV/V2/";
for file in std::fs::read_dir(folder).unwrap() {
let fp = file.unwrap();
let fp = fp.path();
testbench(fp.to_str().unwrap());
}
}
#[test]
fn nav_v3() {
let folder = env!("CARGO_MANIFEST_DIR").to_owned() + "/data/NAV/V3/";
for file in std::fs::read_dir(folder).unwrap() {
let fp = file.unwrap();
let fp = fp.path();
testbench(fp.to_str().unwrap());
}
}
#[test]
#[ignore]
fn nav_v4() {
let folder = env!("CARGO_MANIFEST_DIR").to_owned() + "/data/NAV/V4/";
for file in std::fs::read_dir(folder).unwrap() {
let fp = file.unwrap();
let fp = fp.path();
testbench(fp.to_str().unwrap());
}
}