Skip to content

Commit

Permalink
Increased test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
taavit committed Apr 23, 2023
1 parent 80db962 commit 75c5c1d
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions src/sentences/bww.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,4 +139,43 @@ mod tests {
data
);
}

#[test]
fn test_parse_bww_with_wrong_sentence() {
let sentence = parse_nmea_sentence("$GPAAM,,T,,M,,*4C").unwrap();

assert_eq!(
parse_bww(sentence).unwrap_err(),
Error::WrongSentenceHeader {
expected: SentenceType::BWW,
found: SentenceType::AAM,
}
);
}

#[test]
fn test_parse_bww_with_too_long_to_waypoint_parameter() {
let sentence = parse_nmea_sentence("$GPBWW,,T,,M,ABCDEFGHIJKLMNOPQRSTUWXYZABCDEFGHIJKLMNOPQRSTUWXYZABCDEFGHIJKLMNOPQRSTUWXYZ,*4C").unwrap();

assert_eq!(
parse_bww(sentence).unwrap_err(),
Error::ParameterLength {
max_length: 64,
parameter_length: 75
}
);
}

#[test]
fn test_parse_bww_with_too_long_from_waypoint_parameter() {
let sentence = parse_nmea_sentence("$GPBWW,,T,,M,,ABCDEFGHIJKLMNOPQRSTUWXYZABCDEFGHIJKLMNOPQRSTUWXYZABCDEFGHIJKLMNOPQRSTUWXYZ*4C").unwrap();

assert_eq!(
parse_bww(sentence).unwrap_err(),
Error::ParameterLength {
max_length: 64,
parameter_length: 75
}
);
}
}

0 comments on commit 75c5c1d

Please sign in to comment.