Skip to content

Commit

Permalink
Increase code coverage
Browse files Browse the repository at this point in the history
Increase code coverage by adding "tests" for a few code paths that
otherwise will not be exercised.
  • Loading branch information
d-e-s-o committed Dec 29, 2024
1 parent 0d64a32 commit 2169a66
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/data/v2/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ pub enum Data<B = Bar, Q = Quote, T = Trade> {
Trade(T),
}

impl Data {
impl<B, Q, T> Data<B, Q, T> {
/// Check whether this object is of the `Bar` variant.
#[inline]
pub fn is_bar(&self) -> bool {
Expand Down Expand Up @@ -941,6 +941,20 @@ mod tests {
const SUB_ERR_RESP: &str = r#"[{"T":"error","code":400,"msg":"invalid syntax"}]"#;


/// Exercise the `Sip::source` method.
#[test]
fn sip_source() {
assert_ne!(format!("{:?}", SIP::source()), "");
}

/// Exercise the various `is_*` methods of the `Data` enum.
#[test]
fn data_classification() {
assert!(Data::<(), Quote, Trade>::Bar(()).is_bar());
assert!(Data::<Bar, (), Trade>::Quote(()).is_quote());
assert!(Data::<Bar, Quote, ()>::Trade(()).is_trade());
}

/// Test that the [`Symbols::is_empty`] method works as expected.
#[test]
fn symbols_is_empty() {
Expand Down

0 comments on commit 2169a66

Please sign in to comment.