• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ ck_assert函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中ck_assert函数的典型用法代码示例。如果您正苦于以下问题:C++ ck_assert函数的具体用法?C++ ck_assert怎么用?C++ ck_assert使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了ck_assert函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: START_TEST

END_TEST

START_TEST(test_mm_strings_put_and_get_multiple)
{
  ck_assert(multimap_put(map, strdup("k1"), strdup("v1")));
  ck_assert(multimap_put(map, strdup("k1"), strdup("v2")));
  ck_assert(multimap_put(map, strdup("k1"), strdup("v3")));
  multimap_values_t * values = multimap_get(map, "k1");
  ck_assert(!!values->next);
  ck_assert(!!values->next->next);
  ck_assert(!values->next->next->next);
  ck_assert_str_eq(values->value, "v1");
  ck_assert_str_eq(values->next->value, "v2");
  ck_assert_str_eq(values->next->next->value, "v3");
  ck_assert_uint_eq(3, multimap_size(map));
}
开发者ID:gregory144,项目名称:prism-web-server,代码行数:16,代码来源:check_multimap.c


示例2: START_TEST

END_TEST

/*******************************************************************************
 * is_asn1
 */

START_TEST(test_is_asn1)
{
	typedef struct {
		bool asn1;
		chunk_t chunk;
	} testdata_t;

	u_char buf[8];
	chunk_t chunk_zero = { buf, 0 };
	chunk_t chunk_mean = {   0, 1 };

	testdata_t test[] = {
		{ FALSE, chunk_zero },
		{ FALSE, chunk_empty },
		{ FALSE, chunk_mean },
		{ TRUE,  chunk_from_chars(0x30, 0x00) },
		{ TRUE,  chunk_from_chars(0x31, 0x00) },
		{ TRUE,  chunk_from_chars(0x04, 0x00) },
		{ FALSE, chunk_from_chars(0x02, 0x00) },
		{ FALSE, chunk_from_chars(0x30, 0x01) },
		{ FALSE, chunk_from_chars(0x30, 0x80) },
		{ TRUE,  chunk_from_chars(0x30, 0x01, 0xa1) },
		{ FALSE, chunk_from_chars(0x30, 0x01, 0xa1, 0xa2) },
		{ TRUE,  chunk_from_chars(0x30, 0x01, 0xa1, 0x0a) },
		{ FALSE, chunk_from_chars(0x30, 0x01, 0xa1, 0xa2, 0x0a) },
	};

	int i;

	for (i = 0; i < countof(test); i++)
	{
		ck_assert(is_asn1(test[i].chunk) == test[i].asn1);
	}
}
开发者ID:netklass,项目名称:strongswan,代码行数:40,代码来源:test_asn1.c


示例3: START_TEST

} END_TEST

START_TEST (test_RFS_NT) {
    struct RFstring *s1 = RFS_NT("a string");
    struct RFstring *s2 = RFS_NT("a string %s %d", "with", 123);
    ck_assert_rf_str_eq_cstr(s1, "a string");
    ck_assert(rf_string_data(s1)[rf_string_length_bytes(s1)] == '\0');
    ck_assert_rf_str_eq_cstr(s2, "a string with 123");
    ck_assert(rf_string_data(s2)[rf_string_length_bytes(s2)] == '\0');
    struct RFstring *s3 = RFS_NT_OR_DIE("a string");
    struct RFstring *s4 = RFS_NT("a string %s %d", "with", 123);
    ck_assert_rf_str_eq_cstr(s3, "a string");
    ck_assert(rf_string_data(s3)[rf_string_length_bytes(s3)] == '\0');
    ck_assert_rf_str_eq_cstr(s4, "a string with 123");
    ck_assert(rf_string_data(s4)[rf_string_length_bytes(s4)] == '\0');

    // test that subsequent allocations don't overwite the null terminating
    // character
    ck_assert(rf_string_data(s1)[rf_string_length_bytes(s1)] == '\0');
    ck_assert(rf_string_data(s2)[rf_string_length_bytes(s2)] == '\0');
    ck_assert(rf_string_data(s3)[rf_string_length_bytes(s3)] == '\0');
    ck_assert(rf_string_data(s4)[rf_string_length_bytes(s4)] == '\0');
} END_TEST
开发者ID:refu-lang,项目名称:rfbase,代码行数:23,代码来源:test_string_buffers.c


示例4: sym_sign_testing

