Skip to content

Commit

Permalink
add some more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
robamu committed Aug 23, 2024
1 parent 53078b5 commit 8ea50f0
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
29 changes: 25 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,12 +271,18 @@ impl RemoteEntityConfigProvider for alloc::vec::Vec<RemoteEntityConfig> {
}

impl RemoteEntityConfigProvider for RemoteEntityConfig {
fn get(&self, _remote_id: u64) -> Option<&RemoteEntityConfig> {
Some(self)
fn get(&self, remote_id: u64) -> Option<&RemoteEntityConfig> {
if remote_id == self.entity_id.value() {
return Some(self);
}
None
}

fn get_mut(&mut self, _remote_id: u64) -> Option<&mut RemoteEntityConfig> {
Some(self)
fn get_mut(&mut self, remote_id: u64) -> Option<&mut RemoteEntityConfig> {
if remote_id == self.entity_id.value() {
return Some(self);
}
None
}

fn add_config(&mut self, _cfg: &RemoteEntityConfig) -> bool {
Expand Down Expand Up @@ -891,6 +897,7 @@ pub(crate) mod tests {
use super::*;

pub const LOCAL_ID: UnsignedByteFieldU16 = UnsignedByteFieldU16::new(1);
pub const REMOTE_ID: UnsignedByteFieldU16 = UnsignedByteFieldU16::new(2);

pub struct FileSegmentRecvdParamsNoSegMetadata {
#[allow(dead_code)]
Expand Down Expand Up @@ -1237,6 +1244,20 @@ pub(crate) mod tests {
assert_eq!(check_timer.expiry_time_seconds(), 1);
}

#[test]
fn test_remote_cfg_provider_single() {
let remote_entity_cfg = RemoteEntityConfig::new_with_default_values(
REMOTE_ID.into(),
1024,
true,
false,
TransmissionMode::Unacknowledged,
ChecksumType::Crc32,
);
let remote_entity_retrieved = remote_entity_cfg.get(REMOTE_ID.value()).unwrap();
ssert_eq!(remote_entity_retrieved.entity_id, REMOTE_ID.into());
}

#[test]
fn dummy_fault_hook_test() {
let mut user_hook_dummy = DummyFaultHook::default();
Expand Down
1 change: 1 addition & 0 deletions tests/end-to-end.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//! This is an end-to-end integration tests using the CFDP abstractions provided by the library.
use std::{
fs::OpenOptions,
io::Write,
Expand Down

0 comments on commit 8ea50f0

Please sign in to comment.