void CheckResult(int lineno, const BaseTestDatum &test, ib_status_t rc, ib_flags_t exresult, ib_flags_t result) { std::string s1, s2; EXPECT_EQ(IB_OK, rc) << "Line " << lineno << ": " << Stringize(test) << " returned " << rc; if (rc != IB_OK) { return; } // NEWBUF and ALIAS result flags should never both be set bool both = ib_flags_all(result, IB_STRFLAG_NEWBUF|IB_STRFLAG_ALIAS); ASSERT_FALSE(both) << "Line " << lineno << ": " << Stringize(test) << " both NEWBUF and ALIAS result flags are set!" << ResultStr(result, s1); // Build the expected output EXPECT_EQ(exresult, result) << "Line " << lineno << ": " << Stringize(test) << " expected result=" << ResultStr(exresult, s1) << exresult << " actual=" << ResultStr(result, s2) << result; }
void CheckResults(const TestDatum &test, ib_status_t rc, ib_flags_t result) { const TextBuf &exout = ExpectedOut(test); bool exmod = (exout != test.InBuf()); ib_flags_t exresult = ExpectedResult( Op(), exmod ); CheckResult(test.LineNo(), test, rc, exresult, result); const char *out = m_outbuf.GetBuf(); if (out != NULL) { size_t outlen = m_outbuf.GetLen(); size_t exlen = exout.GetLen(); EXPECT_EQ(exlen, outlen) << "Line " << test.LineNo() << ": " << Stringize(test) << " expected len=" << exlen << ", actual len=" << outlen; EXPECT_TRUE(exout == m_outbuf) << "Line " << test.LineNo() << ": " << Stringize(test) << " expected=\"" << exout.GetFmt() << "\"" << " actual=\"" << m_outbuf.GetFmt() << "\""; } }
virtual void CheckResults(const TestDatum &test, ib_status_t rc, ib_flags_t result) { size_t lno = test.LineNo(); const char *out = m_outbuf.GetBuf(); const TextBuf &exout = ExpectedOut(test); bool exmod = (test.InBuf() != exout); ib_flags_t exresult = ExpectedResult(Op(), exmod); CheckResult(lno, test, rc, exresult, result); EXPECT_STRNE(NULL, out) << "Line " << lno << ": " << Stringize(test) << " Data out is NULL"; if (out != NULL) { const char *exbuf = exout.GetBuf(); EXPECT_STREQ(exbuf, out) << "Line " << lno << ": " << Stringize(test) << " expected=\"" << exout.GetFmt() << " actual=\"" << m_outbuf.GetFmt() << "\""; } }
void RunTestImpl(int line, const char *haystack, size_t haystack_len, const char *needle, size_t needle_len, const char *expected) { const char *result = ib_strrstr_ex(haystack, haystack_len, needle, needle_len); const int blen = 256; char b1[blen]; char b2[blen]; char b3[blen]; EXPECT_STREQ(expected, result) << "Line " << line << ": " << Stringize("strrstr", haystack, haystack_len, needle, needle_len, b1, blen) << " expected " << Stringize(expected, b3, blen) << " returned " << Stringize(result, b2, blen); }
static void DoPragma (void) /* Handle a #pragma line by converting the #pragma preprocessor directive into * the _Pragma() compiler operator. */ { /* Skip blanks following the #pragma directive */ SkipWhitespace (0); /* Copy the remainder of the line into MLine removing comments and ws */ SB_Clear (MLine); Pass1 (Line, MLine); /* Convert the directive into the operator */ SB_CopyStr (Line, "_Pragma ("); SB_Reset (MLine); Stringize (MLine, Line); SB_AppendChar (Line, ')'); /* Initialize reading from line */ SB_Reset (Line); InitLine (Line); }
static void MacroArgSubst (MacroExp* E) /* Argument substitution according to ISO/IEC 9899:1999 (E), 6.10.3.1ff */ { ident Ident; int ArgIdx; StrBuf* OldSource; StrBuf* Arg; int HaveSpace; /* Remember the current input and switch to the macro replacement. */ int OldIndex = SB_GetIndex (&E->M->Replacement); SB_Reset (&E->M->Replacement); OldSource = InitLine (&E->M->Replacement); /* Argument handling loop */ while (CurC != '\0') { /* If we have an identifier, check if it's a macro */ if (IsSym (Ident)) { /* Check if it's a macro argument */ if ((ArgIdx = FindMacroArg (E->M, Ident)) >= 0) { /* A macro argument. Get the corresponding actual argument. */ Arg = ME_GetActual (E, ArgIdx); /* Copy any following whitespace */ HaveSpace = SkipWhitespace (0); /* If a ## operator follows, we have to insert the actual * argument as is, otherwise it must be macro replaced. */ if (CurC == '#' && NextC == '#') { /* ### Add placemarker if necessary */ SB_Append (&E->Replacement, Arg); } else { /* Replace the formal argument by a macro replaced copy * of the actual. */ SB_Reset (Arg); MacroReplacement (Arg, &E->Replacement); /* If we skipped whitespace before, re-add it now */ if (HaveSpace) { SB_AppendChar (&E->Replacement, ' '); } } } else { /* An identifier, keep it */ SB_AppendStr (&E->Replacement, Ident); } } else if (CurC == '#' && NextC == '#') { /* ## operator. */ NextChar (); NextChar (); SkipWhitespace (0); /* Since we need to concatenate the token sequences, remove * any whitespace that was added to target, since it must come * from the input. */ while (IsSpace (SB_LookAtLast (&E->Replacement))) { SB_Drop (&E->Replacement, 1); } /* If the next token is an identifier which is a macro argument, * replace it, otherwise do nothing. */ if (IsSym (Ident)) { /* Check if it's a macro argument */ if ((ArgIdx = FindMacroArg (E->M, Ident)) >= 0) { /* Get the corresponding actual argument and add it. */ SB_Append (&E->Replacement, ME_GetActual (E, ArgIdx)); } else { /* Just an ordinary identifier - add as is */ SB_AppendStr (&E->Replacement, Ident); } } } else if (CurC == '#' && E->M->ArgCount >= 0) { /* A # operator within a macro expansion of a function like * macro. Read the following identifier and check if it's a * macro parameter. */ NextChar (); SkipWhitespace (0); if (!IsSym (Ident) || (ArgIdx = FindMacroArg (E->M, Ident)) < 0) { PPError ("`#' is not followed by a macro parameter"); } else { /* Make a valid string from Replacement */ Arg = ME_GetActual (E, ArgIdx); SB_Reset (Arg); Stringize (Arg, &E->Replacement); } } else if (IsQuote (CurC)) { CopyQuotedString (&E->Replacement); } else { SB_AppendChar (&E->Replacement, CurC); NextChar (); } } #if 0 /* Remove whitespace from the end of the line */ while (IsSpace (SB_LookAtLast (&E->Replacement))) { SB_Drop (&E->Replacement, 1); } #endif /* Switch back the input */ InitLine (OldSource); SB_SetIndex (&E->M->Replacement, OldIndex); }