Skip to content

Commit

Permalink
Add some tests to boost coverage
Browse files Browse the repository at this point in the history
The logic isn't important, but it helps make actual coverage gaps more visible.
  • Loading branch information
marshallpierce committed Mar 2, 2024
1 parent 9e9c7ab commit 2b91084
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions src/decode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -340,3 +340,47 @@ mod tests {
}
}
}

#[allow(deprecated)]
#[cfg(test)]
mod coverage_gaming {
use super::*;
use std::error::Error;

#[test]
fn decode_error() {
let _ = format!("{:?}", DecodeError::InvalidPadding.clone());
let _ = format!(
"{} {} {} {}",
DecodeError::InvalidByte(0, 0),
DecodeError::InvalidLength(0),
DecodeError::InvalidLastSymbol(0, 0),
DecodeError::InvalidPadding,
);
}

#[test]
fn decode_slice_error() {
let _ = format!("{:?}", DecodeSliceError::OutputSliceTooSmall.clone());
let _ = format!(
"{} {}",
DecodeSliceError::OutputSliceTooSmall,
DecodeSliceError::DecodeError(DecodeError::InvalidPadding)
);
let _ = DecodeSliceError::OutputSliceTooSmall.source();
let _ = DecodeSliceError::DecodeError(DecodeError::InvalidPadding).source();
}

#[test]
fn deprecated_fns() {
let _ = decode("");
let _ = decode_engine("", &crate::prelude::BASE64_STANDARD);
let _ = decode_engine_vec("", &mut Vec::new(), &crate::prelude::BASE64_STANDARD);
let _ = decode_engine_slice("", &mut [], &crate::prelude::BASE64_STANDARD);
}

#[test]
fn decoded_len_est() {
assert_eq!(3, decoded_len_estimate(4));
}
}

0 comments on commit 2b91084

Please sign in to comment.