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

C++ ASSERT_NOT_NULL函数代码示例

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

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



在下文中一共展示了ASSERT_NOT_NULL函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:ihcuo,项目名称:hw2,代码行数:31,代码来源:dish_test.c


示例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);
}
开发者ID:nthevu,项目名称:kaa,代码行数:29,代码来源:test_kaa_list.c


示例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);
}
开发者ID:Acarus,项目名称:kaa,代码行数:27,代码来源:test_kaa_list.c


示例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);
}
开发者ID:tabe,项目名称:Diagonal,代码行数:27,代码来源:diag_vcdiff_contract.c


示例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);
}
开发者ID:Kirill380,项目名称:kaa,代码行数:29,代码来源:test_kaa_common_schema.c


示例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);
}
开发者ID:Kirill380,项目名称:kaa,代码行数:31,代码来源:test_kaa_common_schema.c


示例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];
}
开发者ID:jalishah,项目名称:airborne,代码行数:30,代码来源:rot2d.c


示例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);
}
开发者ID:nthevu,项目名称:kaa,代码行数:27,代码来源:test_kaa_list.c


示例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);
}
开发者ID:Aerobota,项目名称:PenguPilot,代码行数:28,代码来源:mon.c


示例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);
}
开发者ID:PldX,项目名称:geany-java-tags,代码行数:7,代码来源:java-parser-test.c


示例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;
}
开发者ID:LWSS,项目名称:gx,代码行数:28,代码来源:gx.c


示例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);
}
开发者ID:Kirill380,项目名称:kaa,代码行数:27,代码来源:test_kaa_common_schema.c


示例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;
}
开发者ID:vmware,项目名称:lightwave,代码行数:31,代码来源:key_value_pair.c


示例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));
}
开发者ID:duli2888,项目名称:company_testwork,代码行数:7,代码来源:analyze.c


示例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);
}
开发者ID:BioSoundSystems,项目名称:kaa,代码行数:59,代码来源:test_kaa_deque.c


示例16: print_ip

static void print_ip(char *buf, ip_addr *i)
{
	ASSERT_NOT_NULL(buf);
	ASSERT_NOT_NULL(i);
	l4_uint32_t addr = i->a;

	snprintf(buf, ipbuf_size, ip_fmt, ip_str(&addr));
}
开发者ID:duli2888,项目名称:company_testwork,代码行数:8,代码来源:analyze.c


示例17: threadManagerSetUp

void threadManagerSetUp(swTestSuite *suite)
{
  swEdgeLoop *loop = swEdgeLoopNew();
  ASSERT_NOT_NULL(loop);
  swThreadManager *manager = swThreadManagerNew(loop, 1000);
  ASSERT_NOT_NULL(manager);
  swTestSuiteDataSet(suite, manager);
}
开发者ID:shadowweb,项目名称:shadowlib,代码行数:8,代码来源:thread-manager-test.c


示例18: stopFunction

void stopFunction(void *arg)
{
  swTestLogLine("Terminating thread\n");
  swTreadTestData *testData = arg;
  ASSERT_NOT_NULL(testData);
  ASSERT_NOT_NULL(testData->terminate);
  *(testData->terminate) = 1L;
}
开发者ID:shadowweb,项目名称:shadowlib,代码行数:8,代码来源:thread-manager-test.c


示例19: cddb_site_get_description

cddb_error_t cddb_site_get_description(const cddb_site_t *site,
                                       const char **desc)
{
    ASSERT_NOT_NULL(site);
    ASSERT_NOT_NULL(desc);
    *desc = site->desc;
    return CDDB_ERR_OK;
}
开发者ID:Distrotech,项目名称:libcddb,代码行数:8,代码来源:cddb_site.c


示例20: cddb_site_get_submit_path

cddb_error_t cddb_site_get_submit_path(const cddb_site_t *site,
                                       const char **path)
{
    ASSERT_NOT_NULL(site);
    ASSERT_NOT_NULL(path);
    *path = site->submit_path;
    return CDDB_ERR_OK;
}
开发者ID:Distrotech,项目名称:libcddb,代码行数:8,代码来源:cddb_site.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ ASSERT_NOT_OK函数代码示例发布时间:2022-05-30
下一篇:
C++ ASSERT_NOT_IMPLEMENTED函数代码示例发布时间: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