Lines Matching +full:unit +full:- +full:tests
2 * CUTest -- C/C++ Unit Test facility
5 * Copyright (c) 2013-2017 Martin Mitas
40 /* Macro to specify list of unit tests in the suite.
41 * The unit test implementation MUST provide list of unit tests it implements
60 /* Macros for testing whether an unit test succeeds or fails. These macros
61 * can be used arbitrarily in functions implementing the unit tests.
67 * (It expects printf-like format string and its parameters). The macros
68 * return non-zero (condition passes) or 0 (condition fails).
75 * TEST_CHECK(ptr->member1 < 100);
76 * TEST_CHECK(ptr->member2 > 200);
87 /* The unit test files should not rely on anything below. */
114 * with the unit tests implementation. */
162 buffer[sizeof(buffer) - 1] = '\0'; in test_print_in_color__()
287 printf("Unit tests:\n"); in test_list_names__()
288 for (test = &test_list__[0]; test->func != NULL; test++) in test_list_names__()
289 printf(" %s\n", test->name); in test_list_names__()
296 for (test = &test_list__[0]; test->func != NULL; test++) { in test_by_name__()
297 if (strcmp(test->name, name) == 0) in test_by_name__()
304 /* Call directly the given test unit function. */
313 test->name); in test_do_run__()
320 "Test %s... ", test->name); in test_do_run__()
323 printf("%.*s", (int)(sizeof(spaces) - n), spaces); in test_do_run__()
332 /* This is good to do for case the test unit e.g. crashes. */ in test_do_run__()
336 test->func(); in test_do_run__()
373 return (test_current_failures__ == 0) ? 0 : -1; in test_do_run__()
377 /* Called if anything goes bad in cutest, or if the unit test ends in other
404 /* Trigger the unit test. If possible (and not suppressed) it starts a child
421 if (pid == (pid_t)-1) { in test_run__()
490 _snprintf(buffer, sizeof(buffer) - 1, in test_run__()
491 "%s --no-exec --no-summary --verbose=%d --color=%s -- \"%s\"", in test_run__()
493 test_colorize__ ? "always" : "never", test->name); in test_run__()
503 test_error__("Cannot create unit test subprocess [%ld].", in test_run__()
516 /* Child processes suppressed through --no-exec. */ in test_run__()
532 ptrs->ExceptionRecord->ExceptionCode, in test_exception_filter__()
533 ptrs->ExceptionRecord->ExceptionAddress); in test_exception_filter__()
543 printf("Run the specified unit tests; or if the option '--skip' is used, " in test_help__()
545 printf("tests in the suite but those listed. By default, if no tests are " in test_help__()
547 printf("on the command line, all unit tests in the suite are run.\n"); in test_help__()
551 " -s, --skip Execute all unit tests but the listed ones\n"); in test_help__()
552 printf(" --no-exec Do not execute unit tests as child " in test_help__()
555 " --no-summary Suppress printing of test results summary\n"); in test_help__()
556 printf(" -l, --list List unit tests in the suite and exit\n"); in test_help__()
557 printf(" -v, --verbose Enable more verbose output\n"); in test_help__()
558 printf(" --verbose=LEVEL Set verbose level to LEVEL:\n"); in test_help__()
566 printf(" --color=WHEN Enable colorized output (WHEN is one of " in test_help__()
568 printf(" -h, --help Display this help and exit\n"); in test_help__()
575 const struct test__ **tests = NULL; in main() local
591 if (seen_double_dash || argv[i][0] != '-') { in main()
592 tests = (const struct test__ **)realloc( in main()
593 (void *)tests, (n + 1) * sizeof(const struct test__ *)); in main()
594 if (tests == NULL) { in main()
598 tests[n] = test_by_name__(argv[i]); in main()
599 if (tests[n] == NULL) { in main()
600 fprintf(stderr, "%s: Unrecognized unit test '%s'\n", argv[0], in main()
602 fprintf(stderr, "Try '%s --list' for list of unit tests.\n", in main()
607 } else if (strcmp(argv[i], "--") == 0) { in main()
609 } else if (strcmp(argv[i], "--help") == 0 || in main()
610 strcmp(argv[i], "-h") == 0) { in main()
613 } else if (strcmp(argv[i], "--verbose") == 0 || in main()
614 strcmp(argv[i], "-v") == 0) { in main()
616 } else if (strncmp(argv[i], "--verbose=", 10) == 0) { in main()
618 } else if (strcmp(argv[i], "--color=auto") == 0) { in main()
620 } else if (strcmp(argv[i], "--color=always") == 0 || in main()
621 strcmp(argv[i], "--color") == 0) { in main()
623 } else if (strcmp(argv[i], "--color=never") == 0) { in main()
625 } else if (strcmp(argv[i], "--skip") == 0 || in main()
626 strcmp(argv[i], "-s") == 0) { in main()
628 } else if (strcmp(argv[i], "--no-exec") == 0) { in main()
630 } else if (strcmp(argv[i], "--no-summary") == 0) { in main()
632 } else if (strcmp(argv[i], "--list") == 0 || in main()
633 strcmp(argv[i], "-l") == 0) { in main()
638 fprintf(stderr, "Try '%s --help' for more information.\n", argv[0]); in main()
652 /* Run the tests */ in main()
654 /* Run all tests */ in main()
658 /* Run the listed tests */ in main()
660 test_run__(tests[i]); in main()
662 /* Run all tests except those listed */ in main()
666 if (tests[j] == &test_list__[i]) { in main()
681 printf(" Count of all unit tests: %4d\n", test_count__); in main()
682 printf(" Count of run unit tests: %4d\n", in main()
684 printf(" Count of failed unit tests: %4d\n", in main()
686 printf(" Count of skipped unit tests: %4d\n", in main()
687 test_count__ - test_stat_run_units__); in main()
692 " SUCCESS: All unit tests have passed.\n"); in main()
696 " FAILED: %d of %d unit tests have failed.\n", in main()
701 if (tests != NULL) in main()
702 free((void *)tests); in main()