Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
mantid
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mantidproject
mantid
Commits
e13ff0ba
Commit
e13ff0ba
authored
8 years ago
by
Gemma Guest
Browse files
Options
Downloads
Patches
Plain Diff
Re #18215 Add missing tests for CalculateSlits algorithm
parent
9b25b73f
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Framework/Algorithms/CMakeLists.txt
+1
-0
1 addition, 0 deletions
Framework/Algorithms/CMakeLists.txt
Framework/Algorithms/test/CalculateSlitsTest.h
+110
-0
110 additions, 0 deletions
Framework/Algorithms/test/CalculateSlitsTest.h
with
111 additions
and
0 deletions
Framework/Algorithms/CMakeLists.txt
+
1
−
0
View file @
e13ff0ba
...
...
@@ -655,6 +655,7 @@ set ( TEST_FILES
CalculateEfficiencyTest.h
CalculateFlatBackgroundTest.h
CalculateResolutionTest.h
CalculateSlitsTest.h
CalculateTransmissionBeamSpreaderTest.h
CalculateTransmissionTest.h
CalculateZscoreTest.h
...
...
This diff is collapsed.
Click to expand it.
Framework/Algorithms/test/CalculateSlitsTest.h
0 → 100644
+
110
−
0
View file @
e13ff0ba
#ifndef CALCULATESLITSTEST_H_
#define CALCULATESLITSTEST_H_
#include
<cxxtest/TestSuite.h>
#include
"MantidAlgorithms/CalculateSlits.h"
using
namespace
Mantid
::
Algorithms
;
class
CalculateSlitsTest
:
public
CxxTest
::
TestSuite
{
public:
void
test_sensible_values
()
{
CalculateSlits
alg
;
alg
.
initialize
();
alg
.
setProperty
(
"Slit1Slit2"
,
1940.5
);
alg
.
setProperty
(
"Slit2SA"
,
364.
);
alg
.
setProperty
(
"Angle"
,
0.7
);
alg
.
setProperty
(
"Footprint"
,
50.
);
alg
.
setProperty
(
"Resolution"
,
0.03
);
TS_ASSERT_THROWS_NOTHING
(
alg
.
execute
());
TS_ASSERT
(
alg
.
isExecuted
());
const
double
slit1
=
alg
.
getProperty
(
"Slit1"
);
TS_ASSERT_EQUALS
(
slit1
,
1.0784367635946033
);
const
double
slit2
=
alg
.
getProperty
(
"Slit2"
);
TS_ASSERT_EQUALS
(
slit2
,
0.34402409376933002
);
}
void
test_with_negative_angle
()
{
CalculateSlits
alg
;
alg
.
initialize
();
alg
.
setProperty
(
"Slit1Slit2"
,
1940.5
);
alg
.
setProperty
(
"Slit2SA"
,
364.
);
alg
.
setProperty
(
"Angle"
,
-
0.7
);
alg
.
setProperty
(
"Footprint"
,
50.
);
alg
.
setProperty
(
"Resolution"
,
0.03
);
TS_ASSERT_THROWS_NOTHING
(
alg
.
execute
());
TS_ASSERT
(
alg
.
isExecuted
());
const
double
slit1
=
alg
.
getProperty
(
"Slit1"
);
TS_ASSERT_EQUALS
(
slit1
,
-
1.0784367635946033
);
const
double
slit2
=
alg
.
getProperty
(
"Slit2"
);
TS_ASSERT_EQUALS
(
slit2
,
-
0.34402409376933002
);
}
void
test_with_angle_zero
()
{
CalculateSlits
alg
;
alg
.
initialize
();
alg
.
setProperty
(
"Slit1Slit2"
,
1940.5
);
alg
.
setProperty
(
"Slit2SA"
,
364.
);
alg
.
setProperty
(
"Angle"
,
0.
);
alg
.
setProperty
(
"Footprint"
,
50.
);
alg
.
setProperty
(
"Resolution"
,
0.03
);
TS_ASSERT_THROWS_NOTHING
(
alg
.
execute
());
TS_ASSERT
(
alg
.
isExecuted
());
const
double
slit1
=
alg
.
getProperty
(
"Slit1"
);
TS_ASSERT_EQUALS
(
slit1
,
0.0
);
const
double
slit2
=
alg
.
getProperty
(
"Slit2"
);
TS_ASSERT_EQUALS
(
slit2
,
0.0
);
}
void
test_with_nan_and_inf
()
{
const
double
nan
=
std
::
numeric_limits
<
double
>::
quiet_NaN
();
const
double
inf
=
std
::
numeric_limits
<
double
>::
infinity
();
const
double
ninf
=
-
inf
;
CalculateSlits
alg
;
alg
.
initialize
();
alg
.
setProperty
(
"Slit1Slit2"
,
nan
);
alg
.
setProperty
(
"Slit2SA"
,
nan
);
alg
.
setProperty
(
"Angle"
,
inf
);
alg
.
setProperty
(
"Footprint"
,
inf
);
alg
.
setProperty
(
"Resolution"
,
ninf
);
TS_ASSERT_THROWS_NOTHING
(
alg
.
execute
());
TS_ASSERT
(
alg
.
isExecuted
());
const
double
slit1
=
alg
.
getProperty
(
"Slit1"
);
TS_ASSERT
(
isnan
(
slit1
));
const
double
slit2
=
alg
.
getProperty
(
"Slit2"
);
TS_ASSERT
(
isnan
(
slit2
));
}
void
test_with_no_args
()
{
CalculateSlits
alg
;
alg
.
initialize
();
TS_ASSERT_THROWS_NOTHING
(
alg
.
execute
());
TS_ASSERT
(
alg
.
isExecuted
());
const
double
slit1
=
alg
.
getProperty
(
"Slit1"
);
TS_ASSERT
(
isnan
(
slit1
));
const
double
slit2
=
alg
.
getProperty
(
"Slit2"
);
TS_ASSERT
(
isnan
(
slit2
));
}
};
#endif
/*CALCULATESLITSTEST_H_*/
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