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
a3757c7d
Commit
a3757c7d
authored
May 03, 2013
by
Gigg, Martyn Anthony
Browse files
Add null pointer check to FunctionProperty::value.
Also updates the unit test to test for this behaviour. Refs #7004
parent
797e174f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Code/Mantid/Framework/API/src/FunctionProperty.cpp
View file @
a3757c7d
...
...
@@ -62,7 +62,8 @@ namespace API
*/
std
::
string
FunctionProperty
::
value
()
const
{
return
m_value
->
asString
();
if
(
m_value
)
return
m_value
->
asString
();
else
return
getDefault
();
}
/** Get the value the property was initialised with -its default value
...
...
@@ -99,7 +100,7 @@ namespace API
*/
std
::
string
FunctionProperty
::
isValid
()
const
{
return
isDefault
()
?
"Funcion is empty."
:
""
;
return
isDefault
()
?
"Func
t
ion is empty."
:
""
;
}
/** Indicates if the function has not been created yet.
...
...
Code/Mantid/Framework/API/test/FunctionPropertyTest.h
View file @
a3757c7d
...
...
@@ -41,6 +41,8 @@ public:
void
testValue
()
{
FunctionProperty
prop
(
"fun"
);
TS_ASSERT_EQUALS
(
""
,
prop
.
value
());
std
::
string
error
;
TS_ASSERT_THROWS_NOTHING
(
error
=
prop
.
setValue
(
"name=FunctionPropertyTest_Function,A=3"
));
TS_ASSERT
(
error
.
empty
());
...
...
Code/Mantid/Framework/PythonInterface/test/python/mantid/api/FunctionPropertyTest.py
View file @
a3757c7d
...
...
@@ -30,6 +30,11 @@ class FunctionPropertyTest(unittest.TestCase):
func
=
FunctionProperty
(
"fun"
)
self
.
assertEqual
(
"Function"
,
func
.
type
)
def
test_value_is_empty_string_for_default_property
(
self
):
func
=
FunctionProperty
(
"name"
)
self
.
assertEquals
(
None
,
func
.
value
)
self
.
assertEquals
(
""
,
func
.
valueAsStr
)
def
test_valid_string_value_gives_function_object_as_value
(
self
):
alg
=
self
.
TestFunctionPropAlg
()
alg
.
initialize
()
...
...
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