| 1 |
// Copyright (c) Microsoft. All rights reserved. |
| 2 |
// Licensed under the MIT license. See LICENSE file in the project root for full license information. |
| 3 |
|
| 4 |
#include "ctest.h" |
| 5 |
|
| 6 |
int main() |
| 7 |
{ |
| 8 |
size_t failedTests = 0; |
| 9 |
|
| 10 |
/* This first suite is ran without counting failed tests to prove that the argument is optional. */ |
| 11 |
CTEST_RUN_TEST_SUITE(SimpleTestSuiteOneTest); |
| 12 |
|
| 13 |
{ |
| 14 |
size_t temp_failed_tests = 0; |
| 15 |
CTEST_RUN_TEST_SUITE(enum_define_tests, temp_failed_tests); |
| 16 |
if (temp_failed_tests != 2) // 2 expected failing tests |
| 17 |
{ |
| 18 |
failedTests++; |
| 19 |
} |
| 20 |
} |
| 21 |
CTEST_RUN_TEST_SUITE(SimpleTestSuiteOneTest, failedTests); |
| 22 |
CTEST_RUN_TEST_SUITE(SimpleTestSuiteTwoTests, failedTests); |
| 23 |
CTEST_RUN_TEST_SUITE(TestSuiteInitializeCleanupTests, failedTests); |
| 24 |
CTEST_RUN_TEST_SUITE(AssertSuccessTests, failedTests); |
| 25 |
{ |
| 26 |
// tests with regular assert failures, no special messages |
| 27 |
size_t temp_failed_tests = 0; |
| 28 |
CTEST_RUN_TEST_SUITE(AssertFailureTests, temp_failed_tests); |
| 29 |
if (temp_failed_tests != 75) |
| 30 |
{ |
| 31 |
failedTests ++; |
| 32 |
} |
| 33 |
} |
| 34 |
{ |
| 35 |
// tests with assert failures with printf like messages |
| 36 |
size_t temp_failed_tests = 0; |
| 37 |
CTEST_RUN_TEST_SUITE(AssertFailureTestsWithPrintfLikeMsgs, temp_failed_tests); |
| 38 |
if (temp_failed_tests != 38) |
| 39 |
{ |
| 40 |
failedTests++; |
| 41 |
} |
| 42 |
} |
| 43 |
CTEST_RUN_TEST_SUITE(TestFunctionInitializeTests, failedTests); |
| 44 |
CTEST_RUN_TEST_SUITE(TestFunctionCleanupTests, failedTests); |
| 45 |
|
| 46 |
{ |
| 47 |
size_t temp_failed_tests = 0; |
| 48 |
CTEST_RUN_TEST_SUITE(whentestfunctioninitializefailstests, temp_failed_tests); |
| 49 |
if (temp_failed_tests != 2) |
| 50 |
{ |
| 51 |
failedTests ++; |
| 52 |
} |
| 53 |
} |
| 54 |
{ |
| 55 |
size_t temp_failed_tests = 0; |
| 56 |
CTEST_RUN_TEST_SUITE(whentestsuiteinitializefailstests, temp_failed_tests); |
| 57 |
if (temp_failed_tests != 1) |
| 58 |
{ |
| 59 |
failedTests ++; |
| 60 |
} |
| 61 |
} |
| 62 |
|
| 63 |
{ |
| 64 |
size_t temp_failed_tests = 0; |
| 65 |
CTEST_RUN_TEST_SUITE(testfunctioncleanupfailstests, temp_failed_tests); |
| 66 |
if (temp_failed_tests != 2) |
| 67 |
{ |
| 68 |
failedTests ++; |
| 69 |
} |
| 70 |
} |
| 71 |
|
| 72 |
{ |
| 73 |
size_t temp_failed_tests = 0; |
| 74 |
CTEST_RUN_TEST_SUITE(TestSuiteCleanupTests, temp_failed_tests); |
| 75 |
if (temp_failed_tests == 0) /*the tests in TestSuiteCleanupTests HAVE to fail*/ |
| 76 |
{ |
| 77 |
failedTests++; |
| 78 |
} |
| 79 |
} |
| 80 |
|
| 81 |
{ |
| 82 |
size_t temp_failed_tests = 0; |
| 83 |
CTEST_RUN_TEST_SUITE(TestSuiteCleanupTests2, temp_failed_tests); |
| 84 |
if (temp_failed_tests == 0) /*the tests in TestSuiteCleanupTests HAVE to fail*/ |
| 85 |
{ |
| 86 |
failedTests++; |
| 87 |
} |
| 88 |
} |
| 89 |
|
| 90 |
#if defined _MSC_VER |
| 91 |
{ |
| 92 |
size_t temp_failed_tests = 0; |
| 93 |
CTEST_RUN_TEST_SUITE(WindowsTypesTests, temp_failed_tests); |
| 94 |
if (temp_failed_tests != 5) // 5 expected failing tests |
| 95 |
{ |
| 96 |
failedTests++; |
| 97 |
} |
| 98 |
} |
| 99 |
#endif |
| 100 |
|
| 101 |
return failedTests; |
| 102 |
} |