static UA_StatusCode
sym_sign_testing(const UA_SecurityPolicy *securityPolicy,
                 void *channelContext,
                 const UA_ByteString *message,
                 UA_ByteString *signature) {
    SET_CALLED(sym_sign);
    ck_assert(securityPolicy != NULL);
    ck_assert(channelContext != NULL);
    ck_assert(message != NULL);
    ck_assert(signature != NULL);
    ck_assert(signature->length != 0);
    ck_assert(signature->data != NULL);

    memset(signature->data, 'S', signature->length);
    return UA_STATUSCODE_GOOD;
}
开发者ID:open62541,项目名称:open62541,代码行数:16,代码来源:testing_policy.c


示例5: START_TEST

END_TEST


START_TEST (array_reseed_delay_64)
{
  unsigned int size=ARRAY_SIZE-1;
  unsigned int offset=16;
  
  unsigned int multiplier=8; // 1 - 8bit, 2 - 64bit, 4 - 32bit, ...
  
  /* Generate one size */
  {{{
	  unsigned char dst[ARRAY_SIZE] = {0};
	  ck_assert_int_eq (rdrand_get_uint64_array_reseed_delay((uint64_t *)&dst, size/multiplier, RETRY_LIMIT), size/multiplier);
	  // test if it wrote just into the place it should
	  ck_assert(test_zeros(dst, ARRAY_SIZE, size, ARRAY_SIZE));
	  // test if it wrote something (rarely can fail)
	  ck_assert(test_ones(dst, ARRAY_SIZE, 0, size));
  }}}	
  
  /* Generate half size */
  {{{
	  unsigned char dst[ARRAY_SIZE] = {0};
	  ck_assert_int_eq (rdrand_get_uint64_array_reseed_delay((uint64_t *)&dst, size/(2*multiplier), RETRY_LIMIT), size/(2*multiplier));
	  // test if it wrote just into the place it should
	  ck_assert(test_zeros(dst, ARRAY_SIZE, size/2, ARRAY_SIZE));
	  // test if it wrote something (rarely can fail)
	  ck_assert(test_ones(dst, ARRAY_SIZE, 0, size/2));
  }}}	
  
  /* Generate half size with offset */
  {{{
	  unsigned char dst[ARRAY_SIZE] = {0};
	  ck_assert_int_eq (rdrand_get_uint64_array_reseed_delay((uint64_t *)&dst+offset/multiplier, size/(2*multiplier), RETRY_LIMIT), size/(2*multiplier));
	  // test if it wrote just into the place it should
	  ck_assert(test_zeros(dst, ARRAY_SIZE, size/2+offset, ARRAY_SIZE));
	  // test if it wrote just into the place it should
	  ck_assert(test_zeros(dst, ARRAY_SIZE, 0, offset));
	  // test if it wrote something (rarely can fail)
	  ck_assert(test_ones(dst, ARRAY_SIZE, offset, size/2));
  }}}
}
开发者ID:BroukPytlik,项目名称:RdRand,代码行数:42,代码来源:check_rdrand.c


示例6: START_TEST

END_TEST

/**
 * url length test
 *
 * uses access dataset and test unit
 */
START_TEST(nsurl_length_test)
{
	nserror err;
	nsurl *res_url;
	const struct test_triplets *tst = &access_tests[_i];

	/* not testing create, this should always succeed */
	err = nsurl_create(tst->test1, &res_url);
	ck_assert(err == NSERROR_OK);

	ck_assert_int_eq(nsurl_length(res_url), strlen(tst->test2));

	nsurl_unref(res_url);

}
开发者ID:EyMenZ,项目名称:NetSurf-OS3,代码行数:22,代码来源:nsurl.c


示例7: START_TEST

END_TEST

START_TEST (parse_node_descr_test_1) {
  char *descr = "1 | 2 3 4 | 5 6 7";
  node_t *node = parse_node_descr(descr);

  ck_assert (node != NULL);
  
  if (node != NULL) {
    ck_assert_int_eq(node->id, 1);

    ck_assert_int_eq(node->out[0], 2);
    ck_assert_int_eq(node->out[1], 3);
    ck_assert_int_eq(node->out[2], 4);

    ck_assert_int_eq(node->in[0], 5);
    ck_assert_int_eq(node->in[1], 6);
    ck_assert_int_eq(node->in[2], 7);

    node_delete(node);
  }
}
开发者ID:Cecca,项目名称:gdem,代码行数:22,代码来源:test_parser.c


示例8: START_TEST

} END_TEST


/**
 * \brief Verify deletion of image on given index
 *
 * Remove one image pointer from the middle of the image group array and
 * verify the image references are handled correctly.
 */
