这篇教程C++ test_begin函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中test_begin函数的典型用法代码示例。如果您正苦于以下问题:C++ test_begin函数的具体用法?C++ test_begin怎么用?C++ test_begin使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了test_begin函数的27个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: mainint main(void){ test_package_begin("hash", "Externally linked hash table data structure with operations"); hash_init(); test_begin("Hash allocation"); { Hash *a; a = hash_new(int_hash, int_key_eq); test_result(a != NULL); hash_destroy(a); } test_end(); test_begin("Multiple allocs"); { Hash *a, *b; a = hash_new(int_hash, int_key_eq); b = hash_new(int_hash, int_key_eq); test_result(a != NULL && b != NULL && a != b); hash_destroy(b); hash_destroy(a); } test_end(); test_begin("Insert/lookup"); { Hash *a; const char *t; a = hash_new(int_hash, int_key_eq); hash_insert(a, (const void *) 17, "foo"); test_result((t = hash_lookup(a, (const void *) 17)) != NULL && strcmp(t, "foo") == 0); hash_destroy(a); } test_end(); test_begin("Resize"); { Hash *a; const char *t; unsigned int i; a = hash_new(int_hash, int_key_eq); hash_insert(a, (const void *) 4711, "foo"); for(i = 0; i < 100; i++) hash_insert(a, (const void *) (3519 + i), "test-data"); test_result((t = hash_lookup(a, (const void *) 4711)) != NULL && strcmp(t, "foo") == 0); hash_destroy(a); } test_end(); return test_package_end();}
开发者ID:versenaut,项目名称:purple,代码行数:59,
示例2: test_ds_buffersstatic void test_ds_buffers(void){ test_begin("data-stack buffer growth"); T_BEGIN { size_t i; unsigned char *p; size_t left = t_get_bytes_available(); while (left < 10000) { t_malloc_no0(left); /* force a new block */ left = t_get_bytes_available(); } left -= 64; /* make room for the sentry if DEBUG */ p = t_buffer_get(1); p[0] = 1; for (i = 2; i <= left; i++) { /* grow it */ unsigned char *p2 = t_buffer_get(i); test_assert_idx(p == p2, i); p[i-1] = i; test_assert_idx(p[i-2] == (unsigned char)(i-1), i); } /* now fix it permanently */ t_buffer_alloc_last_full(); test_assert(t_get_bytes_available() < 64 + MEM_ALIGN(1)); } T_END; test_end(); test_begin("data-stack buffer interruption"); T_BEGIN { void *b = t_buffer_get(1000); void *a = t_malloc_no0(1); void *b2 = t_buffer_get(1001); test_assert(a == b); /* expected, not guaranteed */ test_assert(b2 != b); } T_END; test_end(); test_begin("data-stack buffer with reallocs"); T_BEGIN { size_t bigleft = t_get_bytes_available(); size_t i; for (i = 1; i < bigleft-64; i += i_rand()%32) T_BEGIN { unsigned char *p, *p2; size_t left; t_malloc_no0(i); left = t_get_bytes_available(); /* The most useful idx for the assert is 'left' */ test_assert_idx(left <= bigleft-i, left); p = t_buffer_get(left/2); p[0] = 'Z'; p[left/2 - 1] = 'Z'; p2 = t_buffer_get(left + left/2); test_assert_idx(p != p2, left); test_assert_idx(p[0] == 'Z', left); test_assert_idx(p[left/2 -1] == 'Z', left); } T_END; } T_END; test_end();}
开发者ID:bdraco,项目名称:core,代码行数:58,
示例3: test_unicharvoid test_unichar(void){ static const char overlong_utf8[] = "/xf8/x80/x95/x81/xa1"; static const char collate_in[] = "/xc3/xbc /xc2/xb3"; static const char collate_exp[] = "U/xcc/x88 3"; buffer_t *collate_out; unichar_t chr, chr2; string_t *str = t_str_new(16); test_begin("unichars encode/decode"); for (chr = 0; chr <= 0x10ffff; chr++) { /* The bottom 6 bits should be irrelevant to code coverage, only test 000000, 111111, and something in between. */ if ((chr & 63) == 1) chr += rand() % 62; /* After 0, somewhere between 1 and 62 */ else if ((chr & 63) > 0 && (chr & 63) < 63) chr |= 63; /* After random, straight to 63 */ str_truncate(str, 0); uni_ucs4_to_utf8_c(chr, str); test_assert(uni_utf8_str_is_valid(str_c(str))); test_assert(uni_utf8_get_char(str_c(str), &chr2) == (int)uni_utf8_char_bytes(*str_data(str))); test_assert(chr2 == chr); if ((chr & 0x63) == 0) { unsigned int utf8len = uni_utf8_char_bytes(*str_c(str)); /* virtually truncate the byte string */ while (--utf8len > 0) test_assert(uni_utf8_get_char_n(str_c(str), utf8len, &chr2) == 0); utf8len = uni_utf8_char_bytes(*str_c(str)); /* actually truncate the byte stream */ while (--utf8len > 0) { str_truncate(str, utf8len); test_assert(!uni_utf8_str_is_valid(str_c(str))); test_assert(uni_utf8_get_char(str_c(str), &chr2) == 0); } } } test_end(); test_begin("unichar collation"); collate_out = buffer_create_dynamic(default_pool, 32); uni_utf8_to_decomposed_titlecase(collate_in, sizeof(collate_in), collate_out); test_assert(!strcmp(collate_out->data, collate_exp)); buffer_free(&collate_out); test_assert(!uni_utf8_str_is_valid(overlong_utf8)); test_assert(uni_utf8_get_char(overlong_utf8, &chr2) < 0); test_end(); test_unichar_uni_utf8_strlen(); test_unichar_uni_utf8_partial_strlen_n();}
开发者ID:Raffprta,项目名称:core,代码行数:57,
示例4: mainintmain(int argc, char **argv){ TDSRESULTINFO *info; char mymsg[256]; fprintf(stdout, "%s: Testing flags from server/n", __FILE__); if (try_tds_login(&login, &tds, __FILE__, 0) != TDS_SUCCESS) { fprintf(stderr, "try_tds_login() failed/n"); return 1; } if (run_query(tds, "create table #tmp1 (i numeric(10,0) identity primary key, b varchar(20) null, c int not null)") != TDS_SUCCESS) fatal_error("creating table error"); /* TDS 4.2 without FOR BROWSE clause seem to forget flags... */ if (!IS_TDS42(tds->conn)) { /* check select of all fields */ test_begin("select * from #tmp1"); info = tds->current_results; if (info->num_cols != 3) { sprintf(mymsg,"wrong number of columns returned expected 3 got %d", info->num_cols); fatal_error(mymsg); } check_flags(info->columns[0], 0, "identity"); check_flags(info->columns[1], 1, "nullable writable"); check_flags(info->columns[2], 2, "writable"); test_end(); } /* check select of 2 field */ test_begin("select c, b from #tmp1 for browse"); info = tds->current_results; if (info->num_cols != 3) fatal_error("wrong number of columns returned"); check_flags(info->columns[0], 0, "writable"); if (!IS_TDS42(tds->conn)) { check_flags(info->columns[1], 1, "nullable writable"); } else { check_flags(info->columns[1], 1, "writable-nullable writable"); } /* TDS5 return not identity information altough documented.. */ check_flags(info->columns[2], 2, "writable identity key hidden-writable key hidden"); test_end(); try_tds_logout(login, tds, 0); return 0;}
开发者ID:DmitrySigaev,项目名称:ncbi,代码行数:57,
示例5: test_str_sanitizevoid test_str_sanitize(void){ static struct str_sanitize_test tests[] = { { NULL, 2, NULL }, { "", 2, NULL }, { "a", 2, NULL }, { "ab", 2, NULL }, { "abc", 2, "..." }, { "abcd", 3, "..." }, { "abcde", 4, "a..." }, { "/xD1/x81", 1, "..." }, { "/xD1/x81", 2, "/xD1/x81" }, { "/xD1/x81", 3, NULL }, { "/xC3/xA4/xC3/xA4zyxa", 1, "..." }, { "/xC3/xA4/xC3/xA4zyxa", 2, "..." }, { "/xC3/xA4/xC3/xA4zyxa", 3, "..." }, { "/xC3/xA4/xC3/xA4zyxa", 4, "..." }, { "/xC3/xA4/xC3/xA4zyxa", 5, "/xC3/xA4..." }, { "/xC3/xA4/xC3/xA4zyxa", 6, "/xC3/xA4..." }, { "/xC3/xA4/xC3/xA4zyxa", 7, "/xC3/xA4/xC3/xA4..." }, { "/xC3/xA4/xC3/xA4zyxa", 8, "/xC3/xA4/xC3/xA4zyxa" }, { "/001x/x1fy/x81", 10, "?x?y?" } }; const char *str; string_t *str2; unsigned int i; test_begin("str_sanitize"); for (i = 0; i < N_ELEMENTS(tests); i++) { str = str_sanitize(tests[i].str, tests[i].max_len); if (tests[i].sanitized != NULL) test_assert_idx(null_strcmp(str, tests[i].sanitized) == 0, i); else test_assert_idx(str == tests[i].str, i); } test_end(); test_begin("str_sanitize_append"); str2 = t_str_new(128); for (i = 0; i < N_ELEMENTS(tests); i++) { if (tests[i].str == NULL) continue; str_truncate(str2, 0); str_append(str2, "1234567890"); str_sanitize_append(str2, tests[i].str, tests[i].max_len); test_assert_idx(strncmp(str_c(str2), "1234567890", 10) == 0, i); if (tests[i].sanitized != NULL) test_assert_idx(strcmp(str_c(str2)+10, tests[i].sanitized) == 0, i); else test_assert_idx(strcmp(str_c(str2)+10, tests[i].str) == 0, i); } test_end();}
开发者ID:LTD-Beget,项目名称:dovecot,代码行数:54,
示例6: test_istream_base64_encodervoid test_istream_base64_encoder(void){ unsigned int i; for (i = 0; i < N_ELEMENTS(tests); i++) { test_begin(t_strdup_printf("istream base64 decoder %u", i+1)); encode_test(tests[i].input, tests[i].chars_per_line, tests[i].crlf, tests[i].output); test_end(); } test_begin("istream base64 encoder seek"); test_istream_base64_encoder_seek(hello, "aGVs/r/nbG8g/r/nd29y/r/nbGQ="); test_end();}
开发者ID:Raffprta,项目名称:core,代码行数:14,
示例7: test_unichar_uni_utf8_strlenstatic void test_unichar_uni_utf8_strlen(void){ static const char input[] = "/xC3/xA4/xC3/xA4/0a"; test_begin("uni_utf8_strlen()"); test_assert(uni_utf8_strlen(input) == 2); test_end(); test_begin("uni_utf8_strlen_n()"); test_assert(uni_utf8_strlen_n(input, 1) == 0); test_assert(uni_utf8_strlen_n(input, 2) == 1); test_assert(uni_utf8_strlen_n(input, 3) == 1); test_assert(uni_utf8_strlen_n(input, 4) == 2); test_end();}
开发者ID:Raffprta,项目名称:core,代码行数:15,
示例8: disable_and_enablestatic voiddisable_and_enable(void){ const char *test_id = "kevent(EVFILT_USER, EV_DISABLE and EV_ENABLE)"; struct kevent kev; test_begin(test_id); test_no_kevents(); kevent_add(kqfd, &kev, 1, EVFILT_USER, EV_ADD, 0, 0, NULL); kevent_add(kqfd, &kev, 1, EVFILT_USER, EV_DISABLE, 0, 0, NULL); /* Trigger the event, but since it is disabled, nothing will happen. */ kevent_add(kqfd, &kev, 1, EVFILT_USER, 0, NOTE_TRIGGER, 0, NULL); test_no_kevents(); kevent_add(kqfd, &kev, 1, EVFILT_USER, EV_ENABLE, 0, 0, NULL); kevent_add(kqfd, &kev, 1, EVFILT_USER, 0, NOTE_TRIGGER, 0, NULL); kev.flags = EV_CLEAR; kev.fflags &= ~NOTE_FFCTRLMASK; kev.fflags &= ~NOTE_TRIGGER; kevent_cmp(&kev, kevent_get(kqfd)); success();}
开发者ID:FreeBSDFoundation,项目名称:freebsd,代码行数:27,
示例9: test_kevent_socket_disable_and_enablevoidtest_kevent_socket_disable_and_enable(void){ const char *test_id = "kevent(EVFILT_READ, EV_DISABLE)"; struct kevent kev; test_begin(test_id); /* Add an event, then disable it. */ EV_SET(&kev, sockfd[0], EVFILT_READ, EV_ADD, 0, 0, &sockfd[0]); if (kevent(kqfd, &kev, 1, NULL, 0, NULL) < 0) err(1, "%s", test_id); EV_SET(&kev, sockfd[0], EVFILT_READ, EV_DISABLE, 0, 0, &sockfd[0]); if (kevent(kqfd, &kev, 1, NULL, 0, NULL) < 0) err(1, "%s", test_id); kevent_socket_fill(); test_no_kevents(); /* Re-enable the knote, then see if an event is generated */ kev.flags = EV_ENABLE; if (kevent(kqfd, &kev, 1, NULL, 0, NULL) < 0) err(1, "%s", test_id); kev.flags = EV_ADD; kev.data = 1; kevent_cmp(&kev, kevent_get(kqfd)); kevent_socket_drain(); kev.flags = EV_DELETE; if (kevent(kqfd, &kev, 1, NULL, 0, NULL) < 0) err(1, "%s", test_id); success();}
开发者ID:coyizumi,项目名称:cs111,代码行数:35,
示例10: test_message_header_encode_qstatic void test_message_header_encode_q(void){ string_t *input = t_str_new(100); string_t *str = t_str_new(512); unsigned int i, j, skip; test_begin("message header encode q"); str_append_c(input, 'a'); for (i = 0; i < 40; i++) str_append(input, "/xC3/xA4"); for (i = 0; i < 80; i++) { for (skip = 0; skip < 2; skip++) { str_truncate(str, 0); for (j = 1; j < i; j++) str_append_c(str, 'X'); if (i != 0) str_append_c(str, ' '); message_header_encode_q(str_data(input) + skip, str_len(input) - skip, str, i == 0 ? 0 : i+1); test_assert(verify_q(str_c(str), i, skip == 0)); } } test_end();}
开发者ID:bechtoldt,项目名称:dovecot-core,代码行数:27,
示例11: test_message_id_get_next |