Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
OPOSSUM
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
phelix
rust
OPOSSUM
Commits
bc40a8aa
Commit
bc40a8aa
authored
1 year ago
by
Udo Eisenbarth
Browse files
Options
Downloads
Patches
Plain Diff
Add unit test for dummy.analyze
parent
c183872e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Pipeline
#7705
passed
1 year ago
Stage: test
Stage: build
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/lightdata.rs
+3
-3
3 additions, 3 deletions
src/lightdata.rs
src/nodes/dummy.rs
+48
-0
48 additions, 0 deletions
src/nodes/dummy.rs
src/spectrum.rs
+1
-1
1 addition, 1 deletion
src/spectrum.rs
with
52 additions
and
4 deletions
src/lightdata.rs
+
3
−
3
View file @
bc40a8aa
...
...
@@ -11,7 +11,7 @@ use crate::spectrum::Spectrum;
/// [`AnalyzerType`](crate::analyzer::AnalyzerType). For example, an energy analysis ([`LightData::Energy`]) only
/// contains a [`Spectrum`] information, while a geometric analysis ([`LightData::Geometric]) constains a set of optical
/// ray data.
#[derive(Debug,
Clone,
Serialize,
Deserialize)]
#[derive(Debug,
Clone,
Serialize,
Deserialize
,
PartialEq
)]
pub
enum
LightData
{
/// data type used for energy analysis.
Energy
(
DataEnergy
),
...
...
@@ -45,12 +45,12 @@ impl Display for LightData {
}
}
}
#[derive(Debug,
Clone,
Serialize,
Deserialize)]
#[derive(Debug,
Clone,
Serialize,
Deserialize
,
PartialEq
)]
pub
struct
DataEnergy
{
pub
spectrum
:
Spectrum
,
}
#[derive(Debug,
Clone,
Serialize,
Deserialize)]
#[derive(Debug,
Clone,
Serialize,
Deserialize
,
PartialEq
)]
pub
struct
DataGeometric
{
_ray
:
i32
,
}
This diff is collapsed.
Click to expand it.
src/nodes/dummy.rs
+
48
−
0
View file @
bc40a8aa
...
...
@@ -134,6 +134,8 @@ impl Dottable for Dummy {}
#[cfg(test)]
mod
test
{
use
crate
::{
lightdata
::{
DataEnergy
,
LightData
},
spectrum
::
create_he_ne_spectrum
};
use
super
::
*
;
#[test]
fn
new
()
{
...
...
@@ -169,4 +171,50 @@ mod test {
let
node
=
Dummy
::
default
();
assert_eq!
(
node
.node_type
(),
"dummy"
);
}
#[test]
fn
analyze_ok
()
{
let
mut
dummy
=
Dummy
::
default
();
let
mut
input
=
LightResult
::
default
();
let
input_light
=
LightData
::
Energy
(
DataEnergy
{
spectrum
:
create_he_ne_spectrum
(
1.0
)});
input
.insert
(
"front"
.into
(),
Some
(
input_light
.clone
()));
let
output
=
dummy
.analyze
(
input
,
&
AnalyzerType
::
Energy
);
assert!
(
output
.is_ok
());
let
output
=
output
.unwrap
();
assert!
(
output
.contains_key
(
"rear"
.into
()));
assert_eq!
(
output
.len
(),
1
);
let
output
=
output
.get
(
"rear"
.into
())
.unwrap
();
assert!
(
output
.is_some
());
let
output
=
output
.clone
()
.unwrap
();
assert_eq!
(
output
,
input_light
);
}
#[test]
fn
analyze_wrong
()
{
let
mut
dummy
=
Dummy
::
default
();
let
mut
input
=
LightResult
::
default
();
let
input_light
=
LightData
::
Energy
(
DataEnergy
{
spectrum
:
create_he_ne_spectrum
(
1.0
)});
input
.insert
(
"rear"
.into
(),
Some
(
input_light
.clone
()));
let
output
=
dummy
.analyze
(
input
,
&
AnalyzerType
::
Energy
);
assert!
(
output
.is_ok
());
let
output
=
output
.unwrap
();
let
output
=
output
.get
(
"rear"
.into
())
.unwrap
();
assert!
(
output
.is_none
());
}
#[test]
fn
analyze_inverse
()
{
let
mut
dummy
=
Dummy
::
default
();
dummy
.set_property
(
"inverted"
,
true
.into
())
.unwrap
();
let
mut
input
=
LightResult
::
default
();
let
input_light
=
LightData
::
Energy
(
DataEnergy
{
spectrum
:
create_he_ne_spectrum
(
1.0
)});
input
.insert
(
"rear"
.into
(),
Some
(
input_light
.clone
()));
let
output
=
dummy
.analyze
(
input
,
&
AnalyzerType
::
Energy
);
assert!
(
output
.is_ok
());
let
output
=
output
.unwrap
();
assert!
(
output
.contains_key
(
"front"
.into
()));
assert_eq!
(
output
.len
(),
1
);
let
output
=
output
.get
(
"front"
.into
())
.unwrap
();
assert!
(
output
.is_some
());
let
output
=
output
.clone
()
.unwrap
();
assert_eq!
(
output
,
input_light
);
}
}
This diff is collapsed.
Click to expand it.
src/spectrum.rs
+
1
−
1
View file @
bc40a8aa
...
...
@@ -21,7 +21,7 @@ use std::fs::File;
///
/// This structure handles an array of values over a given wavelength range. Although the interface
/// is still limited, the structure is prepared for handling also non-equidistant wavelength slots.
#[derive(Clone,
Serialize,
Deserialize)]
#[derive(Clone,
Serialize,
Deserialize
,
PartialEq
)]
pub
struct
Spectrum
{
data
:
Array1
<
(
f64
,
f64
)
>
,
// (wavelength in meters, data in 1/meters)
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment