Skip to content
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 Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[workspace]
members = [
"swiftnav",
"swiftnav-sys"
# "swiftnav-sys"
]
1 change: 1 addition & 0 deletions swiftnav/src/coords/ecef.rs
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@ impl MulAssign<&f64> for ECEF {
mod tests {
use super::*;

#[expect(clippy::float_cmp)]
#[test]
fn ecef_ops() {
let a = ECEF::new(1.0, 2.0, 3.0);
Expand Down
13 changes: 7 additions & 6 deletions swiftnav/src/coords/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@ mod tests {
const MAX_ANGLE_ERROR_SECS: f64 = 1e-7;
const MAX_ANGLE_ERROR_RAD: f64 = (MAX_ANGLE_ERROR_SECS / 3600.0).to_radians();

#[expect(clippy::float_cmp)]
#[test]
fn llhrad2deg() {
let zeros = LLHRadians::default();
Expand All @@ -312,11 +313,11 @@ mod tests {
assert_eq!(0.0, deg.longitude());
assert_eq!(0.0, deg.height());

let swift_home: LLHDegrees = [37.779804, -122.391751, 60.0].into();
let swift_home: LLHDegrees = [37.779_804, -122.391_751, 60.0].into();
let rads = swift_home.to_radians();

assert!((rads.latitude() - 0.659381970558).abs() < MAX_ANGLE_ERROR_RAD);
assert!((rads.longitude() + 2.136139032231).abs() < MAX_ANGLE_ERROR_RAD);
assert!((rads.latitude() - 0.659_381_970_558).abs() < MAX_ANGLE_ERROR_RAD);
assert!((rads.longitude() + 2.136_139_032_231).abs() < MAX_ANGLE_ERROR_RAD);
assert!(
rads.height() == swift_home.height(),
"rads.height() = {}, swift_home.height() = {}",
Expand All @@ -339,7 +340,7 @@ mod tests {
];

/* Semi-major axis. */
const EARTH_A: f64 = 6378137.0;
const EARTH_A: f64 = 6_378_137.0;
/* Semi-minor axis. */
const EARTH_B: f64 = 6_356_752.314_245_179;

Expand Down Expand Up @@ -404,7 +405,7 @@ mod tests {

#[test]
fn llh2ecef2llh() {
for llh_input in LLH_VALUES.iter() {
for llh_input in &LLH_VALUES {
let llh_input: LLHRadians = llh_input.into();
let llh_output = llh_input.to_ecef().to_llh();

Expand All @@ -425,7 +426,7 @@ mod tests {

#[test]
fn ecef2llh2ecef() {
for ecef_input in ECEF_VALUES.iter() {
for ecef_input in &ECEF_VALUES {
let ecef_input: ECEF = ecef_input.into();
let ecef_output = ecef_input.to_llh().to_ecef();

Expand Down
11 changes: 6 additions & 5 deletions swiftnav/src/edc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,7 @@ mod tests {
const TEST_DATA: &[u8] = "123456789".as_bytes();

/// Helper function to append a CRC-24Q value as 3 bytes (big-endian) to a buffer
#[expect(clippy::cast_possible_truncation)]
fn append_crc24q(data: &mut Vec<u8>, crc: u32) {
data.push((crc >> 16) as u8);
data.push((crc >> 8) as u8);
Expand Down Expand Up @@ -365,9 +366,9 @@ mod tests {

/* Test value taken from python crcmod package tests, see:
* http://crcmod.sourceforge.net/crcmod.predefined.html */
let crc = compute_crc24q(TEST_DATA, 0xB704CE);
let crc = compute_crc24q(TEST_DATA, 0x00B7_04CE);
assert!(
crc == 0x21CF02,
crc == 0x0021_CF02,
"CRC of \"123456789\" with init value 0xB704CE should be 0x21CF02, not {}",
crc
);
Expand Down Expand Up @@ -403,7 +404,7 @@ mod tests {
#[test]
fn prop_crc_stays_within_24_bits(data in prop::collection::vec(any::<u8>(), 0..1000), init in any::<u32>()) {
let crc = compute_crc24q(&data, init);
prop_assert!(crc <= 0xFFFFFF, "CRC result 0x{:08X} exceeds 24-bit maximum", crc);
prop_assert!(crc <= 0x00FF_FFFF, "CRC result 0x{:08X} exceeds 24-bit maximum", crc);
}

/// Property: Incremental CRC calculation equals full calculation.
Expand Down Expand Up @@ -432,10 +433,10 @@ mod tests {
#[test]
fn prop_crc_initial_value_masked(data in prop::collection::vec(any::<u8>(), 0..100), init in any::<u32>()) {
let crc1 = compute_crc24q(&data, init);
let crc2 = compute_crc24q(&data, init & 0xFFFFFF);
let crc2 = compute_crc24q(&data, init & 0x00FF_FFFF);
prop_assert_eq!(crc1, crc2,
"CRC with init 0x{:08X} should equal CRC with masked init 0x{:06X}",
init, init & 0xFFFFFF);
init, init & 0x00FF_FFFF);
}

/// Property: Single bit errors are detected (CRC changes).
Expand Down
3 changes: 2 additions & 1 deletion swiftnav/src/reference_frame/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,7 @@ mod tests {
use params::TRANSFORMATIONS;
use std::str::FromStr;

#[expect(clippy::too_many_lines)]
#[test]
fn reference_frame_strings() {
assert_eq!(ReferenceFrame::ITRF88.to_string(), "ITRF88");
Expand Down Expand Up @@ -996,7 +997,7 @@ mod tests {
},
};

let params = transformation.params.clone();
let params = transformation.params;
repo.add_transformation(transformation);
assert_eq!(repo.count(), 2);

Expand Down
1 change: 1 addition & 0 deletions swiftnav/src/signal/code.rs
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,7 @@ mod tests {
assert!(Code::AuxBds.is_bds());
}

#[expect(clippy::too_many_lines)]
#[test]
fn code_strings() {
use std::str::FromStr;
Expand Down
1 change: 1 addition & 0 deletions swiftnav/src/signal/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ impl fmt::Display for GnssSignal {
mod tests {
use super::*;

#[expect(clippy::too_many_lines)]
#[test]
fn signal_to_constellation() {
assert_eq!(
Expand Down
28 changes: 14 additions & 14 deletions swiftnav/src/time/gnss.rs
Original file line number Diff line number Diff line change
Expand Up @@ -742,7 +742,7 @@ mod tests {
fn add_duration() {
let mut t = GpsTime::new(0, 0.0).unwrap();
let t_expected = GpsTime::new(0, 1.001).unwrap();
let d = Duration::new(1, 1000000);
let d = Duration::new(1, 1_000_000);

t.add_duration(&d);
assert_eq!(t, t_expected);
Expand All @@ -760,7 +760,7 @@ mod tests {
fn subtract_duration() {
let mut t = GpsTime::new(0, 1.001).unwrap();
let t_expected = GpsTime::new(0, 0.0).unwrap();
let d = Duration::new(1, 1000000);
let d = Duration::new(1, 1_000_000);

t.subtract_duration(&d);
assert_eq!(t, t_expected);
Expand All @@ -783,14 +783,14 @@ mod tests {
let epsilon = 1e-5;

let test_cases = [
GpsTime::new_unchecked(1234, 567890.01),
GpsTime::new_unchecked(1234, 567890.0501),
GpsTime::new_unchecked(1234, 604800.06),
GpsTime::new_unchecked(1234, 567_890.01),
GpsTime::new_unchecked(1234, 567_890.050_1),
GpsTime::new_unchecked(1234, 604_800.06),
];

let expectations = [
GpsTime::new_unchecked(1234, 567890.00),
GpsTime::new_unchecked(1234, 567890.10),
GpsTime::new_unchecked(1234, 567_890.00),
GpsTime::new_unchecked(1234, 567_890.10),
GpsTime::new_unchecked(1235, 0.1),
];

Expand All @@ -812,14 +812,14 @@ mod tests {
let epsilon = 1e-6;

let test_cases = [
GpsTime::new_unchecked(1234, 567890.01),
GpsTime::new_unchecked(1234, 567890.0501),
GpsTime::new_unchecked(1234, 604800.06),
GpsTime::new_unchecked(1234, 567_890.01),
GpsTime::new_unchecked(1234, 567_890.050_1),
GpsTime::new_unchecked(1234, 604_800.06),
];

let expectations = [
GpsTime::new_unchecked(1234, 567890.00),
GpsTime::new_unchecked(1234, 567890.00),
GpsTime::new_unchecked(1234, 567_890.00),
GpsTime::new_unchecked(1234, 567_890.00),
GpsTime::new_unchecked(1235, 0.0),
];

Expand All @@ -840,7 +840,7 @@ mod tests {

assert!(GalTime::new(-1, 0.0).is_err());
assert!(GalTime::new(0, -1.0).is_err());
assert!(GalTime::new(0, consts::WEEK_SECS as f64 + 1.0).is_err());
assert!(GalTime::new(0, f64::from(consts::WEEK_SECS) + 1.0).is_err());
}

#[test]
Expand All @@ -854,6 +854,6 @@ mod tests {

assert!(BdsTime::new(-1, 0.0).is_err());
assert!(BdsTime::new(0, -1.0).is_err());
assert!(BdsTime::new(0, consts::WEEK_SECS as f64 + 1.0).is_err());
assert!(BdsTime::new(0, f64::from(consts::WEEK_SECS) + 1.0).is_err());
}
}
10 changes: 5 additions & 5 deletions swiftnav/src/time/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,13 @@ mod tests {
#[test]
fn conversions() {
const TEST_CASES: [GpsTime; 10] = [
GpsTime::new_unchecked(1234, 567890.0),
GpsTime::new_unchecked(1234, 567890.5),
GpsTime::new_unchecked(1234, 567890.0),
GpsTime::new_unchecked(1234, 567_890.0),
GpsTime::new_unchecked(1234, 567_890.5),
GpsTime::new_unchecked(1234, 567_890.0),
GpsTime::new_unchecked(1234, 0.0),
GpsTime::new_unchecked(1000, 604578.0),
GpsTime::new_unchecked(1000, 604_578.0),
GpsTime::new_unchecked(1001, 222.222),
GpsTime::new_unchecked(1001, 604578.0),
GpsTime::new_unchecked(1001, 604_578.0),
GpsTime::new_unchecked(1939, 222.222),
GpsTime::new_unchecked(1930, 16.0),
GpsTime::new_unchecked(1930, 18.0), /* around Jan 2017 leap second */
Expand Down
Loading