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
d12a7968
Commit
d12a7968
authored
6 years ago
by
Gagik Vardanyan
Browse files
Options
Downloads
Patches
Plain Diff
Re #22728 improved unit tests
parent
70ca6077
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/test/CropToComponentTest.h
+29
-0
29 additions, 0 deletions
Framework/Algorithms/test/CropToComponentTest.h
Framework/Indexing/test/IndexInfoTest.h
+15
-7
15 additions, 7 deletions
Framework/Indexing/test/IndexInfoTest.h
with
44 additions
and
7 deletions
Framework/Algorithms/test/CropToComponentTest.h
+
29
−
0
View file @
d12a7968
...
@@ -5,6 +5,7 @@
...
@@ -5,6 +5,7 @@
#include
"MantidAPI/AlgorithmManager.h"
#include
"MantidAPI/AlgorithmManager.h"
#include
"MantidAPI/SpectrumInfo.h"
#include
"MantidAPI/SpectrumInfo.h"
#include
"MantidAlgorithms/CreateSampleWorkspace.h"
#include
"MantidAlgorithms/CropToComponent.h"
#include
"MantidAlgorithms/CropToComponent.h"
#include
"MantidDataHandling/LoadRaw3.h"
#include
"MantidDataHandling/LoadRaw3.h"
#include
"MantidTestHelpers/WorkspaceCreationHelper.h"
#include
"MantidTestHelpers/WorkspaceCreationHelper.h"
...
@@ -201,6 +202,34 @@ public:
...
@@ -201,6 +202,34 @@ public:
}
}
}
}
void
test_scanning_workspace
()
{
// Create a sample scanning workspace
Mantid
::
Algorithms
::
CreateSampleWorkspace
creator
;
creator
.
setChild
(
true
);
creator
.
initialize
();
creator
.
setProperty
(
"NumBanks"
,
2
);
creator
.
setProperty
(
"NumScanPoints"
,
5
);
creator
.
setProperty
(
"OutputWorkspace"
,
"__unused_for_child"
);
creator
.
execute
();
Mantid
::
API
::
MatrixWorkspace_sptr
workspace
=
creator
.
getProperty
(
"OutputWorkspace"
);
// Act
Mantid
::
Algorithms
::
CropToComponent
crop
;
crop
.
setChild
(
true
);
crop
.
initialize
();
crop
.
setRethrows
(
true
);
crop
.
setProperty
(
"InputWorkspace"
,
workspace
);
crop
.
setProperty
(
"OutputWorkspace"
,
"__cropped"
);
crop
.
setProperty
(
"ComponentNames"
,
"bank1"
);
TS_ASSERT_THROWS_NOTHING
(
crop
.
execute
())
TS_ASSERT
(
crop
.
isExecuted
())
Mantid
::
API
::
MatrixWorkspace_sptr
cropped
=
crop
.
getProperty
(
"OutputWorkspace"
);
TS_ASSERT
(
cropped
)
}
private
:
private
:
Mantid
::
API
::
MatrixWorkspace_sptr
Mantid
::
API
::
MatrixWorkspace_sptr
getSampleWorkspace
(
int
numberOfBanks
,
int
numbersOfPixelPerBank
)
{
getSampleWorkspace
(
int
numberOfBanks
,
int
numbersOfPixelPerBank
)
{
...
...
This diff is collapsed.
Click to expand it.
Framework/Indexing/test/IndexInfoTest.h
+
15
−
7
View file @
d12a7968
...
@@ -333,17 +333,25 @@ public:
...
@@ -333,17 +333,25 @@ public:
"Some of the requested detectors do not have a corresponding spectrum"
);
"Some of the requested detectors do not have a corresponding spectrum"
);
}
}
void
test_globalSpectrumIndicesFromDetectorIndices_scanning
()
{
void
test_globalSpectrumIndicesFromDetectorIndices_scanning_different_time_indices
()
{
IndexInfo
info
(
3
);
IndexInfo
info
(
3
);
std
::
vector
<
size_t
>
detectorIndices
{
6
,
8
};
std
::
vector
<
size_t
>
detectorIndices
{
6
,
8
};
std
::
vector
<
SpectrumDefinition
>
specDefs
(
3
);
std
::
vector
<
SpectrumDefinition
>
specDefs
(
3
);
// Two indices map to same detector; typical for time-indexed workspaces.
// Two indices map to the same detector at different time indices; typical
specDefs
[
0
].
add
(
6
);
// for time-indexed workspaces.
specDefs
[
1
].
add
(
6
);
specDefs
[
0
].
add
(
6
,
1
);
specDefs
[
2
].
add
(
8
);
specDefs
[
1
].
add
(
6
,
2
);
specDefs
[
2
].
add
(
8
,
1
);
info
.
setSpectrumDefinitions
(
specDefs
);
info
.
setSpectrumDefinitions
(
specDefs
);
TS_ASSERT_THROWS_NOTHING
(
TS_ASSERT_THROWS_NOTHING
(
info
.
globalSpectrumIndicesFromDetectorIndices
(
detectorIndices
));
info
.
globalSpectrumIndicesFromDetectorIndices
(
detectorIndices
));
const
auto
&
indices
=
info
.
globalSpectrumIndicesFromDetectorIndices
(
detectorIndices
);
TS_ASSERT_EQUALS
(
indices
.
size
(),
3
);
TS_ASSERT_EQUALS
(
indices
[
0
],
0
);
TS_ASSERT_EQUALS
(
indices
[
1
],
1
);
TS_ASSERT_EQUALS
(
indices
[
2
],
2
);
}
}
void
test_globalSpectrumIndicesFromDetectorIndices_fails_conflict_miss
()
{
void
test_globalSpectrumIndicesFromDetectorIndices_fails_conflict_miss
()
{
...
@@ -351,8 +359,8 @@ public:
...
@@ -351,8 +359,8 @@ public:
std
::
vector
<
size_t
>
detectorIndices
{
6
,
8
};
std
::
vector
<
size_t
>
detectorIndices
{
6
,
8
};
std
::
vector
<
SpectrumDefinition
>
specDefs
(
3
);
std
::
vector
<
SpectrumDefinition
>
specDefs
(
3
);
// Two indices map to same detector, but additionally one is missing.
// Two indices map to same detector, but additionally one is missing.
specDefs
[
0
].
add
(
6
);
specDefs
[
0
].
add
(
6
,
1
);
specDefs
[
1
].
add
(
6
);
specDefs
[
1
].
add
(
6
,
2
);
info
.
setSpectrumDefinitions
(
specDefs
);
info
.
setSpectrumDefinitions
(
specDefs
);
TS_ASSERT_THROWS_EQUALS
(
TS_ASSERT_THROWS_EQUALS
(
info
.
globalSpectrumIndicesFromDetectorIndices
(
detectorIndices
),
info
.
globalSpectrumIndicesFromDetectorIndices
(
detectorIndices
),
...
...
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