void Vector2iTestSuite() { TestSuite suite; suite.emplace_back(TestAdd, "TestAdd"); suite.emplace_back(TestEquals, "TestEquals"); suite.emplace_back(TestNegation, "TestNegation"); suite.emplace_back(TestSub, "TestSub"); suite.emplace_back(TestLength, "TestLength"); suite.emplace_back(TestScale, "TestScale"); suite.emplace_back(TestPlusEquals, "TestPlusEquals"); suite.emplace_back(TestMinusEquals, "TestMinusEquals"); RunSuite(suite, "Vector2i"); }
int main(int argc, char **argv) { #define MAX_CASES 1000 extern char *optarg; extern int optind; char *suites[MAX_CASES], *tests[MAX_CASES]; int ch, failed, i, num_suites, num_tests, verbose; char *test; progname = argv[0]; num_suites = num_tests = verbose = 0; while ((ch = getopt(argc, argv, "s:t:v")) != EOF) switch (ch) { case 's': append_case(suites, &num_suites, optarg); break; case 't': append_case(tests, &num_tests, optarg); break; case 'v': verbose = 1; break; case '?': default: return (usage()); } argc -= optind; argv += optind; if (argc != 0) return (usage()); /* Setup the assert to override the default DB one. */ db_env_set_func_assert(CuTestAssertForDb); failed = 0; if (num_tests == 0 && num_suites == 0) failed = RunAllSuites(); else { for(i = 0; i < num_suites; i++) failed += RunSuite(suites[i]); for(i = 0; i < num_tests; i++) { test = strchr(tests[i], ':'); if (test == NULL) { fprintf(stderr, "Invalid test case: %s\n", tests[i]); continue; } /* * Replace the ':' with NULL, to split the current * value into two strings. */ *test = '\0'; ++test; failed += RunTest(tests[i], test); } } while(num_suites != 0) free(suites[--num_suites]); while(num_tests != 0) free(tests[--num_tests]); if (failed > 0) return (1); else return (0); }