本文整理汇总了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);
}
示例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);
}
示例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;
}
示例4: CuTestNew
CuTest* CuTestNew(const char* name, TestFunction function) {
CuTest* tc = NULL;
if (ALLOC(tc) < 0)
die_oom();
CuTestInit(tc, name, function);
return tc;
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}