START_TEST(test_delete_index) {

	ck_assert( OK == group_delete_index(image_group, 2) );
	ck_assert_str_eq( pointer_list[0]->name, group_get_image(image_group, 0)->name );
	ck_assert_str_eq( pointer_list[1]->name, group_get_image(image_group, 1)->name );
	ck_assert_str_eq( pointer_list[3]->name, group_get_image(image_group, 2)->name );
	ck_assert_int_eq( 2, pointer_list[0]->ref );
	ck_assert_int_eq( 2, pointer_list[1]->ref );
	ck_assert_int_eq( 1, pointer_list[2]->ref );
	ck_assert_int_eq( 2, pointer_list[3]->ref );
	ck_assert_int_eq( 9, group_get_size(image_group) );

} END_TEST
开发者ID:zdenekc,项目名称:SIVM,代码行数:22,代码来源:test_image_group.c


示例9: START_TEST

END_TEST

START_TEST(test_minmea_scan_d)
{
    int direction;

    ck_assert(minmea_scan("K", "d", &direction) == false);

    ck_assert(minmea_scan("", "d", &direction) == true);
    ck_assert(minmea_scan(",foo", "d", &direction) == true);
    ck_assert_int_eq(direction, 0);
    ck_assert(minmea_scan("N", "d", &direction) == true);
    ck_assert_int_eq(direction, 1);
    ck_assert(minmea_scan("S,foo", "d", &direction) == true);
    ck_assert_int_eq(direction, -1);
    ck_assert(minmea_scan("W", "d", &direction) == true);
    ck_assert_int_eq(direction, -1);
    ck_assert(minmea_scan("E,foo", "d", &direction) == true);
    ck_assert_int_eq(direction, 1);
}
开发者ID:KrzAst,项目名称:minmea,代码行数:20,代码来源:tests.c


示例10: START_TEST

END_TEST
START_TEST(test_telnet_single_byte_commands)
{
    unsigned char byte;
    for(byte = TELNET_NOP; byte <= TELNET_GA; ++byte) {
        // Arrange.
        telnet *tel = telnet_create();

        // Act.
        telnet_update(tel, TELNET_IAC);
        telnet_update(tel, byte);

        // Assert.
        ck_assert_int_eq(tel->cmd_len, 2);
        ck_assert_int_eq(tel->cmd_ready, 1);
        unsigned char expected_cmd[] = {TELNET_IAC, byte};
        ck_assert(memcmp(tel->cmd, expected_cmd, sizeof(expected_cmd)) == 0);

        // Clean up.
        telnet_destroy(tel);
    }
}
开发者ID:jbschlosser,项目名称:smudge,代码行数:22,代码来源:telnet_tests.c


示例11: test_create_from_string_and_family_any

END_TEST

/*******************************************************************************
 * host_create_from_string_and_family
 */

static void test_create_from_string_and_family_any(char *string, int family,
												   int expected)
{
	host_t *host;

	host = host_create_from_string_and_family(string, family, 500);
	if (expected == AF_UNSPEC)
	{
		ck_assert(host == NULL);
	}
	else
	{
		verify_any(host, expected, 500);
		host->destroy(host);
	}
}
开发者ID:BatuhanKaratas,项目名称:Bil527StrongSwan,代码行数:22,代码来源:test_host.c


示例12: START_TEST

END_TEST



START_TEST (test_find_common_prefix_double_middle)
{
    node * n = r3_tree_create(10);
    edge * e = r3_edge_createl(zstrdup("{slug}/foo/{name}"), sizeof("{slug}/foo/{name}")-1, NULL);
    r3_node_append_edge(n,e);

    int prefix_len;
    edge *ret_edge = NULL;
    char *errstr;

    errstr = NULL;
    ret_edge = r3_node_find_common_prefix(n, "{slug}/foo/{number}", sizeof("{slug}/foo/{number}")-1, &prefix_len, &errstr);
    ck_assert(ret_edge);
    ck_assert_int_eq(prefix_len, 11);
    SAFE_FREE(errstr);

    r3_tree_free(n);
}
开发者ID:CindyLinz,项目名称:r3,代码行数:22,代码来源:check_tree.c


示例13: START_TEST

END_TEST

START_TEST(path_add_invalid_path)
{
	struct libinput *li;
	struct libinput_event *event;
	struct libinput_device *device;

	li = litest_create_context();

	litest_disable_log_handler(li);
	device = libinput_path_add_device(li, "/tmp/");
	litest_restore_log_handler(li);
	ck_assert(device == NULL);

	libinput_dispatch(li);

	while ((event = libinput_get_event(li)))
		ck_abort();

	libinput_unref(li);
}
开发者ID:heftig,项目名称:libinput,代码行数:22,代码来源:path.c


