Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
mantidproject
mantid
Commits
f1bdd9e0
Commit
f1bdd9e0
authored
Mar 20, 2013
by
Zhou, Wenduo
Browse files
Add more unit tests. Refs #6746.
parent
aa9baa39
Changes
2
Hide whitespace changes
Inline
Side-by-side
Code/Mantid/Framework/Kernel/src/Statistics.cpp
View file @
f1bdd9e0
...
...
@@ -229,9 +229,15 @@ namespace Mantid
if
(
obsI
.
size
()
!=
calI
.
size
()
||
obsI
.
size
()
!=
obsE
.
size
())
{
std
::
stringstream
errss
;
errss
<<
"GetRFactor() Input Error! Observed Intensity, Calculated Intensity and Observed Error have different number of elements."
;
errss
<<
"GetRFactor() Input Error! Observed Intensity ("
<<
obsI
.
size
()
<<
"), Calculated Intensity ("
<<
calI
.
size
()
<<
") and Observed Error ("
<<
obsE
.
size
()
<<
") have different number of elements."
;
throw
std
::
runtime_error
(
errss
.
str
());
}
if
(
obsI
.
size
()
==
0
)
{
throw
std
::
runtime_error
(
"getRFactor(): the input arrays are empty."
);
}
double
sumnom
=
0
;
double
sumdenom
=
0
;
...
...
Code/Mantid/Framework/Kernel/test/StatisticsTest.h
View file @
f1bdd9e0
...
...
@@ -143,8 +143,45 @@ public:
double
rwp
=
getRFactor
(
obsY
,
calY
,
obsE
);
TS_ASSERT_DELTA
(
rwp
,
0.1582
,
0.0001
);
}
/** Test throw exception
*/
void
testRwpException1
()
{
vector
<
double
>
obsY
(
4
);
vector
<
double
>
calY
(
4
);
vector
<
double
>
obsE
(
3
);
obsY
[
0
]
=
1.0
;
calY
[
0
]
=
1.1
;
obsE
[
0
]
=
1.0
;
obsY
[
1
]
=
2.0
;
calY
[
1
]
=
2.1
;
obsE
[
1
]
=
1.2
;
obsY
[
2
]
=
3.0
;
calY
[
2
]
=
3.5
;
obsE
[
2
]
=
1.4
;
obsY
[
3
]
=
1.0
;
calY
[
3
]
=
1.3
;
TS_ASSERT_THROWS_ANYTHING
(
getRFactor
(
obsY
,
calY
,
obsE
));
}
/** Test throw exception on empty array
*/
void
testRwpException2
()
{
vector
<
double
>
obsY
;
vector
<
double
>
calY
;
vector
<
double
>
obsE
;
TS_ASSERT_THROWS_ANYTHING
(
getRFactor
(
obsY
,
calY
,
obsE
));
}
};
#endif // STATISTICSTEST_H_
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment