本文整理汇总了C++中ASSERT_NOT_NULL函数的典型用法代码示例。如果您正苦于以下问题:C++ ASSERT_NOT_NULL函数的具体用法?C++ ASSERT_NOT_NULL怎么用?C++ ASSERT_NOT_NULL使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ASSERT_NOT_NULL函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testCreate
//TODO: add more tests
static bool testCreate() {
ASSERT_NULL(dishCreate(NULL,NULL,0));
ASSERT_NULL(dishCreate(NULL,NULL,1));
ASSERT_NULL(dishCreate("string",NULL,0));
ASSERT_NULL(dishCreate("",NULL,0));
ASSERT_NULL(dishCreate("","",0));
Dish dish = dishCreate("","",1);
ASSERT_NOT_NULL(dish);
dishDestroy(dish);
ASSERT_NULL(dishCreate(NULL, "Dor", 4));
ASSERT_NULL(dishCreate("Soup", "Shlomo", -1));
char name[] = "Soup";
Dish soup = dishCreate(name, "Shlomo", 5);
ASSERT_NOT_NULL(soup);
name[0] = 'R';
dishDestroy(soup);
char * name1 = (char*)malloc(sizeof(char)*4);
strcpy(name1,"ttl");
char * name2 = (char*)malloc(sizeof(char)*4);
strcpy(name2,"ttl");
free(name1);
//ASSERT_NULL(dishCreate(name1,name2,2)); no idea if this can be made not to crash
free(name2);
//ASSERT_NULL(dishCreate(name1,name2,2));
return true;
}
示例2: test_list_for_each
void test_list_for_each()
{
KAA_TRACE_IN(logger);
kaa_list_t *list = kaa_list_create();
ASSERT_NOT_NULL(list);
int32_t *number1_ptr;
int node_number = 4;
for (int i = 0; i < node_number; ++i) {
number1_ptr = (int32_t *)KAA_MALLOC(sizeof(int32_t *));
ASSERT_NOT_NULL(number1_ptr);
*number1_ptr = rand();
kaa_list_push_back(list, number1_ptr);
}
int number2 = rand();
kaa_list_for_each(kaa_list_begin(list), kaa_list_back(list), (process_data)&test_process_data, &number2);
kaa_list_node_t *it = kaa_list_begin(list);
while (it) {
ASSERT_EQUAL(*(int32_t *)kaa_list_get_data(kaa_list_begin(list)), number2);
it = kaa_list_next(it);
}
kaa_list_destroy(list, NULL);
KAA_TRACE_OUT(logger);
}
示例3: test_list_sort
static void test_list_sort()
{
kaa_list_t *list = kaa_list_create();
ASSERT_NOT_NULL(list);
uint64_t node_number = 100;
for (uint64_t i = 0; i < node_number; ++i) {
test_list_node_t *node = KAA_MALLOC(sizeof(test_list_node_t));
ASSERT_NOT_NULL(node);
node->id = (uint64_t) rand();
kaa_list_push_back(list, node);
}
ASSERT_EQUAL(kaa_list_get_size(list), node_number);
kaa_list_sort(list,&test_kaa_list_predicate);
kaa_list_node_t *it,*next;
it = kaa_list_begin(list);
next = kaa_list_next(it);
while (it && next) {
ASSERT_TRUE(((test_list_node_t*)kaa_list_get_data(it))->id <=
((test_list_node_t*)kaa_list_get_data(next))->id);
it = next;
next = kaa_list_next(it);
}
kaa_list_destroy(list, NULL);
}
示例4: contract_and_expand
static void
contract_and_expand(const char *data, size_t s_window, uint32_t base, size_t s_pcodes)
{
struct diag_vcdiff_script *script;
struct diag_rollinghash32 *rh;
size_t size, s;
uint8_t *result;
char *result0;
size = strlen(data);
rh = (struct diag_rollinghash32 *)diag_rollinghash32_new_rabin_karp((const uint8_t *)data, size, s_window, base);
ASSERT_NOT_NULL(rh);
script = diag_vcdiff_contract(rh);
ASSERT_NOT_NULL(script);
dump_pcodes(script);
ASSERT_EQ_UINT(s_pcodes, script->s_pcodes);
result = diag_vcdiff_expand(script, &s);
ASSERT_EQ_UINT(size, s);
result0 = diag_malloc(s + 1);
(void)memcpy(result0, result, s);
result0[s] = '\0';
ASSERT_EQ_STRING(data, result0);
diag_free(result0);
diag_free(result);
diag_vcdiff_script_destroy(script);
diag_rollinghash32_destroy(rh);
}
示例5: test_fixed_deserialize
static void test_fixed_deserialize(void **state)
{
(void)state;
const uint8_t plain_fixed1[] = { 0x0, 0x1, 0x2, 0x3, 0x4 };
size_t plain_fixed1_size = sizeof(plain_fixed1) / sizeof(char);
kaa_bytes_t *kaa_fixed1 = kaa_fixed_copy_create(plain_fixed1, plain_fixed1_size);
ASSERT_NOT_NULL(kaa_fixed1);
size_t expected_size = kaa_fixed_get_size(kaa_fixed1);
char buffer[expected_size];
avro_writer_t avro_writer = avro_writer_memory(buffer, expected_size);
kaa_fixed_serialize(avro_writer, kaa_fixed1);
avro_reader_t avro_reader = avro_reader_memory(buffer, expected_size);
kaa_bytes_t *kaa_fixed2 = kaa_fixed_deserialize(avro_reader, &expected_size);
ASSERT_NOT_NULL(kaa_fixed2);
ASSERT_EQUAL(memcmp(kaa_fixed2->buffer, plain_fixed1, plain_fixed1_size), 0);
ASSERT_EQUAL(memcmp(kaa_fixed2->buffer, kaa_fixed1->buffer, plain_fixed1_size), 0);
kaa_fixed_destroy(kaa_fixed2);
avro_reader_free(avro_reader);
avro_writer_free(avro_writer);
kaa_fixed_destroy(kaa_fixed1);
}
示例6: test_string_move_create
static void test_string_move_create(void **state)
{
(void)state;
ASSERT_NULL(kaa_string_move_create(NULL, NULL));
const char *plain_test_str1 = "test";
kaa_string_t *kaa_str1 = kaa_string_move_create(plain_test_str1, NULL);
ASSERT_NOT_NULL(kaa_str1);
ASSERT_NOT_NULL(kaa_str1->data);
ASSERT_NULL(kaa_str1->destroy);
ASSERT_EQUAL(strcmp(kaa_str1->data, plain_test_str1), 0);
kaa_string_destroy(kaa_str1);
kaa_str1 = NULL;
char *plain_test_str2 = (char *)KAA_MALLOC(strlen(plain_test_str1) + 1);
ASSERT_NOT_NULL(plain_test_str2);
strcpy(plain_test_str2, plain_test_str1);
kaa_string_t *kaa_str2 = kaa_string_move_create(plain_test_str2, &kaa_data_destroy);
ASSERT_NOT_NULL(kaa_str2);
ASSERT_NOT_NULL(kaa_str2->data);
ASSERT_EQUAL(kaa_str2->destroy, &kaa_data_destroy);
ASSERT_EQUAL(strcmp(kaa_str2->data, plain_test_str1), 0);
kaa_string_destroy(kaa_str2);
}
示例7: rot2d_calc
void rot2d_calc(rot2d_context_t *context, float out[2], const float in[2], float angle)
{
ASSERT_NOT_NULL(context->matrix);
ASSERT_NOT_NULL(context->in);
ASSERT_NOT_NULL(context->out);
/*
* copy arguments to input vector:
*/
context->in->ve[0] = in[0];
context->in->ve[1] = in[1];
/*
* build rotation matrix:
*
* | cos(x) -sin(x) |
* | sin(x) cos(x) |
*/
context->matrix->me[0][0] = cosf(angle);
context->matrix->me[0][1] = sinf(angle);
context->matrix->me[1][0] = -sinf(angle);
context->matrix->me[1][1] = cosf(angle);
/*
* perform rotation and result output:
*/
vm_mlt(context->matrix, context->in, context->out);
out[0] = context->out->ve[0];
out[1] = context->out->ve[1];
}
示例8: test_list_push_front
void test_list_push_front()
{
KAA_TRACE_IN(logger);
kaa_list_t *list = kaa_list_create();
ASSERT_NOT_NULL(list);
int32_t *number;
int node_number = 2;
for (int i = 0; i < node_number; ++i) {
number = (int32_t *)KAA_MALLOC(sizeof(int32_t *));
ASSERT_NOT_NULL(number);
*number = rand();
kaa_list_push_front(list, number);
}
ASSERT_EQUAL(kaa_list_get_size(list), node_number);
ASSERT_NOT_NULL(kaa_list_begin(list));
ASSERT_NULL(kaa_list_prev(kaa_list_begin(list)));
ASSERT_EQUAL((*(int32_t *)kaa_list_get_data(kaa_list_begin(list))), *number);
kaa_list_destroy(list, NULL);
KAA_TRACE_OUT(logger);
}
示例9: mon_init
PERIODIC_THREAD_END
void mon_init(void)
{
ASSERT_ONCE();
/* open monitoring socket: */
mon_socket = scl_get_socket("ap_mon");
ASSERT_NOT_NULL(mon_socket);
int64_t hwm = 1;
zmq_setsockopt(mon_socket, ZMQ_SNDHWM, &hwm, sizeof(hwm));
/* create monitoring connection: */
const struct timespec period = {0, 20 * NSEC_PER_MSEC};
pthread_mutexattr_init(&mutexattr);
pthread_mutexattr_setprotocol(&mutexattr, PTHREAD_PRIO_INHERIT);
pthread_mutex_init(&mutex, &mutexattr);
/* init msgpack buffer: */
ASSERT_NULL(msgpack_buf);
msgpack_buf = msgpack_sbuffer_new();
ASSERT_NOT_NULL(msgpack_buf);
ASSERT_NULL(pk);
pk = msgpack_packer_new(msgpack_buf, msgpack_sbuffer_write);
periodic_thread_start(&emitter_thread, mon_emitter, "mon_thread", THREAD_PRIORITY, period, NULL);
}
示例10: assert_parse_package
void assert_parse_package(const char* package_name, const char* java_text) {
JavaDocStructure* java_doc = parse_text(java_text, TRUE, FALSE);
ASSERT_NOT_NULL(java_doc);
ASSERT_NOT_NULL(java_doc->package_declaration);
ASSERT_STR_EQ(package_name, java_doc->package_declaration->package_name);
java_doc_free(java_doc);
}
示例11: destroy_ship
static void destroy_ship(struct GameState *game_state, struct Ship *ship)
{
struct UIntHashPair *pair = find_pair(&game_state->ship_id_map, ship->id);
ASSERT_NOT_NULL(pair);
uint32 array_index = pair->value;
ASSERT(array_index < game_state->ship_count);
remove_pair(&game_state->ship_id_map, ship->id);
// Ship is already at the end of the array.
if (array_index == game_state->ship_count - 1)
{
--game_state->ship_count;
return;
}
// Swap the destroyed ship with the last active ship in the array.
struct Ship last = game_state->ships[game_state->ship_count - 1];
game_state->ships[array_index] = last;
--game_state->ship_count;
// Update the ship ID map with the swapped ship's new array index.
struct UIntHashPair *last_pair = find_pair(&game_state->ship_id_map, last.id);
ASSERT_NOT_NULL(last_pair);
last_pair->value = array_index;
}
示例12: test_string_deserialize
static void test_string_deserialize(void **state)
{
(void)state;
const char *plain_test_str1 = "test";
kaa_string_t *kaa_str1 = kaa_string_copy_create(plain_test_str1);
ASSERT_NOT_NULL(kaa_str1);
size_t expected_size = kaa_string_get_size(kaa_str1);
char buffer[expected_size];
avro_writer_t avro_writer = avro_writer_memory(buffer, expected_size);
kaa_string_serialize(avro_writer, kaa_str1);
avro_reader_t avro_reader = avro_reader_memory(buffer, expected_size);
kaa_string_t *kaa_str2 = kaa_string_deserialize(avro_reader);
ASSERT_NOT_NULL(kaa_str2);
ASSERT_EQUAL(strcmp(kaa_str2->data, plain_test_str1), 0);
ASSERT_EQUAL(strcmp(kaa_str2->data, kaa_str1->data), 0);
kaa_string_destroy(kaa_str2);
avro_reader_free(avro_reader);
avro_writer_free(avro_writer);
kaa_string_destroy(kaa_str1);
}
示例13: SSOKeyValuePairNew
SSOERROR
SSOKeyValuePairNew(
PSSO_KEY_VALUE_PAIR* pp,
PCSTRING pszKey,
PCSTRING pszValue)
{
SSOERROR e = SSOERROR_NONE;
PSSO_KEY_VALUE_PAIR p = NULL;
ASSERT_NOT_NULL(pp);
ASSERT_NOT_NULL(pszKey);
ASSERT_NOT_NULL(pszValue);
e = SSOMemoryAllocate(sizeof(SSO_KEY_VALUE_PAIR), (void**) &p);
BAIL_ON_ERROR(e);
e = SSOStringAllocate(pszKey, &p->pszKey);
BAIL_ON_ERROR(e);
e = SSOStringAllocate(pszValue, &p->pszValue);
BAIL_ON_ERROR(e);
*pp = p;
error:
if (e != SSOERROR_NONE)
{
SSOKeyValuePairDelete(p);
}
return e;
}
示例14: print_mac
static void print_mac(char *buf, mac_addr *e)
{
ASSERT_NOT_NULL(buf);
ASSERT_NOT_NULL(e);
snprintf(buf, macbuf_size, mac_fmt, mac_str(e->a));
}
示例15: test_kaa_deque_first_last
void test_kaa_deque_first_last()
{
kaa_error_t error_code = KAA_ERR_NONE;
error_code = kaa_deque_first(NULL, NULL);
ASSERT_EQUAL(error_code, KAA_ERR_BADPARAM);
error_code = kaa_deque_last(NULL, NULL);
ASSERT_EQUAL(error_code, KAA_ERR_BADPARAM);
kaa_deque_t *deque = NULL;
error_code = kaa_deque_create(&deque);
ASSERT_EQUAL(error_code, KAA_ERR_NONE);
ASSERT_NOT_NULL(deque);
error_code = kaa_deque_first(deque, NULL);
ASSERT_EQUAL(error_code, KAA_ERR_BADPARAM);
error_code = kaa_deque_last(deque, NULL);
ASSERT_EQUAL(error_code, KAA_ERR_BADPARAM);
kaa_deque_iterator_t *it = NULL;
error_code = kaa_deque_first(NULL, &it);
ASSERT_EQUAL(error_code, KAA_ERR_BADPARAM);
error_code = kaa_deque_last(NULL, &it);
ASSERT_EQUAL(error_code, KAA_ERR_BADPARAM);
error_code = kaa_deque_first(deque, &it);
ASSERT_EQUAL(error_code, KAA_ERR_NONE);
ASSERT_NULL(it);
error_code = kaa_deque_last(deque, &it);
ASSERT_EQUAL(error_code, KAA_ERR_NONE);
ASSERT_NULL(it);
kaa_deque_push_back_data(deque, "data");
ASSERT_EQUAL(kaa_deque_size(deque), 1);
kaa_deque_iterator_t *it1 = NULL;
error_code = kaa_deque_first(deque, &it1);
ASSERT_EQUAL(error_code, KAA_ERR_NONE);
ASSERT_NOT_NULL(it1);
kaa_deque_iterator_t *it2 = NULL;
error_code = kaa_deque_last(deque, &it2);
ASSERT_EQUAL(error_code, KAA_ERR_NONE);
ASSERT_NOT_NULL(it2);
ASSERT_EQUAL(it1, it2);
kaa_deque_push_back_data(deque, "data");
ASSERT_EQUAL(kaa_deque_size(deque), 2);
error_code = kaa_deque_first(deque, &it1);
ASSERT_EQUAL(error_code, KAA_ERR_NONE);
ASSERT_NOT_NULL(it1);
error_code = kaa_deque_last(deque, &it2);
ASSERT_EQUAL(error_code, KAA_ERR_NONE);
ASSERT_NOT_NULL(it2);
ASSERT_NOT_EQUAL(it1, it2);
kaa_deque_destroy(deque, &test_kaa_deque_destroy_stub);
}