本文整理汇总了C++中CU_basic_run_tests函数的典型用法代码示例。如果您正苦于以下问题:C++ CU_basic_run_tests函数的具体用法?C++ CU_basic_run_tests怎么用?C++ CU_basic_run_tests使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CU_basic_run_tests函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int
main(int argc, char **argv)
{
CU_pSuite suite = NULL;
unsigned int num_failures;
if (CU_initialize_registry() != CUE_SUCCESS) {
return CU_get_error();
}
suite = CU_add_suite("bit_array", NULL, NULL);
if (suite == NULL) {
CU_cleanup_registry();
return CU_get_error();
}
if (
CU_add_test(suite, "test_1bit", test_1bit) == NULL ||
CU_add_test(suite, "test_64bit", test_64bit) == NULL ||
CU_add_test(suite, "test_find", test_find) == NULL ||
CU_add_test(suite, "test_resize", test_resize) == NULL ||
CU_add_test(suite, "test_errors", test_errors) == NULL) {
CU_cleanup_registry();
return CU_get_error();
}
CU_basic_set_mode(CU_BRM_VERBOSE);
CU_basic_run_tests();
num_failures = CU_get_number_of_failures();
CU_cleanup_registry();
return num_failures;
}
示例2: main
int main(int argc, char **argv)
{
/* Initialize CUnit. */
if (CUE_SUCCESS != CU_initialize_registry())
return CU_get_error();
/* Here's an example test suite. First we initialize the suit. */
{
CU_pSuite s = CU_add_suite("example test suite",
&init_suite_example,
&clean_suite_example);
CU_add_test(s, "test of mm_malloc()", &test_malloc);
CU_add_test(s, "test #1 of mm_malloc()", &test_malloc_1);
CU_add_test(s, "test #2 of mm_malloc()", &test_malloc_2);
CU_add_test(s, "test #3 of mm_malloc()", &test_malloc_3);
CU_add_test(s, "test #4 of mm_malloc()", &test_malloc_4);
CU_add_test(s, "test #5 of mm_malloc()", &test_malloc_5);
CU_add_test(s, "test #6 of mm_malloc()", &test_malloc_6);
CU_add_test(s, "test #1 of mm_realloc()", &test_realloc_1);
CU_add_test(s, "test #2 of mm_realloc()", &test_realloc_2);
CU_add_test(s, "test #3 of mm_realloc()", &test_realloc_3);
CU_add_test(s, "test #4 of mm_realloc()", &test_realloc_4);
CU_add_test(s, "test #5 of mm_realloc()", &test_realloc_5);
CU_add_test(s, "test #1 of mm_free()", &test_free_1);
CU_add_test(s, "test #2 of mm_free()", &test_free_2);
}
/* Actually run your tests here. */
CU_basic_set_mode(CU_BRM_VERBOSE);
CU_basic_run_tests();
CU_cleanup_registry();
return CU_get_error();
}
示例3: main
int main()
{
CU_pSuite pSuite = NULL;
/* Initialize the CUnit test registry */
if (CUE_SUCCESS != CU_initialize_registry())
return CU_get_error();
/* Add a suite to the registry */
pSuite = CU_add_suite("google_oauth2_access_test", init_suite, clean_suite);
if (NULL == pSuite)
{
CU_cleanup_registry();
return CU_get_error();
}
/* Add the tests to the suite */
if ((NULL == CU_add_test(pSuite, "testBuildAccessTokenRequestAsHtmlRequest", testBuildAccessTokenRequestAsHtmlRequest)) ||
(NULL == CU_add_test(pSuite, "testBuildPostFieldsForRefreshingTheAccessToken", testBuildPostFieldsForRefreshingTheAccessToken)) ||
(NULL == CU_add_test(pSuite, "testBuildPostFieldsForRequestingAnAccessToken", testBuildPostFieldsForRequestingAnAccessToken)) ||
(NULL == CU_add_test(pSuite, "testMakeHttpsRequestWithResponse", testMakeHttpsRequestWithResponse)) ||
(NULL == CU_add_test(pSuite, "testProcessIncomingAccessTokenResponse", testProcessIncomingAccessTokenResponse)) ||
(NULL == CU_add_test(pSuite, "testProcessIncomingRefreshTokenResponse", testProcessIncomingRefreshTokenResponse)) ||
(NULL == CU_add_test(pSuite, "testcheckIfErrorOccured", testcheckIfErrorOccured)))
{
CU_cleanup_registry();
return CU_get_error();
}
/* Run all tests using the CUnit Basic interface */
CU_basic_set_mode(CU_BRM_VERBOSE);
CU_basic_run_tests();
CU_cleanup_registry();
return CU_get_error();
}
示例4: main
/* The main() function for setting up and running the tests.
* Returns a CUE_SUCCESS on successful running, another
* CUnit error code on failure.
*/
int main()
{
CU_pSuite pSuite = NULL;
/* initialize the CUnit test registry */
if (CUE_SUCCESS != CU_initialize_registry())
return CU_get_error();
/* add a suite to the registry */
pSuite = CU_add_suite("Suite_1", init_suite1, clean_suite1);
if (NULL == pSuite) {
CU_cleanup_registry();
return CU_get_error();
}
/* add the tests to the suite */
/* NOTE - ORDER IS IMPORTANT - MUST TEST fread() AFTER fprintf() */
if ((NULL == CU_add_test(pSuite, "test of fprintf()", testFPRINTF)) ||
(NULL == CU_add_test(pSuite, "test of fread()", testFREAD)))
{
CU_cleanup_registry();
return CU_get_error();
}
/* Run all tests using the CUnit Basic interface */
CU_basic_set_mode(CU_BRM_VERBOSE);
CU_basic_run_tests();
CU_cleanup_registry();
return CU_get_error();
}
示例5: main
int main() {
CU_pSuite pSuite = NULL;
/* initialize the CUnit test registry */
if (CUE_SUCCESS != CU_initialize_registry())
return CU_get_error();
/* add a suite to the registry */
pSuite = CU_add_suite("gcd_suite", NULL, NULL);
if (NULL == pSuite) {
CU_cleanup_registry();
return CU_get_error();
}
/* add the tests to the suite */
if ((NULL == CU_add_test(pSuite, "test_same_number", test_same_number)) ||
(NULL == CU_add_test(pSuite, "test_nothing_common", test_nothing_common)) ||
(NULL == CU_add_test(pSuite, "test_factorize", test_factorize)) ||
(NULL == CU_add_test(pSuite, "test_gcd_ok", test_gcd_ok)) ||
(NULL == CU_add_test(pSuite, "test_malloc_fail", test_malloc_fail)) ||
(NULL == CU_add_test(pSuite, "test_malloc_equals_free", test_malloc_equals_free)) ||
(NULL == CU_add_test(pSuite, "test_nb_threads", test_nb_threads)))
{
CU_cleanup_registry();
return CU_get_error();
}
/* Run all tests using the CUnit Basic interface */
CU_basic_set_mode(CU_BRM_VERBOSE);
CU_basic_run_tests();
CU_cleanup_registry();
return CU_get_error();
}
示例6: main
int main(
const int argc,
const char* const * argv)
{
int exitCode = 1; /* failure */
if (CUE_SUCCESS == CU_initialize_registry()) {
CU_Suite* testSuite = CU_add_suite(__FILE__, setup, teardown);
if (NULL != testSuite) {
const char* progname = basename((char*)argv[0]);
CU_ADD_TEST(testSuite, test_create);
CU_ADD_TEST(testSuite, test_get);
CU_ADD_TEST(testSuite, test_write_lock);
CU_ADD_TEST(testSuite, test_read_lock);
CU_ADD_TEST(testSuite, test_multiple_write);
CU_ADD_TEST(testSuite, test_multiple_read);
if (log_init(progname)) {
(void) fprintf(stderr, "Couldn't open logging system\n");
}
else {
if (CU_basic_run_tests() == CUE_SUCCESS) {
if (0 == CU_get_number_of_failures())
exitCode = 0; /* success */
}
}
}
CU_cleanup_registry();
} /* CUnit registry allocated */
return exitCode;
}
示例7: main
int main(int argc, char **argv)
{
CU_pSuite suite = NULL;
unsigned int num_failures;
if (CU_initialize_registry() != CUE_SUCCESS) {
return CU_get_error();
}
suite = CU_add_suite("nvmf", NULL, NULL);
if (suite == NULL) {
CU_cleanup_registry();
return CU_get_error();
}
if (
CU_add_test(suite, "create_subsystem", nvmf_test_create_subsystem) == NULL ||
CU_add_test(suite, "find_subsystem", nvmf_test_find_subsystem) == NULL ||
CU_add_test(suite, "discovery_log", test_discovery_log) == NULL) {
CU_cleanup_registry();
return CU_get_error();
}
CU_basic_set_mode(CU_BRM_VERBOSE);
CU_basic_run_tests();
num_failures = CU_get_number_of_failures();
CU_cleanup_registry();
return num_failures;
}
示例8: main
int main()
{
/* initialize the CUnit test registry */
if (CUE_SUCCESS != CU_initialize_registry())
return CU_get_error();
if (CUE_SUCCESS != create_tlv_suit()) {
goto exit;
}
if (CUE_SUCCESS != create_uri_suit()) {
goto exit;
}
if (CUE_SUCCESS != create_convert_numbers_suit()) {
goto exit;
}
if (CUE_SUCCESS != create_tlv_json_suit()) {
goto exit;
}
CU_basic_set_mode(CU_BRM_VERBOSE);
CU_basic_run_tests();
exit:
CU_cleanup_registry();
return CU_get_error();
}
示例9: main
int main(int argc, char const *argv[]) {
if (CUE_SUCCESS != CU_initialize_registry())
return CU_get_error();
CU_pSuite pSuite = NULL;
pSuite = CU_add_suite("Suite de tests : libfractal", setup, teardown);
if (NULL == pSuite) {
CU_cleanup_registry();
return CU_get_error();
}
if ((NULL == CU_add_test(pSuite, "Name", test_libfractal_ptr_not_null)) ||
(NULL == CU_add_test(pSuite, "Name", test_libfractal_ptr_value_not_null)) ||
(NULL == CU_add_test(pSuite, "Name", test_libfractal_get_name)) ||
(NULL == CU_add_test(pSuite, "Name", test_libfractal_get_width)) ||
(NULL == CU_add_test(pSuite, "Name", test_libfractal_get_height)) ||
(NULL == CU_add_test(pSuite, "Name", test_libfractal_get_a)) ||
(NULL == CU_add_test(pSuite, "Name", test_libfractal_get_b))||
(NULL == CU_add_test(pSuite, "Name", test_libfractal_get_set_value))) {
CU_cleanup_registry();
return CU_get_error();
}
CU_basic_run_tests();
CU_basic_show_failures(CU_get_failure_list());
CU_cleanup_registry();
return 0;
}
示例10: main
int main(int argc, char const *argv[]) {
if (CUE_SUCCESS != CU_initialize_registry())
return CU_get_error();
CU_pSuite pSuite = NULL;
pSuite = CU_add_suite("Suite de tests : malloc", setup, teardown);
if (NULL == pSuite) {
CU_cleanup_registry();
return CU_get_error();
}
if ((NULL == CU_add_test(pSuite, "Blocks réallouables", test_free_block_reallouable)) ||
(NULL == CU_add_test(pSuite, "Pointeur non null", test_malloc_pointeur_non_null)) ||
(NULL == CU_add_test(pSuite, "Deux pointeurs différents", test_malloc_deux_pointeurs_differents)) ||
(NULL == CU_add_test(pSuite, "Size 0", test_malloc_size_0)) ||
(NULL == CU_add_test(pSuite, "Pointeur invalide", test_free_malloc)) ||
(NULL == CU_add_test(pSuite, "Test valeur", test_malloc_ajout)) ||
(NULL == CU_add_test(pSuite, "Double Free", test_double_free)) ||
(NULL == CU_add_test(pSuite, "Test Calloc", callocTest))) {
CU_cleanup_registry();
return CU_get_error();
}
CU_basic_set_mode(CU_BRM_VERBOSE);
CU_basic_run_tests();
CU_basic_show_failures(CU_get_failure_list());
CU_cleanup_registry();
return 0;
}
示例11: main
int main(void)
{
CU_pSuite pSuite = NULL;
if (CUE_SUCCESS != CU_initialize_registry())
return CU_get_error();
pSuite = CU_add_suite("toml suite", init_toml, fini_toml);
if (NULL == pSuite)
goto out;
if ((NULL == CU_add_test(pSuite, "test fruit", testFruit)))
goto out;
if ((NULL == CU_add_test(pSuite, "test types", testTypes)))
goto out;
if ((NULL == CU_add_test(pSuite, "test hex", testHex)))
goto out;
if ((NULL == CU_add_test(pSuite, "test good examples", testGoodExamples)))
goto out;
if ((NULL == CU_add_test(pSuite, "test bad examples", testBadExamples)))
goto out;
CU_basic_set_mode(CU_BRM_VERBOSE);
CU_basic_run_tests();
out:
CU_cleanup_registry();
exit(CU_get_error());
}
示例12: liblinphone_tester_run_tests
int liblinphone_tester_run_tests(const char *suite_name, const char *test_name) {
int i;
int ret;
/* initialize the CUnit test registry */
if (CUE_SUCCESS != CU_initialize_registry())
return CU_get_error();
for (i = 0; i < liblinphone_tester_nb_test_suites(); i++) {
run_test_suite(test_suite[i]);
}
if (suite_name){
CU_pSuite suite;
CU_basic_set_mode(CU_BRM_VERBOSE);
suite=CU_get_suite(suite_name);
if (!suite) {
ms_error("Could not find suite '%s'. Available suites are:", suite_name);
liblinphone_tester_list_suites();
return -1;
} else if (test_name) {
CU_pTest test=CU_get_test_by_name(test_name, suite);
if (!test) {
ms_error("Could not find test '%s' in suite '%s'. Available tests are:", test_name, suite_name);
// do not use suite_name here, since this method is case sentisitive
liblinphone_tester_list_suite_tests(suite->pName);
return -2;
} else {
CU_ErrorCode err= CU_basic_run_test(suite, test);
if (err != CUE_SUCCESS) ms_error("CU_basic_run_test error %d", err);
}
} else {
CU_basic_run_suite(suite);
}
} else
{
#if HAVE_CU_CURSES
if (curses) {
/* Run tests using the CUnit curses interface */
CU_curses_run_tests();
}
else
#endif
{
/* Run all tests using the CUnit Basic interface */
CU_basic_set_mode(CU_BRM_VERBOSE);
CU_basic_run_tests();
}
}
ret=CU_get_number_of_tests_failed()!=0;
/* Redisplay list of failed tests on end */
if (CU_get_number_of_failure_records()){
CU_basic_show_failures(CU_get_failure_list());
printf("\n");
}
CU_cleanup_registry();
return ret;
}
示例13: main
/* The main() function for setting up and running the tests.
* Returns a CUE_SUCCESS on successful running, another
* CUnit error code on failure.
*/
int main()
{
CU_pSuite pSuite = NULL;
/* initialize the CUnit test registry */
if (CUE_SUCCESS != CU_initialize_registry())
return CU_get_error();
/* add a suite to the registry */
pSuite = CU_add_suite("Suite_1", init_suite1, clean_suite1);
if (NULL == pSuite) {
CU_cleanup_registry();
return CU_get_error();
}
/* add the tests to the suite */
/* NOTE - ORDER IS IMPORTANT*/
if ((NULL == CU_add_test(pSuite, "test of test_listdir()", test_listdir)) ||
(NULL == CU_add_test(pSuite, "test of test_movefile()", test_movefile)) ||
(NULL == CU_add_test(pSuite, "test of test_makefolder()", test_makefolder)) ||
(NULL == CU_add_test(pSuite, "test of test_checkfordir()", test_checkfordir)) ||
(NULL == CU_add_test(pSuite, "test of test_changedirdown()", test_changedirdown)) ||
(NULL == CU_add_test(pSuite, "test of test_dirconcat()", test_dirconcat)) ||
(NULL == CU_add_test(pSuite, "test of test_getfilename()", test_getfilename)))
{
CU_cleanup_registry();
return CU_get_error();
}
/* Run all tests using the CUnit Basic interface */
CU_basic_set_mode(CU_BRM_VERBOSE);
CU_basic_run_tests();
CU_cleanup_registry();
return CU_get_error();
}
示例14: main
int main() {
CU_pSuite pSuite = NULL;
/* Initialize the CUnit test registry */
if (CUE_SUCCESS != CU_initialize_registry())
return CU_get_error();
/* Add a suite to the registry */
pSuite = CU_add_suite("dwistring_test", init_suite, clean_suite);
if (NULL == pSuite) {
CU_cleanup_registry();
return CU_get_error();
}
/* Add the tests to the suite */
if ((NULL == CU_add_test(pSuite, "test_concat_null", test_concat_null)) ||
(NULL == CU_add_test(pSuite, "test_concat_both_null", test_concat_both_null))||
(NULL == CU_add_test(pSuite, "test_concat_both_null", test_concat_both_null))||
(NULL == CU_add_test(pSuite, "test_concatall_three_values", test_concatall_three_values))||
(NULL == CU_add_test(pSuite, "test_contains_char_positive", test_contains_char_positive))||
(NULL == CU_add_test(pSuite, "test_contains_char_null", test_contains_char_null))||
(NULL == CU_add_test(pSuite, "test_contains_char_empty", test_contains_char_empty))||
(NULL == CU_add_test(pSuite, "test_null_string_normal", test_null_string_normal))||
(NULL == CU_add_test(pSuite, "test_null_string_nullpointer", test_null_string_nullpointer))||
(NULL == CU_add_test(pSuite, "test_concatall_first_null", test_concatall_first_null))) {
CU_cleanup_registry();
return CU_get_error();
}
/* Run all tests using the CUnit Basic interface */
CU_basic_set_mode(CU_BRM_VERBOSE);
CU_basic_run_tests();
CU_cleanup_registry();
return CU_get_error();
}
示例15: main
int main()
{
CU_pSuite pSuite = NULL;
/* initialize the CUnit test registry */
if (CUE_SUCCESS != CU_initialize_registry())
return CU_get_error();
/* add a suite to the registry */
pSuite = CU_add_suite("asf suite", NULL, NULL);
if (NULL == pSuite) {
CU_cleanup_registry();
return CU_get_error();
}
/* add the tests to the suite */
if ((NULL == CU_add_test(pSuite, "vector", test_vector)) ||
(NULL == CU_add_test(pSuite, "strUtil", test_strUtil)) ||
(NULL == CU_add_test(pSuite, "solve1d", test_solve1d)) ||
(NULL == CU_add_test(pSuite, "complex", test_complex)))
{
CU_cleanup_registry();
return CU_get_error();
}
/* Run all tests using the CUnit Basic interface */
CU_basic_set_mode(CU_BRM_VERBOSE);
CU_basic_run_tests();
int nfail = CU_get_number_of_failures();
CU_cleanup_registry();
return nfail>0;
}