Beispiel #1
0
void CuSuiteDetails(CuSuite* testSuite, CuString* details)
{
	int i;
	int failCount = 0;
	int skipCount = 0;

	if (testSuite->failCount == 0)
	{
		int passCount = testSuite->count - testSuite->failCount - testSuite->skipCount;
		const char* testWord = passCount == 1 ? "test" : "tests";
		CuStringAppendFormat(details, "OK (%d %s)\n", passCount, testWord);
	}
	if (testSuite->skipCount != 0) {
		if (testSuite->failCount == 0)
			CuStringAppend(details, "\n");

		if (testSuite->skipCount > 0) {
			const char* testWord = testSuite->skipCount == 1 ? "test" : "tests";
			CuStringAppendFormat(details, "There were %d skipped %s:\n", testSuite->skipCount, testWord);

			for (i = 0 ; i < testSuite->count ; ++i) {
				CuTest* testCase = testSuite->list[i];
				if (testCase->skip) 	{
					skipCount++;
					CuStringAppendFormat(details, "%d) %s: %s Skipped by %s.\n",
						skipCount, testCase->name, testCase->skipMessage, testCase->skippedBy);
				}
			}
		}

	CuStringAppend(details, "\n");
	}

	if (testSuite->failCount != 0) {
		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);
	}


}
Beispiel #2
0
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  Summary  \n");

		CuStringAppendFormat(details, "Runs:\t%3d\n",   testSuite->count);
		CuStringAppendFormat(details, "Passes:\t%3d\n", testSuite->count - testSuite->failCount);
		CuStringAppendFormat(details, "Fails:\t%3d\n",  testSuite->failCount);
	}
}
Beispiel #3
0
void TestCuStringAppendFormat(CuTest* tc)
{
	int i;
	char* text = CuStrAlloc(301);		/* long string */
	CuString* str = CuStringNew();
	for (i = 0 ; i < 300 ; ++i)
		text[i] = 'a';
	text[300] = '\0';
	CuStringAppendFormat(str, "%s", text);

	/* buffer limit raised to HUGE_STRING_LEN so no overflow */

	CuAssert(tc, "length of str->buffer is 300", 300 == strlen(str->buffer));
}
Beispiel #4
0
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++;
                if (NULL == testCase->file)
                {
                    CuStringAppendFormat(details, "%d) %s: %s\n",
                                         failCount, testCase->name, testCase->message);
                }
                else
                {
                    char buffer[HUGE_STRING_LEN];
                    cuPreferences.outputFormat(buffer, testCase, failCount);
                    CuStringAppend(details, buffer);
                }
            }
        }
        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);
    }
}