本文整理汇总了C++中CuStringAppend函数的典型用法代码示例。如果您正苦于以下问题:C++ CuStringAppend函数的具体用法?C++ CuStringAppend怎么用?C++ CuStringAppend使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CuStringAppend函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CuSuiteDetails
void CuSuiteDetails(CuSuite* testSuite, CuString* details)
{
int i;
int failCount = 0;
if (testSuite->failCount == 0)
{
int passCount = testSuite->count - testSuite->failCount;
const char* testWord = passCount == 1 ? "test" : "tests";
CuStringAppendFormat(details, "OK (%d %s)\n", passCount, testWord);
}
else
{
if (testSuite->failCount == 1)
CuStringAppend(details, "There was 1 failure:\n");
else
CuStringAppendFormat(details, "There were %d failures:\n", testSuite->failCount);
for (i = 0 ; i < testSuite->count ; ++i)
{
CuTest* testCase = testSuite->list[i];
if (testCase->failed)
{
failCount++;
CuStringAppendFormat(details, "%d) %s: %s\n",
failCount, testCase->name, testCase->message);
}
}
CuStringAppend(details, "\n!!!FAILURES!!!\n");
CuStringAppendFormat(details, "Runs: %d ", testSuite->count);
CuStringAppendFormat(details, "Passes: %d ", testSuite->count - testSuite->failCount);
CuStringAppendFormat(details, "Fails: %d\n", testSuite->failCount);
}
}
示例2: CuSuiteSummary
void CuSuiteSummary(CuSuite *testSuite, CuString *summary) {
int i;
for (i = 0; i < testSuite->count; ++i) {
CuTest *testCase = testSuite->list[i];
CuStringAppend(summary, testCase->failed ? "F" : ".");
}
CuStringAppend(summary, "\n\n");
}
示例3: TestCuStringAppend
void TestCuStringAppend(CuTest* tc)
{
CuString* str = CuStringNew();
CuStringAppend(str, "hello");
CuAssertIntEquals(tc, 5, str->length);
CuAssertStrEquals(tc, "hello", str->buffer);
CuStringAppend(str, " world");
CuAssertIntEquals(tc, 11, str->length);
CuAssertStrEquals(tc, "hello world", str->buffer);
}
示例4: CuFail_Line
void CuFail_Line(CuTest *tc, const char *file, int line, const char *message2, const char *message) {
CuString string;
CuStringInit(&string);
if (message2 != NULL) {
CuStringAppend(&string, message2);
CuStringAppend(&string, ": ");
}
CuStringAppend(&string, message);
CuFailInternal(tc, file, line, &string);
}
示例5: TestCuStringAppendNULL
void TestCuStringAppendNULL(CuTest* tc)
{
CuString* str = CuStringNew();
CuStringAppend(str, NULL);
CuAssertIntEquals(tc, 4, str->length);
CuAssertStrEquals(tc, "NULL", str->buffer);
}
示例6: CuStringAppendChar
void CuStringAppendChar(CuString* str, char ch)
{
char text[2];
text[0] = ch;
text[1] = '\0';
CuStringAppend(str, text);
}
示例7: CuStringAppendChar
int CuStringAppendChar(CuString* str, char ch, int dump)
{
char text[2];
text[0] = ch;
text[1] = '\0';
return (CuStringAppend(str, text, dump));
}
示例8: CuStringAppendFormat
void CuStringAppendFormat(CuString *str, const char *format, ...) {
va_list argp;
char buf[HUGE_STRING_LEN];
va_start(argp, format);
vsprintf(buf, format, argp);
va_end(argp);
CuStringAppend(str, buf);
}
示例9: CuAssertStrnEquals_LineMsg
void CuAssertStrnEquals_LineMsg(CuTest* tc, const char* file, int line, const char* message,
const char* expected, size_t explen,
const char* actual)
{
CuString string;
if ((explen == 0) ||
(expected == NULL && actual == NULL) ||
(expected != NULL && actual != NULL &&
strncmp(expected, actual, explen) == 0))
{
return;
}
CuStringInit(&string);
if (message != NULL)
{
CuStringAppend(&string, message);
CuStringAppend(&string, ": ");
}
CuStringAppend(&string, "expected <");
CuStringAppend(&string, expected);
CuStringAppend(&string, "> but was <");
CuStringAppend(&string, actual);
CuStringAppend(&string, ">");
CuFailInternal(tc, file, line, &string);
}
示例10: CuStringAppendFormat
int CuStringAppendFormat(CuString* str, int dump, const char* format, ...)
{
va_list argp;
char buf[HUGE_STRING_LEN];
va_start(argp, format);
vsprintf(buf, format, argp);
va_end(argp);
return (CuStringAppend(str, buf, dump));
}
示例11: CuStringAppendFormat
void CuStringAppendFormat(CuString* str, const char* format, ...)
{
va_list argp;
// http://www.eclipse.org/forums/index.php/t/236510/
char buf[HUGE_STRING_LEN];
va_start(argp, format);
vsprintf(buf, format, argp);
va_end(argp);
CuStringAppend(str, buf);
}
示例12: TestCuStringResizes
void TestCuStringResizes(CuTest* tc)
{
CuString* str = CuStringNew();
int i;
for(i = 0 ; i < STRING_MAX ; ++i)
{
CuStringAppend(str, "aa");
}
CuAssertTrue(tc, STRING_MAX * 2 == str->length);
CuAssertTrue(tc, STRING_MAX * 2 <= str->size);
}
示例13: CuSuiteSummary
void CuSuiteSummary(CuSuite* testSuite, CuString* summary)
{
/*
Dots used to separate test names with status. I want F or P at
column 60, so there are 59 dots here.
*/
static const char spacer []= "...........................................................";
int i;
for (i = 0 ; i < testSuite->count ; ++i)
{
CuTest* testCase = testSuite->list[i];
CuStringAppend(summary, testCase->name);
/* Bad things happen with really long names */
if (strlen(testCase->name) < sizeof(spacer) * sizeof(char))
{
CuStringAppend(summary, spacer + strlen(testCase->name));
}
CuStringAppend(summary, testCase->failed ? "F\n" : "P\n");
}
CuStringAppend(summary, "\n\n");
}
示例14: TestCuStringInserts
void TestCuStringInserts(CuTest* tc)
{
CuString* str = CuStringNew();
CuStringAppend(str, "world");
CuAssertIntEquals(tc, 5, str->length);
CuAssertStrEquals(tc, "world", str->buffer);
CuStringInsert(str, "hell", 0);
CuAssertIntEquals(tc, 9, str->length);
CuAssertStrEquals(tc, "hellworld", str->buffer);
CuStringInsert(str, "o ", 4);
CuAssertIntEquals(tc, 11, str->length);
CuAssertStrEquals(tc, "hello world", str->buffer);
CuStringInsert(str, "!", 11);
CuAssertIntEquals(tc, 12, str->length);
CuAssertStrEquals(tc, "hello world!", str->buffer);
}
示例15: CuStringConvertCStr
/** \brief Converts c_str(char *) to CuString
*
* \param const char* text
* \return CuString* string with content of c_str
*
*/
CuString* CuStringConvertCStr(const char* text){
CuString *str = CuStringNew();
CuStringAppend(str, text);//NULL is handled by Append
return str;
}