当前位置: 首页>>代码示例>>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;未经允许,请勿转载。