Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

only rinex-qc and cli need SP3 dependency #161

Merged
merged 2 commits into from
Sep 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion rinex/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ serde = { version = "1.0", optional = true, default-features = false, features =
flate2 = { version = "1.0.24", optional = true, default-features = false, features = ["zlib"] }
hifitime = { version = "3.8", features = ["serde", "std"] }
horrorshow = { version = "0.8", optional = true }
sp3 = { version = "1.0.0", optional = true, features = ["serde", "flate2"] }
rinex-qc-traits = { path = "../qc-traits", optional = true }

[dev-dependencies]
serde_json = "1"
criterion = "0.5"
rand = "0.8"

[[bench]]
name = "benchmark"
Expand Down
6 changes: 4 additions & 2 deletions rinex/src/tests/compression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,10 @@ mod test {
let rnx = rnx.unwrap();
let compressed = rnx.rnx2crnx1();

let tmp_path = format!("test-{}.crx", random_name(8));

assert!(
compressed.to_file("test.crx").is_ok(),
compressed.to_file(&tmp_path).is_ok(),
"{}{}",
"failed to format compressed rinex",
testfile
Expand All @@ -98,7 +100,7 @@ mod test {
);

// remove generated file
let _ = std::fs::remove_file("test.crx");
let _ = std::fs::remove_file(&tmp_path);
}
}
}
15 changes: 6 additions & 9 deletions rinex/src/tests/production.rs
Original file line number Diff line number Diff line change
@@ -1,24 +1,21 @@
#[cfg(test)]
mod test {
use crate::tests::toolkit::compare_with_panic;
use crate::tests::toolkit::{compare_with_panic, random_name};
use crate::*;
fn testbench(path: &str) {
// parse this file
let rnx = Rinex::from_file(path).unwrap(); // already tested elsewhere
let copy_path = path.to_owned() + "-copy";
assert_eq!(rnx.to_file(&copy_path).is_ok(), true); // test writer
let copy = Rinex::from_file(&copy_path);
let tmp_path = format!("test-{}.rnx", random_name(5));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assert_eq!(rnx.to_file(&tmp_path).is_ok(), true); // test writer
let copy = Rinex::from_file(&tmp_path);
assert_eq!(copy.is_ok(), true); // content should be valid
let copy = copy.unwrap();
// run comparison
if copy != rnx {
compare_with_panic(&copy, &rnx, path);
}
// remove copy not to disturb other test browsers
let _ = std::fs::remove_file(copy_path);
// sleep for a bit
// avoids this (temporary) file being picked up by other automated tests
// std::thread::sleep(std::time::Duration::from_secs(1));
// remove copy
let _ = std::fs::remove_file(tmp_path);
}
#[test]
fn obs_v2() {
Expand Down
11 changes: 11 additions & 0 deletions rinex/src/tests/toolkit.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
use crate::*;
use rand::{distributions::Alphanumeric, Rng};
/*
* Tool to generate random names when we need to produce a file
*/
pub fn random_name(size: usize) -> String {
rand::thread_rng()
.sample_iter(&Alphanumeric)
.take(size)
.map(char::from)
.collect()
}
/*
* OBS RINEX thorough comparison
*/
Expand Down