Skip to content

Commit

Permalink
Fix tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
reitermarkus committed Jun 9, 2022
1 parent e9aa87d commit 66e6bfd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
3 changes: 2 additions & 1 deletion ublox_derive/src/output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ pub fn generate_recv_code_for_packet(pack_descr: &PackDesc) -> TokenStream {
#[doc = "Contains a reference to an underlying buffer, contains accessor methods to retrieve data."]
pub struct #ref_name<'a>(&'a [u8]);
impl<'a> #ref_name<'a> {
#[inline]
pub fn as_bytes(&self) -> &[u8] {
self.0
}
Expand Down Expand Up @@ -361,7 +362,7 @@ pub fn generate_send_code_for_packet(pack_descr: &PackDesc) -> TokenStream {
} else {
ret.extend(quote! {
impl #payload_struct_lifetime #payload_struct #payload_struct_lifetime {
#[inline]
#[inline]
pub fn extend_to<T>(self, out: &mut T)
where
T: core::iter::Extend<u8> +
Expand Down
16 changes: 13 additions & 3 deletions ublox_derive/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ fn test_ubx_packet_recv_simple() {
#[doc = "Contains a reference to an underlying buffer, contains accessor methods to retrieve data."]
pub struct TestRef<'a>(&'a [u8]);
impl<'a> TestRef<'a> {
#[inline]
pub fn as_bytes(&self) -> &[u8] {
self.0
}

#[doc = ""]
#[inline]
pub fn itow(&self) -> u32 {
Expand Down Expand Up @@ -192,6 +197,11 @@ fn test_ubx_packet_recv_dyn_len() {
#[doc = "Contains a reference to an underlying buffer, contains accessor methods to retrieve data."]
pub struct TestRef<'a>(&'a [u8]);
impl<'a> TestRef<'a> {
#[inline]
pub fn as_bytes(&self) -> &[u8] {
self.0
}

#[doc = ""]
#[inline]
pub fn f1_raw(&self) -> &[u8] {
Expand Down Expand Up @@ -308,9 +318,9 @@ fn test_ubx_packet_send() {
ret[13usize] = bytes[3usize];
let bytes = self.a.to_le_bytes();
ret[14usize] = bytes[0usize];
let (ck_a, ck_b) = ubx_checksum(&ret[2..17usize - 2]);
ret[17usize - 2] = ck_a;
ret[17usize - 1] = ck_b;
let (ck_a, ck_b) = ubx_checksum(&ret[2..(Self::PACKET_LEN - 2)]);
ret[Self::PACKET_LEN - 2] = ck_a;
ret[Self::PACKET_LEN - 1] = ck_b;
ret
}
}
Expand Down

0 comments on commit 66e6bfd

Please sign in to comment.