示例14: START_TEST

} END_TEST

START_TEST (test_type_comparison_for_sum_fncall_with_conversion) {
    struct type *t_i8 = testsupport_analyzer_type_create_simple_elementary(ELEMENTARY_TYPE_INT_8);
    struct type *t_i64 = testsupport_analyzer_type_create_simple_elementary(ELEMENTARY_TYPE_INT_64);
    struct type *t_f64 = testsupport_analyzer_type_create_simple_elementary(ELEMENTARY_TYPE_FLOAT_64);
    struct type *t_string = testsupport_analyzer_type_create_simple_elementary(ELEMENTARY_TYPE_STRING);

    struct type *t_sum = testsupport_analyzer_type_create_operator(TYPEOP_SUM,
                                                                   t_i64,
                                                                   t_f64,
                                                                   t_string);

    typecmp_ctx_set_flags(TYPECMP_FLAG_FUNCTION_CALL);
    ck_assert(type_compare(t_i8, t_sum, TYPECMP_PATTERN_MATCHING));
    const struct type *matched_type = typemp_ctx_get_matched_type();
    ck_assert_msg(
        matched_type == t_i64,
        "Unexpected match type "RFS_PF" found",
        RFS_PA(type_str_or_die(matched_type, TSTR_DEFAULT))
    );
} END_TEST
开发者ID:refu-lang,项目名称:refu,代码行数:22,代码来源:test_types.c


示例15: START_TEST

	}END_TEST

START_TEST(test_correct_code_find)
	{

		fl64 * result = NULL;
		si32 resSize = 0;
		fl64 vector[10] = { 2, 3, 4, 2, 6, 7, 8, 9, 0, 0 };
		fl64 trueVal[3] = { 5, 6, 7 };
		si32 size = 10;
		pi8 * operation = ">";
		fl64 target = 6;
		pi8 * howMany = "all";
		si32 inda = 0;
		findfl64(&result, &resSize, vector, size, operation, target, howMany);
		ck_assert(result != NULL);

		for (inda = 0; inda < resSize; inda++) {
			ck_assert_int_eq(trueVal[inda], result[inda]);
		}
		free(result);
	}END_TEST
开发者ID:CptStubbs,项目名称:nav_only,代码行数:22,代码来源:test_utils.c


示例16: START_TEST

END_TEST

START_TEST(test_http_10_keepalive)
{
	const gchar *headers =
		"POST / HTTP/1.0\n"
		"Connection: keep-alive\n"
		"Content-Length: 0\n\n";

	gint err;
	qev_fd_t s = test_socket();
	struct client *client = test_get_client_raw();

	err = send(s, headers, strlen(headers), 0);
	ck_assert_int_eq(err, strlen(headers));

	_assert_status_code(s, 403);

	ck_assert(!client->qev_client._flags.closed);

	close(s);
}
开发者ID:iheartradio,项目名称:quick.io,代码行数:22,代码来源:test_protocol_http.c


示例17: ref_unref_test

END_TEST

#define ref_unref_test(T, a) \
 { \
	 int i; \
	 struct T *tmp = NULL; \
 \
	 for (i = 0; i <= 256; i++) { \
		 tmp = T##_ref(a); \
		 ck_assert(tmp == a); \
	 } \
	 for (i = 0; i <= 256; i++) { \
		 tmp = T##_unref(a); \
		 ck_assert(tmp == NULL); \
	 } \
	 for (i = 0; i <= 256; i++) { \
		 tmp = T##_ref(a); \
		 ck_assert(tmp == a); \
		 tmp = T##_unref(a); \
		 ck_assert(tmp == NULL); \
	 } \
 }

START_TEST(device_ref_unref)
{
	struct ratbag *r;
	struct ratbag_device *d;
	struct ratbag_test_device td = sane_device;

	r = ratbag_create_context(&abort_iface, NULL);
	d = ratbag_device_new_test_device(r, &td);
	ck_assert(d != NULL);

	ratbag_unref(r);

	ref_unref_test(ratbag_device, d);

	ratbag_device_unref(d);
}
开发者ID:bentiss,项目名称:libratbag,代码行数:39,代码来源:test-device.c


示例18: START_TEST

END_TEST

