void SendACompareFailure (const char *const pMsg)

ConcurrencyrsSequentialConcurrencyVisibilityrsProtected

Code
// This method takes the input string pMsg, prefixes it with
// "$# FAIL <i> <m> #$ " where <i> is the instance index and <m> is the current
// message index and terminates it with a carriage return and a newline.
// The message is sent to the test harness as a CompareFailure. CompareFailure's are
// saved with the sequence diagram generated from the trace of the test run.
// The special prefix is used by Quality Architect's custom comparison feature.
// NOTE: this method relies on the member variables nInstanceIndex and
// nCurrentMessageIndex being set to the correct values. The driver generator
// for Quality Architect generates code to set the values in the driver state machine.
// nInstanceIndex is not necessarily the left-to-right instance number from
// the sequence diagram. Use the "Find In" context menu on the generated
// test driver to see the instance index value.
// nCurrentMessageIndex is not necessarily the top-to-bottom message number
// from the sequence diagram. Use the "Find In" context menu on the generated
// test driver to see the message index value.

int nTotalLen = 0;
int nILen;
int nMLen;
int nMsgLen;
char istr[30];
char mstr[30];

nILen = RTFormat::_int(nInstanceIndex, istr, 30);
nMLen = RTFormat::_int(nCurrentMessageIndex, mstr, 30);
nMsgLen = RTMemoryUtil::strlen(pMsg);
nTotalLen = 8 + nILen + 1 + nMLen + 4 + nMsgLen + 3;

char *pFailMsg = new char [nTotalLen];
if (!pFailMsg)
{
    RQARTExceptionCode exCode = eRQARTMemoryError;
    RQART_Exception.error(RTTypedValue(&exCode)).raise();
    return;
}
char *pStr = pFailMsg;
RTMemoryUtil::strcpy(pStr, "$# FAIL ");
pStr += 8;
RTMemoryUtil::strcpy(pStr, istr);
pStr += nILen;
RTMemoryUtil::strcpy(pStr, " ");
pStr += 1;
RTMemoryUtil::strcpy(pStr, mstr);
pStr += nMLen;
RTMemoryUtil::strcpy(pStr, " #$ ");
pStr += 4;
RTMemoryUtil::strcpy(pStr, pMsg);
pStr += nMsgLen;
RTMemoryUtil::strcpy(pStr, "\r\n");

RTString rtStr(pFailMsg);
delete [] pFailMsg;

RQART_TestHarness.CompareFailure(rtStr).send();


Parameter pMsg