Skip to content

Commit

Permalink
Move expected data after the test code
Browse files Browse the repository at this point in the history
  • Loading branch information
matzipan committed Oct 15, 2023
1 parent 1045e7f commit 2aebdb0
Showing 1 changed file with 59 additions and 59 deletions.
118 changes: 59 additions & 59 deletions crates/lox_core/src/ephemeris/daf_spk/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,65 @@ pub fn parse_daf_spk(full_input: &[u8]) -> nom::IResult<&[u8], Spk> {
mod test {
use super::*;

#[test]
fn test_parse_all_summary_and_name_record_pairs() {
let (_, all_summary_records) =
parse_all_summary_and_name_record_pairs(&FILE_CONTENTS, 2, 6, 4)
.expect("DafSummary record parsing should succeed");

assert_eq!(all_summary_records, vec![get_expected_summary_record()]);
}

#[test]
fn test_parse_daf_summary_and_name_record_pair() {
let (_, summary_record) = parse_daf_summary_and_name_record_pair(&SUMMARY_RECORD, 2, 6)
.expect("DafSummary record parsing should succeed");

assert_eq!(summary_record, get_expected_summary_record());
}

#[test]
fn test_parse_daf_comment_area() {
let (unparsed_string, comment) = parse_daf_comment_area(&COMMENT_AREA_SEGMENT, 2)
.expect("Comment area parsing should succeed");

assert_eq!(unparsed_string.len(), 0);

assert_eq!(get_expected_comment_string(), comment);
}

#[test]
fn test_parse_daf_file_record() {
let (unparsed_string, file_record) = parse_daf_file_record(&FILE_RECORD_SEGMENT)
.expect("File record parsing should succeed");

assert_eq!(unparsed_string.len(), 0);

assert_eq!(file_record.locidw, "DAF/SPK");
assert_eq!(file_record.nd, 2);
assert_eq!(file_record.ni, 6);
assert_eq!(file_record.locifn, "NIO2SPK");
assert_eq!(file_record.fward, 4);
assert_eq!(file_record.bward, 4);
assert_eq!(file_record.free, 14967465);
assert_eq!(file_record.locfmt, "LTL-IEEE");
assert_eq!(
file_record.ftpstr,
b"FTPSTR:\r:\n:\r\n:\r\x00:\x81:\x10\xce:ENDFTP"
);
}

#[test]
fn test_parse_daf_spk() {
let spk = parse_daf_spk(&FILE_CONTENTS);

assert!(spk.is_ok());

if let Ok((_, spk)) = spk {
assert_eq!(spk, get_expected_spk());
}
}

fn get_expected_comment_string() -> String {
r#"September 03, 2013
C. Acton
Expand Down Expand Up @@ -788,65 +847,6 @@ name is "19_spk") available from the NAIF website (http://naif.jpl.nasa.gov/tuto
}
}

#[test]
fn test_parse_all_summary_and_name_record_pairs() {
let (_, all_summary_records) =
parse_all_summary_and_name_record_pairs(&FILE_CONTENTS, 2, 6, 4)
.expect("DafSummary record parsing should succeed");

assert_eq!(all_summary_records, vec![get_expected_summary_record()]);
}

#[test]
fn test_parse_daf_summary_and_name_record_pair() {
let (_, summary_record) = parse_daf_summary_and_name_record_pair(&SUMMARY_RECORD, 2, 6)
.expect("DafSummary record parsing should succeed");

assert_eq!(summary_record, get_expected_summary_record());
}

#[test]
fn test_parse_daf_comment_area() {
let (unparsed_string, comment) = parse_daf_comment_area(&COMMENT_AREA_SEGMENT, 2)
.expect("Comment area parsing should succeed");

assert_eq!(unparsed_string.len(), 0);

assert_eq!(get_expected_comment_string(), comment);
}

#[test]
fn test_parse_daf_file_record() {
let (unparsed_string, file_record) = parse_daf_file_record(&FILE_RECORD_SEGMENT)
.expect("File record parsing should succeed");

assert_eq!(unparsed_string.len(), 0);

assert_eq!(file_record.locidw, "DAF/SPK");
assert_eq!(file_record.nd, 2);
assert_eq!(file_record.ni, 6);
assert_eq!(file_record.locifn, "NIO2SPK");
assert_eq!(file_record.fward, 4);
assert_eq!(file_record.bward, 4);
assert_eq!(file_record.free, 14967465);
assert_eq!(file_record.locfmt, "LTL-IEEE");
assert_eq!(
file_record.ftpstr,
b"FTPSTR:\r:\n:\r\n:\r\x00:\x81:\x10\xce:ENDFTP"
);
}

#[test]
fn test_parse_daf_spk() {
let spk = parse_daf_spk(&FILE_CONTENTS);

assert!(spk.is_ok());

if let Ok((_, spk)) = spk {
assert_eq!(spk, get_expected_spk());
}
}

const FILE_CONTENTS: [u8; 5120] = [
0x44u8, 0x41u8, 0x46u8, 0x2Fu8, 0x53u8, 0x50u8, 0x4Bu8, 0x20u8, 0x02u8, 0x00u8, 0x00u8,
0x00u8, 0x06u8, 0x00u8, 0x00u8, 0x00u8, 0x4Eu8, 0x49u8, 0x4Fu8, 0x32u8, 0x53u8, 0x50u8,
Expand Down

0 comments on commit 2aebdb0

Please sign in to comment.