From 1db64256fc62dbde18fae4dd8c15188e14bb4387 Mon Sep 17 00:00:00 2001 From: lkoester Date: Thu, 26 Jan 2023 18:50:50 +0100 Subject: [PATCH 1/5] added gitignore --- .gitignore | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..fee1bb5 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +/target +/Cargo.lock +/.idea/* +!/.idea/runConfigurations From be1c97b75a0c726516459af356884cfabb924df8 Mon Sep 17 00:00:00 2001 From: lkoester Date: Thu, 26 Jan 2023 19:04:16 +0100 Subject: [PATCH 2/5] added partial equal implementation to pustc + unit tests --- src/tc.rs | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/tc.rs b/src/tc.rs index d70aa9e..1124687 100644 --- a/src/tc.rs +++ b/src/tc.rs @@ -213,7 +213,7 @@ impl PusTcSecondaryHeader { /// serde provider like [postcard](https://docs.rs/postcard/latest/postcard/). /// /// There is no spare bytes support yet. -#[derive(PartialEq, Eq, Copy, Clone, Debug)] +#[derive(Eq, Copy, Clone, Debug)] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] pub struct PusTc<'app_data> { sp_header: SpHeader, @@ -440,6 +440,12 @@ impl<'app_data> PusTc<'app_data> { } } +impl PartialEq for PusTc<'_> { + fn eq(&self, other: &Self) -> bool { + self.sp_header == other.sp_header && self.sec_header == other.sec_header && self.app_data == other.app_data + } +} + //noinspection RsTraitImplementation impl CcsdsPacket for PusTc<'_> { ccsds_impl!(); @@ -736,4 +742,20 @@ mod tests { assert_eq!(slice[11], 0xee); assert_eq!(slice[12], 0x63); } + + #[test] + fn partial_eq_pus_tc() { + // new vs new simple + let pus_tc_1 = base_ping_tc_simple_ctor(); + let pus_tc_2 = base_ping_tc_full_ctor(); + assert_eq!(pus_tc_1, pus_tc_2); + } + + #[test] + fn partial_eq_serialized_vs_derialized() { + let pus_tc = base_ping_tc_simple_ctor(); + let mut buf = [0; 32]; + let size = pus_tc.write_to_bytes(&mut buf).unwrap(); + assert_eq!(pus_tc, PusTc::from_bytes(&buf).unwrap().0); + } } From 5b021fec2223cae95496ea854779e468d046c72d Mon Sep 17 00:00:00 2001 From: lkoester Date: Thu, 26 Jan 2023 19:07:35 +0100 Subject: [PATCH 3/5] updated changelog --- CHANGELOG.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index fe57fca..37f2ccb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,14 @@ and this project adheres to [Semantic Versioning](http://semver.org/). # [unreleased] +## Added + +- Added `.gitignore`. + +## Fixed + +- Correct implementation of Trait `PartialEq` for `PusTc`. + # [v0.5.1] 2023-01-22 ## Added From 34bf9780af4af75ab3c03d5912fe7f5c9334b8d8 Mon Sep 17 00:00:00 2001 From: lkoester Date: Thu, 26 Jan 2023 19:08:29 +0100 Subject: [PATCH 4/5] fmt and clippy --- src/tc.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/tc.rs b/src/tc.rs index 1124687..91284e0 100644 --- a/src/tc.rs +++ b/src/tc.rs @@ -442,7 +442,9 @@ impl<'app_data> PusTc<'app_data> { impl PartialEq for PusTc<'_> { fn eq(&self, other: &Self) -> bool { - self.sp_header == other.sp_header && self.sec_header == other.sec_header && self.app_data == other.app_data + self.sp_header == other.sp_header + && self.sec_header == other.sec_header + && self.app_data == other.app_data } } From ad8e50c614435d532e46b03ec287d36b8c999dc5 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 26 Jan 2023 21:00:32 +0100 Subject: [PATCH 5/5] CHANGELOG clarification, gitignore comments --- .gitignore | 3 +++ CHANGELOG.md | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index fee1bb5..e74cf0b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,7 @@ +# Rust /target /Cargo.lock + +# CLion /.idea/* !/.idea/runConfigurations diff --git a/CHANGELOG.md b/CHANGELOG.md index 37f2ccb..6d6b13e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,7 +14,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## Fixed -- Correct implementation of Trait `PartialEq` for `PusTc`. +- Correct manual implementation of Trait `PartialEq` for `PusTc`. The previous auto-derivation was + incorrect because it also compared fields unrelated to the raw byte representation. # [v0.5.1] 2023-01-22