本文整理汇总了C++中ck_assert函数的典型用法代码示例。如果您正苦于以下问题:C++ ck_assert函数的具体用法?C++ ck_assert怎么用?C++ ck_assert使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ck_assert函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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));
}
示例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);
}
}
示例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
示例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;
}
示例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));
}}}
}
示例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);
}
示例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);
}
}
示例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
示例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);
}
示例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);
}
}
示例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);
}
}
示例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);
}
示例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);
}
示例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
示例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