Skip to content

Commit 8bb82c9

Browse files
committed
Fix WorkspacePropertyTest for debug/release different behaviour.
1 parent 0d87c9b commit 8bb82c9

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

Framework/API/test/WorkspacePropertyTest.h

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,15 @@ class WorkspacePropertyTest : public CxxTest::TestSuite {
122122
// valid
123123
TS_ASSERT_EQUALS(wsp2->setValue("ws2"), "");
124124
TS_ASSERT_EQUALS(wsp2->isValid(), "");
125-
// Setting an invalid name should make wsp6 invalid
125+
126+
// Setting an invalid name should make wsp6 invalid but currently only in debug mode.
126127
std::string invalidWorkspaceName = "ws6-1";
127-
std::string error =
128+
std::string error = "";
129+
#ifndef NDEBUG
130+
error =
128131
"Invalid object name '" + invalidWorkspaceName +
129132
"'. Names must start with a letter or underscore and contain only alpha-numeric characters and underscores.";
133+
#endif
130134
TS_ASSERT_EQUALS(wsp6->setValue(invalidWorkspaceName), error);
131135
TS_ASSERT_EQUALS(wsp6->isValid(), error);
132136

@@ -351,17 +355,19 @@ class WorkspacePropertyTest : public CxxTest::TestSuite {
351355
void test_trimmming_off() {
352356
Workspace_sptr ws = WorkspaceFactory::Instance().create("WorkspacePropertyTest", 1, 1, 1);
353357
std::string wsNameWithWhitespace = " space1\t\n";
354-
AnalysisDataService::Instance().add("space1", ws);
358+
AnalysisDataService::Instance().add(wsNameWithWhitespace, ws);
355359
WorkspaceProperty<Workspace> p("workspace1", "", Direction::Input);
356360
// turn trimming off
357361
p.setAutoTrim(false);
358362

359-
std::string expectedError =
363+
std::string expectedError = "";
364+
#ifndef NDEBUG
365+
expectedError =
360366
"Invalid object name '" + wsNameWithWhitespace +
361367
"'. Names must start with a letter or underscore and contain only alpha-numeric characters and underscores.";
362-
363-
// setValue() should return an error string if illegal workspace name is provided.
364-
TS_ASSERT_EQUALS(p.setValue(wsNameWithWhitespace), "expectedError");
368+
#endif
369+
// setValue() should return an error string in debug mode if illegal workspace name is provided.
370+
TS_ASSERT_EQUALS(p.setValue(wsNameWithWhitespace), expectedError);
365371

366372
AnalysisDataService::Instance().clear();
367373
}

0 commit comments

Comments
 (0)