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); }
CuSuite* CuSuiteNew(void) { CuSuite* testSuite = NULL; if (ALLOC(testSuite) < 0) die_oom(); CuSuiteInit(testSuite); return testSuite; }
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); }
void TestCuSuiteInit(CuTest* tc) { CuSuite ts; CuSuiteInit(&ts); CuAssertTrue(tc, ts.count == 0); CuAssertTrue(tc, ts.failCount == 0); }
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; }
CuSuite* m_boolean_get_test_suite(void) { static CuSuite suite; CuSuiteInit(&suite); SUITE_ADD_TEST(&suite, test_m_boolean); return &suite; }
CuSuite* m_pointer_get_test_suite(void) { static CuSuite suite; CuSuiteInit(&suite); SUITE_ADD_TEST(&suite, test_m_pointer); return &suite; }
CuSuite* CuSuiteNew(const char *name, SuiteSetupFunction setup, SuiteTeardownFunction teardown) { CuSuite* testSuite = CU_ALLOC(CuSuite); if (testSuite != NULL) CuSuiteInit(testSuite, name, setup, teardown); else fprintf(stderr, "%s: %s%s\n", CU_FAIL_HEADER, "Error initializing test suite: ", name); return testSuite; }
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); }
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); }
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); }
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); }
CuSuite* CuSuiteNew(void) { CuSuite* testSuite = CU_ALLOC(CuSuite); CuSuiteInit(testSuite); return testSuite; }
CuSuite* CuSuiteNew(char* name) { CuSuite* testSuite = CU_ALLOC(CuSuite); CuSuiteInit(testSuite, name); return testSuite; }