當前位置: 首頁>>代碼示例>>C++>>正文


C++ CuTestInit函數代碼示例

本文整理匯總了C++中CuTestInit函數的典型用法代碼示例。如果您正苦於以下問題:C++ CuTestInit函數的具體用法?C++ CuTestInit怎麽用?C++ CuTestInit使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了CuTestInit函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。

示例1: TestCuSuiteDetails_SingleFail

void TestCuSuiteDetails_SingleFail(CuTest* tc)
{
	CuSuite ts;
	CuTest tc1, tc2;
	CuString details;
	const char* front;
	const char* back;

	CuSuiteInit(&ts);
	CuTestInit(&tc1, "TestPasses", TestPasses);
	CuTestInit(&tc2, "TestFails",  zTestFails);
	CuStringInit(&details);

	CuSuiteAdd(&ts, &tc1);
	CuSuiteAdd(&ts, &tc2);
	CuSuiteRun(&ts);

	CuSuiteDetails(&ts, &details);

	CuAssertTrue(tc, ts.count == 2);
	CuAssertTrue(tc, ts.failCount == 1);

	front = "There was 1 failure:\n"
		"1) TestFails: ";
	back =  "test should fail\n"
		"\n!!!FAILURES!!!\n"
		"Runs: 2 Passes: 1 Fails: 1\n";

	CuAssertStrEquals(tc, back, details.buffer + strlen(details.buffer) - strlen(back));
	details.buffer[strlen(front)] = 0;
	CuAssertStrEquals(tc, front, details.buffer);
}
開發者ID:jvbenavi,項目名稱:c_prj,代碼行數:32,代碼來源:CuTestTest.c

示例2: TestCuSuiteDetails_MultiplePasses

void TestCuSuiteDetails_MultiplePasses(CuTest* tc)
{
	CuSuite ts;
	CuTest tc1, tc2;
	CuString details;
	const char* expected;

	CuSuiteInit(&ts);
	CuTestInit(&tc1, "TestPasses", TestPasses);
	CuTestInit(&tc2, "TestPasses", TestPasses);
	CuStringInit(&details);

	CuSuiteAdd(&ts, &tc1);
	CuSuiteAdd(&ts, &tc2);
	CuSuiteRun(&ts);

	CuSuiteDetails(&ts, &details);

	CuAssertTrue(tc, ts.count == 2);
	CuAssertTrue(tc, ts.failCount == 0);

	expected =
		"OK (2 tests)\n";

	CuAssertStrEquals(tc, expected, details.buffer);
}
開發者ID:jvbenavi,項目名稱:c_prj,代碼行數:26,代碼來源:CuTestTest.c

示例3: TestCustomProgressCallback

void TestCustomProgressCallback(CuTest* tc)
{
	CuSuite ts;
	CuTest tc1, tc2, tc3, tc4;
	customProgressCallbackCounter = 0;
	cuPreferences.progressCallback = CustomProgressCallback;

	CuSuiteInit(&ts);
	CuTestInit(&tc1, "TestPasses", TestPasses);
	CuTestInit(&tc2, "TestPasses", TestPasses);
	CuTestInit(&tc3, "TestFails",  zTestFails);
	CuTestInit(&tc4, "TestPasses", TestPasses);

	CuSuiteAdd(&ts, &tc1);
	CuSuiteAdd(&ts, &tc2);
	CuSuiteAdd(&ts, &tc3);
	CuSuiteAdd(&ts, &tc4);
	CuAssertTrue(tc, ts.count == 4);

	CuSuiteRun(&ts);
	CuAssertTrue(tc, ts.count - ts.failCount == 3);
	CuAssertTrue(tc, ts.failCount == 1);
	CuAssertTrue(tc, customProgressCallbackCounter == 4);
	cuPreferences.progressCallback = NULL;
}
開發者ID:asheidan,項目名稱:CuTest,代碼行數:25,代碼來源:CuTestTest.c

示例4: CuTestNew

CuTest* CuTestNew(const char* name, TestFunction function) {
	CuTest* tc = NULL;
    if (ALLOC(tc) < 0)
        die_oom();
	CuTestInit(tc, name, function);
	return tc;
}
開發者ID:turingmachine,項目名稱:augeas,代碼行數:7,代碼來源:cutest.c

