Skip to content
Snippets Groups Projects
Commit 7e440480 authored by Udo Eisenbarth's avatar Udo Eisenbarth :speech_balloon:
Browse files

Imrprove unit tests for EnergyMeter

parent 66f58a58
No related branches found
No related tags found
1 merge request!25Resolve "EnergyMeter: Add analysis_inverse unit test"
......@@ -105,7 +105,11 @@ impl BeamSplitter {
s.scale_vertical(1.0 - self.ratio()).unwrap();
out1_2_spectrum = Some(s);
}
_ => return Err(OpossumError::Analysis("expected DataEnergy value at input port".into())),
_ => {
return Err(OpossumError::Analysis(
"expected DataEnergy value at input port".into(),
))
}
}
}
if let Some(Some(in2)) = in2 {
......@@ -118,7 +122,11 @@ impl BeamSplitter {
s.scale_vertical(1.0 - self.ratio()).unwrap();
out2_2_spectrum = Some(s);
}
_ => return Err(OpossumError::Analysis("expected DataEnergy value at input port".into())),
_ => {
return Err(OpossumError::Analysis(
"expected DataEnergy value at input port".into(),
))
}
}
}
let out1_spec = merge_spectra(out1_1_spectrum, out2_2_spectrum);
......
......@@ -208,32 +208,27 @@ mod test {
fn analyze() {
let mut meter = EnergyMeter::default();
let mut input = LightResult::default();
let input_data=Some(LightData::Energy(DataEnergy {
let input_data = Some(LightData::Energy(DataEnergy {
spectrum: create_he_ne_spectrum(1.0),
}));
input.insert(
"in1".into(),
input_data.clone(),
);
input.insert("in1".into(), input_data.clone());
let result = meter.analyze(input, &AnalyzerType::Energy);
assert!(result.is_ok());
assert!(result.clone().unwrap().contains_key("out1"));
assert!(result.unwrap().get("out1").unwrap().is_some());
assert_eq!(result.unwrap().get("out1").unwrap(), &input_data);
}
#[test]
fn analyze_inverted() {
let mut meter = EnergyMeter::default();
let mut input = LightResult::default();
meter.set_property("inverted", true.into()).unwrap();
input.insert(
"out1".into(),
Some(LightData::Energy(DataEnergy {
spectrum: create_he_ne_spectrum(1.0),
})),
);
let input_data = Some(LightData::Energy(DataEnergy {
spectrum: create_he_ne_spectrum(1.0),
}));
input.insert("out1".into(), input_data.clone());
let result = meter.analyze(input, &AnalyzerType::Energy);
assert!(result.is_ok());
assert!(result.clone().unwrap().contains_key("in1"));
assert!(result.unwrap().get("in1").unwrap().is_some());
assert_eq!(result.unwrap().get("in1").unwrap(), &input_data);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment