Skip to content

Commit

Permalink
add test for invalid pfb
Browse files Browse the repository at this point in the history
  • Loading branch information
d3v-null committed Jun 26, 2024
1 parent 7686c9f commit 9ecc4e8
Showing 1 changed file with 23 additions and 7 deletions.
30 changes: 23 additions & 7 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use prettytable::{format as prettyformat, row, table};
use crate::{
error::{
BirliError,
BirliError::DryRun,
BirliError::{BadMWAVersion, DryRun},
CLIError::{InvalidCommandLineArgument, InvalidRangeSpecifier},
},
flags::FlagContext,
Expand Down Expand Up @@ -1308,12 +1308,8 @@ impl<'a> BirliContext<'a> {
Some("auto") => match corr_ctx.mwa_version {
MWAVersion::CorrMWAXv2 => Some(PFB_JAKE_2022_200HZ),
MWAVersion::CorrLegacy | MWAVersion::CorrOldLegacy => Some(PFB_COTTER_2014_10KHZ),
ver => return Err(BirliError::BadMWAVersion {
message:
"could not determine automatic pfb gains from provided mwalib::MWAVersion."
.into(),
version: ver.to_string(),
}),
#[rustfmt::skip]
ver => { return Err(BadMWAVersion { message: "unknown mwa version".into(), version: ver.to_string() }) },

Check warning on line 1312 in src/cli.rs

View check run for this annotation

Codecov / codecov/patch

src/cli.rs#L1312

Added line #L1312 was not covered by tests
},
Some(option) => panic!("unknown option for --passband-gains: {option}"),
};
Expand Down Expand Up @@ -2002,6 +1998,26 @@ mod tests {
assert_abs_diff_ne!(prep_ctx.passband_gains.unwrap()[0], PFB_JAKE_2022_200HZ[0]);
}

/// pfb gains is cotter by default for legacy correlator.
#[test]
fn test_invalid_pfb() {
let (metafits_path, gpufits_paths) = get_1254670392_avg_paths();

#[rustfmt::skip]
let args = vec![
"birli",
"-m", metafits_path,
"--no-draw-progress",
"--pfb-gains", "invalid",
gpufits_paths[0],
gpufits_paths[1],
];

let birli_ctx = BirliContext::from_args(&args);

assert!(birli_ctx.is_err());
}

/// pfb gains is jake by default for mwax correlator.
#[test]
fn test_auto_pfb_mwax() {
Expand Down

0 comments on commit 9ecc4e8

Please sign in to comment.