START_TEST(test_single_resnum_08)
{
   /* range */
   strcpy(chain,      "A");
   resnum1 =           10 ;
   strcpy(insert1,    "B");
   resnum2 =           10 ;
   strcpy(insert2,    "B");

   /* pdb */
   strcpy(pdb->chain, "A");
   pdb->resnum =       10 ;
   strcpy(pdb->insert,"A");
   
   /* expected output */
   expected_output = FALSE;
   
   output = blInPDBZone(pdb, chain, resnum1, insert1, resnum2, insert2);
   ck_assert( output == expected_output );
}
开发者ID:ACRMGroup,项目名称:bioplib,代码行数:22,代码来源:inpdbzone_suite.c


示例19: START_TEST

} END_TEST

START_TEST (test_IDSET_includes_guid_glob) {
        struct GUID       server_guid = GUID_random();
        struct GUID       random_guid = GUID_random();
        int               i;
        struct idset      *idset_in;
        struct rawidset   *rawidset_in;
        const uint16_t    repl_id = 0x0001;
        const uint64_t    ids[] = {0x180401000000,
                                   0x190401000000,
                                   0x1a0401000000,
                                   0x1b0401000000,
                                   0x500401000000,
                                   0x520401000000,
                                   0x530401000000,
                                   0x710401000000};
        const uint64_t    not_in_id = 0x2a0401000000;
        const size_t      ids_size = sizeof(ids) / sizeof(uint64_t);

        rawidset_in = RAWIDSET_make(mem_ctx, true, false);
        ck_assert(rawidset_in != NULL);
        for (i = 0; i < ids_size; i++) {
                RAWIDSET_push_eid(rawidset_in, (ids[i] << 16) | repl_id);
        }
        ck_assert_int_eq(rawidset_in->count, ids_size);
        rawidset_in->idbased = false;
        rawidset_in->repl.guid = server_guid;
        idset_in = RAWIDSET_convert_to_idset(mem_ctx, rawidset_in);
        ck_assert(idset_in != NULL);

        /* Case: All inserted elements in the range */
        for (i = 0; i < ids_size; i++) {
                ck_assert(IDSET_includes_guid_glob(idset_in, &server_guid, ids[i]));
        }

        /* Case: a different guid for the same id */
        ck_assert(!IDSET_includes_guid_glob(idset_in, &random_guid, ids[0]));

        /* Case: Not in range and different guid */
        ck_assert(!IDSET_includes_guid_glob(idset_in, &random_guid, not_in_id));

        /* Case: Not in range */
        ck_assert(!IDSET_includes_guid_glob(idset_in, &server_guid, not_in_id));

} END_TEST
开发者ID:ThHirsch,项目名称:openchange,代码行数:46,代码来源:mapi_idset.c


示例20: START_TEST

END_TEST

/*******************************************************************************
 * chunk_create_cat
 */

START_TEST(test_chunk_create_cat)
{
	chunk_t foo, bar;
	chunk_t a, b, c;
	u_char *ptra, *ptrb;

	foo = chunk_from_str("foo");
	bar = chunk_from_str("bar");

	/* to simplify things we use the chunk_cata macro */

	a = chunk_empty;
	b = chunk_empty;
	c = chunk_cata("cc", a, b);
	ck_assert_int_eq(c.len, 0);
	ck_assert(c.ptr != NULL);

	a = foo;
	b = bar;
	c = chunk_cata("cc", a, b);
	ck_assert_int_eq(c.len, 6);
	ck_assert(chunk_equals(c, chunk_from_str("foobar")));

	a = chunk_clone(foo);
	b = chunk_clone(bar);
	c = chunk_cata("mm", a, b);
	ck_assert_int_eq(c.len, 6);
	ck_assert(chunk_equals(c, chunk_from_str("foobar")));

	a = chunk_clone(foo);
	b = chunk_clone(bar);
	ptra = a.ptr;
	ptrb = b.ptr;
	c = chunk_cata("ss", a, b);
	ck_assert_int_eq(c.len, 6);
	ck_assert(chunk_equals(c, chunk_from_str("foobar")));
	/* check memory area of cleared chunk */
	ck_assert(!chunk_equals(foo, chunk_create(ptra, 3)));
	ck_assert(!chunk_equals(bar, chunk_create(ptrb, 3)));
}
开发者ID:LeiYuan,项目名称:strongswan,代码行数:46,代码来源:test_chunk.c



注:本文中的ck_assert函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ ck_assert_int_eq函数代码示例发布时间:2022-05-30
下一篇:
C++ ck_abort_msg函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap