Skip to content

Commit 61e6880

Browse files
committed
HPCC-33499 Logic fixes
- Add assert to catch tests that should throw an exception but don't. - Update the implicit prefix test to remove an incorrect assumption that using the implicitly-defined "n" prefix is required when a default namespace is used. Signed-off-by: Terrence Asselin <[email protected]>
1 parent 513192a commit 61e6880

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

testing/unittests/esdltests.cpp

+8-5
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,8 @@ class ESDLTests : public CppUnit::TestFixture
368368
scriptContext->setTraceToStdout(false);
369369
runTransform(scriptContext, scriptXml, ESDLScriptCtxSection_ESDLRequest, ESDLScriptCtxSection_FinalRequest, testname);
370370

371+
CPPUNIT_ASSERT_EQUAL_MESSAGE(VStringBuffer("Expected exception %d not thrown", code), code, 0);
372+
371373
StringBuffer output;
372374
scriptContext->toXML(output.clear(), ESDLScriptCtxSection_FinalRequest);
373375

@@ -381,9 +383,9 @@ class ESDLTests : public CppUnit::TestFixture
381383
{
382384
StringBuffer m;
383385
int actualErrorCode = E->errorCode();
384-
VStringBuffer comparison("Expected Exception: code=%d \nActual Exception: code=%d, message=%s", code, actualErrorCode, E->errorMessage(m).str());
386+
VStringBuffer message("Exception message: %s", E->errorMessage(m).str());
385387
E->Release();
386-
CPPUNIT_ASSERT_EQUAL_MESSAGE(comparison.str(), code, actualErrorCode);
388+
CPPUNIT_ASSERT_EQUAL_MESSAGE(message.str(), code, actualErrorCode);
387389
}
388390
}
389391

@@ -535,11 +537,12 @@ class ESDLTests : public CppUnit::TestFixture
535537
</config>
536538
)!!";
537539

540+
// The previous version of this test was incorrect in asserting the implicit 'n' prefix was required.
541+
// "implicit-prefix" shows that it can be used.
538542
runTest("implicit-prefix", esdlImplicitNamespaceSelectPath, soapRequestImplicitPrefix, config, implicitPrefixResult, 0);
539543

540-
// The implicit 'n' prefix is required if the content has a namespace defined
541-
// with no prefix. This test is expected to throw an exception.
542-
runTest("implicit-prefix-not-used", esdlImplicitNamespaceSelectPath, soapRequestImplicitPrefix, configNoPrefix, implicitPrefixResult, 99);
544+
// "implicit-prefix-not-used" shows that it is optional.
545+
runTest("implicit-prefix-not-used", esdlImplicitNamespaceSelectPath, soapRequestImplicitPrefix, configNoPrefix, implicitPrefixResult, 0);
543546
}
544547

545548
void testEsdlTransformRequestNamespaces()

0 commit comments

Comments
 (0)