示例5: CuTestNew

CuTest* CuTestNew(const char* name, TestFunction function, TestSetupFunction setup, TestTeardownFunction teardown)
{
	CuTest* tc = CU_ALLOC(CuTest);
	if (tc != NULL)
		CuTestInit(tc, name, function, setup, teardown);
	else
		fprintf(stderr, "%s: %s%s\n", CU_FAIL_HEADER,
		    "Error initializing test case: ", name);
	return tc;
}
開發者ID:galaxyeye,項目名稱:bdb,代碼行數:10,代碼來源:CuTest.c

示例6: TestCuAssertPtrNotNull_Failure

void TestCuAssertPtrNotNull_Failure(CuTest* tc)
{
	CuTest tc2;

	CuTestInit(&tc2, "MyTest", TestPasses);

	/* test failing case */
	CuAssertPtrNotNull(&tc2, NULL);
	CuAssertTrue(tc, tc2.failed);
	CompareAsserts(tc, "CuAssertPtrNotNull failed", "null pointer unexpected", tc2.message);
}
開發者ID:jvbenavi,項目名稱:c_prj,代碼行數:11,代碼來源:CuTestTest.c

示例7: TestCuTestRun

void TestCuTestRun(CuTest* tc)
{
	CuTest tc2;
	CuTestInit(&tc2, "MyTest", zTestFails);
	CuTestRun(&tc2);

	CuAssertStrEquals(tc, "MyTest", tc2.name);
	CuAssertTrue(tc, tc2.failed);
	CuAssertTrue(tc, tc2.ran);
	CompareAsserts(tc, "TestRun failed", "test should fail", tc2.message);
}
開發者ID:jvbenavi,項目名稱:c_prj,代碼行數:11,代碼來源:CuTestTest.c

示例8: TestCuTestInit

void TestCuTestInit(CuTest *tc)
{
	CuTest tc2;
	CuTestInit(&tc2, "MyTest", TestPasses);
	CuAssertStrEquals(tc, "MyTest", tc2.name);
	CuAssertTrue(tc, !tc2.failed);
	CuAssertTrue(tc, tc2.message == NULL);
	CuAssertTrue(tc, tc2.function == TestPasses);
	CuAssertTrue(tc, tc2.ran == 0);
	CuAssertTrue(tc, tc2.jumpBuf == NULL);
}
開發者ID:jvbenavi,項目名稱:c_prj,代碼行數:11,代碼來源:CuTestTest.c

示例9: CuSuiteAddSuite

void CuSuiteAddSuite(CuSuite* testSuite, CuSuite* testSuite2)
{
	int i;
	for (i = 0 ; i < testSuite2->count ; ++i)
	{
		CuTest* testCase = testSuite2->list[i];
		CuTest* newTest = CU_ALLOC(CuTest);
		CuTestInit(newTest, testCase->name, testCase->function);
		CuSuiteAdd(testSuite, newTest);
	}
}
開發者ID:Chris--B,項目名稱:Cprimes,代碼行數:11,代碼來源:CuTest.c

示例10: TestCuAssertPtrNotNull_Success

void TestCuAssertPtrNotNull_Success(CuTest* tc)
{
	CuTest tc2;
	int x;

	CuTestInit(&tc2, "MyTest", TestPasses);

	/* test success case */
	CuAssertPtrNotNull(&tc2, &x);
	CuAssertTrue(tc, ! tc2.failed);
	CuAssertTrue(tc, NULL == tc2.message);
}
開發者ID:jvbenavi,項目名稱:c_prj,代碼行數:12,代碼來源:CuTestTest.c

示例11: TestCuSuiteSummary

void TestCuSuiteSummary(CuTest* tc)
{
	CuSuite ts;
	CuTest tc1, tc2;
	CuString summary;

	CuSuiteInit(&ts);
	CuTestInit(&tc1, "TestPasses", TestPasses);
	CuTestInit(&tc2, "TestFails",  zTestFails);
	CuStringInit(&summary);

	CuSuiteAdd(&ts, &tc1);
	CuSuiteAdd(&ts, &tc2);
	CuSuiteRun(&ts);

	CuSuiteSummary(&ts, &summary);

	CuAssertTrue(tc, ts.count == 2);
	CuAssertTrue(tc, ts.failCount == 1);
	CuAssertStrEquals(tc, ".F\n\n", summary.buffer);
}
開發者ID:jvbenavi,項目名稱:c_prj,代碼行數:21,代碼來源:CuTestTest.c

示例12: TestCuSuiteRun

void TestCuSuiteRun(CuTest* tc)
{
	CuSuite ts;
	CuTest tc1, tc2, tc3, tc4;

	CuSuiteInit(&ts);
	CuTestInit(&tc1, "TestPasses", TestPasses);
	CuTestInit(&tc2, "TestPasses", TestPasses);
	CuTestInit(&tc3, "TestFails",  zTestFails);
	CuTestInit(&tc4, "TestFails",  zTestFails);

	CuSuiteAdd(&ts, &tc1);
	CuSuiteAdd(&ts, &tc2);
	CuSuiteAdd(&ts, &tc3);
	CuSuiteAdd(&ts, &tc4);
	CuAssertTrue(tc, ts.count == 4);

	CuSuiteRun(&ts);
	CuAssertTrue(tc, ts.count - ts.failCount == 2);
	CuAssertTrue(tc, ts.failCount == 2);
}
開發者ID:jvbenavi,項目名稱:c_prj,代碼行數:21,代碼來源:CuTestTest.c

示例13: TestCuSuiteAddTest

void TestCuSuiteAddTest(CuTest* tc)
{
	CuSuite ts;
	CuTest tc2;

	CuSuiteInit(&ts);
	CuTestInit(&tc2, "MyTest", zTestFails);

	CuSuiteAdd(&ts, &tc2);
	CuAssertTrue(tc, ts.count == 1);

	CuAssertStrEquals(tc, "MyTest", ts.list[0]->name);
}
開發者ID:jvbenavi,項目名稱:c_prj,代碼行數:13,代碼來源:CuTestTest.c

示例14: TestCuSuiteDetails_MultipleFails_gcclike

void TestCuSuiteDetails_MultipleFails_gcclike(CuTest* tc)
{
	CuSuite ts;
	CuTest tc1, tc2;
	CuString details;
	const char* front;
	const char* mid;
	const char* back;
	cuPreferences.outputFormat = CuOutputFormat_gcclike;

	CuSuiteInit(&ts);
	CuTestInit(&tc1, "TestFails1", zTestFails);
	CuTestInit(&tc2, "TestFails2", zTestFails);
	CuStringInit(&details);

	CuSuiteAdd(&ts, &tc1);
	CuSuiteAdd(&ts, &tc2);
	CuSuiteRun(&ts);

	CuSuiteDetails(&ts, &details);

	CuAssertTrue(tc, ts.count == 2);
	CuAssertTrue(tc, ts.failCount == 2);

	front =
		"There were 2 failures:\n"
		__FILE__ ":";
	mid =   "test should fail\n"
		__FILE__ ":";
	back =  "test should fail\n"
		"\n!!!FAILURES!!!\n"
		"Runs: 2 Passes: 0 Fails: 2\n";

	CuAssertStrEquals(tc, back, details.buffer + strlen(details.buffer) - strlen(back));
	CuAssert(tc, "Couldn't find middle", strstr(details.buffer, mid) != NULL);
	details.buffer[strlen(front)] = 0;
	CuAssertStrEquals(tc, front, details.buffer);
}
開發者ID:asheidan,項目名稱:CuTest,代碼行數:38,代碼來源:CuTestTest.c

示例15: TestCuAssertPtrEquals_Failure

void TestCuAssertPtrEquals_Failure(CuTest* tc)
{
	CuTest tc2;
	int x;
	int* nullPtr = NULL;
	char expected_message[STRING_MAX];

	CuTestInit(&tc2, "MyTest", TestPasses);

	/* test failing case */
	sprintf(expected_message, "expected pointer <0x%p> but was <0x%p>", nullPtr, &x);
	CuAssertPtrEquals(&tc2, NULL, &x);
	CuAssertTrue(tc, tc2.failed);
	CompareAsserts(tc, "CuAssertPtrEquals failed", expected_message, tc2.message);
}
開發者ID:jvbenavi,項目名稱:c_prj,代碼行數:15,代碼來源:CuTestTest.c


注:本文中的CuTestInit函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。