当前位置: 首页>>代码示例>>C++>>正文


C++ TEST_ASSERT_NOT_NULL函数代码示例

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


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

示例1: TEST

TEST(LeakDetection, BufferOverrunFoundDuringFree)
{
#ifndef USING_OUTPUT_SPY
    TEST_IGNORE();
#else
    void* m = malloc(10);
    char* s = (char*)m;
    TEST_ASSERT_NOT_NULL(m);
    s[10] = (char)0xFF;
    UnityOutputCharSpy_Enable(1);
    EXPECT_ABORT_BEGIN
    free(m);
    EXPECT_ABORT_END
    UnityOutputCharSpy_Enable(0);
    Unity.CurrentTestFailed = 0;
    CHECK(strstr(UnityOutputCharSpy_Get(), "Buffer overrun detected during free()"));
#endif
}
开发者ID:2trill2spill,项目名称:nextgen,代码行数:18,代码来源:unity_fixture_Test.c

示例2: test_mapFind_given_Ali_and_ali_is_in_the_linkedList_in_the_map_should_return_Ali_object3

void test_mapFind_given_Ali_and_ali_is_in_the_linkedList_in_the_map_should_return_Ali_object3(){
  Person *Ali = personNew("Ali",25,70.3);
  Person *Zorro = personNew("Zorro",60,55.4);
  Person *person;
  
  List *list = listNew(Ali, NULL);
  list = listAdd(Zorro,list);
  
  Map *map = mapNew(5);
  map->bucket[5] = list;
  hash_ExpectAndReturn(Ali,5);
  
  person = mapFind(map , Ali ,comparePerson, hash);
  
  TEST_ASSERT_NOT_NULL(person);
  TEST_ASSERT_EQUAL_Person(Ali,person);
  
}
开发者ID:9drashijin,项目名称:Map,代码行数:18,代码来源:test_Map_IT.c

示例3: test_stringCreate_will_update_both_based_number_and_identifier

void test_stringCreate_will_update_both_based_number_and_identifier()
{
	char *name = "num1";
	char *name1 = "num2";
	DefineElement element;
	element.ID = "num1";
	element.actualID = "200";
	DefineElement element1;
	element1.ID = "num2";
	element1.actualID = "500";
	getElement_ExpectAndReturn(DefineList, name,&element);
	getElement_ExpectAndReturn(DefineList, name1,&element1);
	String * testTokenizer = stringCreate("0x1234-num1+num2%b'101100'");
	TEST_ASSERT_NOT_NULL(testTokenizer);
	TEST_ASSERT_EQUAL_STRING("4660-200+500%44",testTokenizer->rawString);
	TEST_ASSERT_EQUAL(15,testTokenizer->length);
	TEST_ASSERT_EQUAL(0,testTokenizer->startIndex);
	free(testTokenizer);
}
开发者ID:jwchong93,项目名称:Expression_Parsing,代码行数:19,代码来源:test_Token.c

示例4: test_maplinearStore_given_Ali_but_Ali_is_same_in_Map

void test_maplinearStore_given_Ali_but_Ali_is_same_in_Map(){
	CEXCEPTION_T e;
	Person *Ali = personNew("Ali",25,70.3);
	Map *map = mapNew(5);
	
	map->bucket[3] =Ali;
	hash_ExpectAndReturn(Ali,3);
	comparePerson(Ali,Ali);
	
	Try{
		maplinearStore(map , Ali ,comparePerson, hash);
		TEST_FAIL_MESSAGE("Expect ERR_SAME_ELEMENT");
	}
	Catch(e){
	TEST_ASSERT_EQUAL(ERR_SAME_ELEMENT, e);
	TEST_ASSERT_NOT_NULL(map->bucket[3]);
	TEST_ASSERT_EQUAL_Person(Ali,getPersonFromBucketLinear(map->bucket[3]));
	}
}
开发者ID:9drashijin,项目名称:Map,代码行数:19,代码来源:test_Map_IT.c

示例5: test_controller_conf_create_and_destroy

void
test_controller_conf_create_and_destroy(void) {
  lagopus_result_t rc;
  controller_conf_t *conf = NULL;
  const char *name = "controller_name";

  controller_initialize();

  // Normal case
  {
    rc = controller_conf_create(&conf, name);
    TEST_ASSERT_EQUAL(LAGOPUS_RESULT_OK, rc);
    TEST_ASSERT_NOT_NULL_MESSAGE(conf, "conf_create() will create new controller");

    // name
    TEST_ASSERT_EQUAL_STRING(name, conf->name);

    // current_attr
    TEST_ASSERT_NULL(conf->current_attr);

    // modified_attr
    TEST_ASSERT_NOT_NULL(conf->modified_attr);

    // enabled
    TEST_ASSERT_FALSE(conf->is_enabled);

    // used
    TEST_ASSERT_FALSE(conf->is_used);
  }

  // Abnormal case
  {
    rc = controller_conf_create(NULL, name);
    TEST_ASSERT_EQUAL(LAGOPUS_RESULT_INVALID_ARGS, rc);

    rc = controller_conf_create(&conf, NULL);
    TEST_ASSERT_EQUAL(LAGOPUS_RESULT_INVALID_ARGS, rc);
  }

  controller_conf_destroy(conf);

  controller_finalize();
}
开发者ID:1514louluo,项目名称:lagopus,代码行数:43,代码来源:controller_test.c

示例6: test_controller_get_attr

void
test_controller_get_attr(void) {
  lagopus_result_t rc;
  controller_conf_t *conf = NULL;
  controller_attr_t *attr = NULL;
  const char *name = "controller_name";

  controller_initialize();

  rc = controller_conf_create(&conf, name);
  TEST_ASSERT_EQUAL(LAGOPUS_RESULT_OK, rc);
  TEST_ASSERT_NOT_NULL_MESSAGE(conf, "conf_create() will create new controller");

  rc = controller_conf_add(conf);
  TEST_ASSERT_EQUAL(LAGOPUS_RESULT_OK, rc);

  // Normal case of getter
  {
    rc = controller_get_attr(name, true, &attr);
    TEST_ASSERT_EQUAL(LAGOPUS_RESULT_INVALID_OBJECT, rc);

    rc = controller_get_attr(name, false, &attr);
    TEST_ASSERT_EQUAL(LAGOPUS_RESULT_OK, rc);
    TEST_ASSERT_NOT_NULL(attr);
  }

  // Abnormal case of getter
  {
    rc = controller_get_attr(NULL, true, &attr);
    TEST_ASSERT_EQUAL(LAGOPUS_RESULT_INVALID_ARGS, rc);

    rc = controller_get_attr(NULL, false, &attr);
    TEST_ASSERT_EQUAL(LAGOPUS_RESULT_INVALID_ARGS, rc);

    rc = controller_get_attr(name, true, NULL);
    TEST_ASSERT_EQUAL(LAGOPUS_RESULT_INVALID_ARGS, rc);

    rc = controller_get_attr(name, false, NULL);
    TEST_ASSERT_EQUAL(LAGOPUS_RESULT_INVALID_ARGS, rc);
  }

  controller_finalize();
}
开发者ID:1514louluo,项目名称:lagopus,代码行数:43,代码来源:controller_test.c

示例7: test_pktbuf_start_write__pkt_users_2

static void test_pktbuf_start_write__pkt_users_2(void)
{
    gnrc_pktsnip_t *pkt_copy, *pkt = gnrc_pktbuf_add(NULL, TEST_STRING16, sizeof(TEST_STRING16),
                                                     GNRC_NETTYPE_TEST);

    gnrc_pktbuf_hold(pkt, 1);
    TEST_ASSERT_NOT_NULL((pkt_copy = gnrc_pktbuf_start_write(pkt)));
    TEST_ASSERT(pkt != pkt_copy);
    TEST_ASSERT(pkt->next == pkt_copy->next);
    TEST_ASSERT_EQUAL_STRING(pkt->data, pkt_copy->data);
    TEST_ASSERT_EQUAL_INT(pkt->size, pkt_copy->size);
    TEST_ASSERT_EQUAL_INT(pkt->type, pkt_copy->type);
    TEST_ASSERT_EQUAL_INT(pkt->users, pkt_copy->users);
    TEST_ASSERT_EQUAL_INT(1, pkt->users);

    gnrc_pktbuf_release(pkt_copy);
    gnrc_pktbuf_release(pkt);
    TEST_ASSERT(gnrc_pktbuf_is_empty());
}
开发者ID:A-Paul,项目名称:RIOT,代码行数:19,代码来源:tests-pktbuf.c

示例8: test_pktbuf_realloc_data__success

static void test_pktbuf_realloc_data__success(void)
{
    char exp_data[] = TEST_STRING16;
    gnrc_pktsnip_t *pkt;

    pkt = gnrc_pktbuf_add(NULL, TEST_STRING16, sizeof(TEST_STRING16), GNRC_NETTYPE_TEST);

    TEST_ASSERT_NOT_NULL(pkt);

    TEST_ASSERT_EQUAL_INT(0, gnrc_pktbuf_realloc_data(pkt, sizeof(TEST_STRING8)));
    TEST_ASSERT_NULL(pkt->next);
    TEST_ASSERT_EQUAL_INT(sizeof(TEST_STRING8), pkt->size);
    for (unsigned int i = 0; i < pkt->size; i++) {
        uint8_t *data = pkt->data;
        TEST_ASSERT_EQUAL_INT(exp_data[i], data[i]);
    }
    TEST_ASSERT_EQUAL_INT(GNRC_NETTYPE_TEST, pkt->type);
    TEST_ASSERT_EQUAL_INT(1, pkt->users);
}
开发者ID:A-Paul,项目名称:RIOT,代码行数:19,代码来源:tests-pktbuf.c

示例9: test_metadata

void test_metadata ()
{
    char my_endpoint[MAX_SOCKET_STRING];
    setup_test_context ();

    //  Spawn ZAP handler
    //  We create and bind ZAP socket in main thread to avoid case
    //  where child thread does not start up fast enough.
    void *handler = zmq_socket (get_test_context (), ZMQ_REP);
    TEST_ASSERT_NOT_NULL (handler);
    TEST_ASSERT_SUCCESS_ERRNO (zmq_bind (handler, "inproc://zeromq.zap.01"));
    void *zap_thread = zmq_threadstart (&zap_handler, handler);

    void *server = test_context_socket (ZMQ_DEALER);
    void *client = test_context_socket (ZMQ_DEALER);
    TEST_ASSERT_SUCCESS_ERRNO (
      zmq_setsockopt (server, ZMQ_ZAP_DOMAIN, "DOMAIN", 6));
    bind_loopback_ipv4 (server, my_endpoint, sizeof (my_endpoint));
    TEST_ASSERT_SUCCESS_ERRNO (zmq_connect (client, my_endpoint));

    s_send (client, "This is a message");
    zmq_msg_t msg;
    zmq_msg_init (&msg);
    TEST_ASSERT_SUCCESS_ERRNO (zmq_msg_recv (&msg, server, 0));
    TEST_ASSERT_EQUAL_STRING ("World", zmq_msg_gets (&msg, "Hello"));
    TEST_ASSERT_EQUAL_STRING ("DEALER", zmq_msg_gets (&msg, "Socket-Type"));
    TEST_ASSERT_EQUAL_STRING ("anonymous", zmq_msg_gets (&msg, "User-Id"));
    TEST_ASSERT_EQUAL_STRING ("127.0.0.1", zmq_msg_gets (&msg, "Peer-Address"));

    TEST_ASSERT_NULL (zmq_msg_gets (&msg, "No Such"));
    TEST_ASSERT_EQUAL_INT (EINVAL, zmq_errno ());
    zmq_msg_close (&msg);

    test_context_socket_close_zero_linger (client);
    test_context_socket_close_zero_linger (server);

    //  Shutdown
    teardown_test_context ();

    //  Wait until ZAP handler terminates
    zmq_threadclose (zap_thread);
}
开发者ID:CommanderBubble,项目名称:libzmq,代码行数:42,代码来源:test_metadata.cpp

示例10: test_libcoap_parser_parse_message_with_payload_and_token

/**
 * \fn test_libcoap_parser_parse_message_with_payload_and_token(void)
 *
 * \brief call coap protocol parser with message with token option and small payload (ACK - changed)
 *
 */
void test_libcoap_parser_parse_message_with_payload_and_token(void)
{
    coap_address.addr_ptr = address;

    sn_coap_hdr_s *coap_header_ptr = sn_coap_protocol_parse(handle, &coap_address, sizeof(coap_message_token_payload), coap_message_token_payload, NULL);

    TEST_ASSERT_NOT_NULL(coap_header_ptr);

    TEST_ASSERT_EQUAL(COAP_MSG_TYPE_ACKNOWLEDGEMENT, coap_header_ptr->msg_type);
    TEST_ASSERT_EQUAL(COAP_MSG_CODE_RESPONSE_CHANGED, coap_header_ptr->msg_code);
    TEST_ASSERT_EQUAL(0x1234, coap_header_ptr->msg_id);

    TEST_ASSERT_EQUAL(3, coap_header_ptr->token_len);
    TEST_ASSERT_EQUAL_INT8_ARRAY(option_short, coap_header_ptr->token_ptr, sizeof(option_short));

    TEST_ASSERT_EQUAL(3, coap_header_ptr->payload_len);
    TEST_ASSERT_EQUAL_INT8_ARRAY(option_short, coap_header_ptr->payload_ptr, sizeof(option_short));

    sn_coap_parser_release_allocated_coap_msg_mem(handle, coap_header_ptr);
}
开发者ID:AlessandroA,项目名称:mbed,代码行数:26,代码来源:Test.c

示例11: test_mapStore_given_Ali_but_Ali_is_same_in_Map

void test_mapStore_given_Ali_but_Ali_is_same_in_Map(){
	CEXCEPTION_T e;
	Person *person = personNew("Ali",25,70.3);
	List *list = listNew(person, NULL);
	Map *map = mapNew(5);
	
	map->bucket[3] =list;
	hash_ExpectAndReturn(person,3);
	comparePerson(person,person);
	
	Try{
		mapStore(map , person ,comparePerson, hash);
		TEST_FAIL_MESSAGE("Expect ERR_SAME_ELEMENT");
	}
	Catch(e){
	TEST_ASSERT_EQUAL(ERR_SAME_ELEMENT, e);
	TEST_ASSERT_NOT_NULL(map->bucket[3]);
	TEST_ASSERT_EQUAL_Person(person,getPersonFromBucket(map->bucket[3]));
	}
}
开发者ID:9drashijin,项目名称:Map,代码行数:20,代码来源:test_Map_IT.c

示例12: test_pktbuf_add__in_place

static void test_pktbuf_add__in_place(void)
{
    ng_pktsnip_t *pkt = ng_pktbuf_add(NULL, TEST_STRING16, sizeof(TEST_STRING16),
                                      NG_NETTYPE_UNDEF);
    ng_pktsnip_t *header;

    TEST_ASSERT_NOT_NULL((header = ng_pktbuf_add(pkt, pkt->data, 4, NG_NETTYPE_UNDEF)));
    TEST_ASSERT(header == pkt->next);
    TEST_ASSERT_EQUAL_STRING(TEST_STRING16, header->data); /* there is no 0 byte */
    TEST_ASSERT_EQUAL_INT(4, header->size);
    TEST_ASSERT_EQUAL_INT(NG_NETTYPE_UNDEF, header->type);
    TEST_ASSERT_EQUAL_INT(1, header->users);
    TEST_ASSERT_EQUAL_STRING(TEST_STRING16 + 4, pkt->data);
    TEST_ASSERT_EQUAL_INT(sizeof(TEST_STRING16) - 4, pkt->size);
    TEST_ASSERT_EQUAL_INT(NG_NETTYPE_UNDEF, pkt->type);
    TEST_ASSERT_EQUAL_INT(1, pkt->users);
    ng_pktbuf_release(header);
    ng_pktbuf_release(pkt);
    TEST_ASSERT(ng_pktbuf_is_empty());
}
开发者ID:centurysys,项目名称:RIOT,代码行数:20,代码来源:tests-pktbuf.c

示例13: test_mapStore_given_Zorro_added_into_Ali_in_the_Map

void test_mapStore_given_Zorro_added_into_Ali_in_the_Map(){
	CEXCEPTION_T e;
	Person *person = personNew("Ali",25,70.3);
	Person *Zorro = personNew("Zorro",60,55.4);
	List *list = listNew(person, NULL);
	Map *map = mapNew(5);
	
	map->bucket[3] = list;
	hash_ExpectAndReturn(Zorro,3);
	
	Try{
		mapStore(map , Zorro ,comparePerson, hash);

		TEST_ASSERT_NOT_NULL(map->bucket[3]);
		TEST_ASSERT_EQUAL_Person(Zorro,getPersonFromBucket(map->bucket[3]));
		TEST_ASSERT_EQUAL_Person(person,getPersonFromBucket(((List *)map->bucket[3])->next));
	}
	Catch(e){
		TEST_FAIL_MESSAGE("Expect Zorro");
	}
}
开发者ID:9drashijin,项目名称:Map,代码行数:21,代码来源:test_Map_IT.c

示例14: test_getToken_should_detect_modulus_sign

void test_getToken_should_detect_modulus_sign()
{
	String *testTokenizer = stringCreate("200%10");
	
	//Since the program already can detect 25.
	Token *testToken;
	free(getToken(testTokenizer));
	testToken = getToken(testTokenizer);
	
	//This testToken should be not NULL
	TEST_ASSERT_NOT_NULL(testToken);
	//With operator type.
	TEST_ASSERT_EQUAL(OPERATOR,*testToken);
	Operator *opeToken = (Operator*)testToken;
	TEST_ASSERT_EQUAL(OPERATOR,opeToken->type);
	TEST_ASSERT_EQUAL(MODULUS,opeToken->id);
	TEST_ASSERT_EQUAL(70,opeToken->precedence);
	free(testTokenizer);
	free(opeToken);
	
}
开发者ID:jwchong93,项目名称:Expression_Parsing,代码行数:21,代码来源:test_Token.c

示例15: cjson_utils_functions_shouldnt_crash_with_null_pointers

static void cjson_utils_functions_shouldnt_crash_with_null_pointers(void)
{
    cJSON *item = cJSON_CreateString("item");
    TEST_ASSERT_NOT_NULL(item);

    TEST_ASSERT_NULL(cJSONUtils_GetPointer(item, NULL));
    TEST_ASSERT_NULL(cJSONUtils_GetPointer(NULL, "pointer"));
    TEST_ASSERT_NULL(cJSONUtils_GetPointerCaseSensitive(NULL, "pointer"));
    TEST_ASSERT_NULL(cJSONUtils_GetPointerCaseSensitive(item, NULL));
    TEST_ASSERT_NULL(cJSONUtils_GeneratePatches(item, NULL));
    TEST_ASSERT_NULL(cJSONUtils_GeneratePatches(NULL, item));
    TEST_ASSERT_NULL(cJSONUtils_GeneratePatchesCaseSensitive(item, NULL));
    TEST_ASSERT_NULL(cJSONUtils_GeneratePatchesCaseSensitive(NULL, item));
    cJSONUtils_AddPatchToArray(item, "path", "add", NULL);
    cJSONUtils_AddPatchToArray(item, "path", NULL, item);
    cJSONUtils_AddPatchToArray(item, NULL, "add", item);
    cJSONUtils_AddPatchToArray(NULL, "path", "add", item);
    cJSONUtils_ApplyPatches(item, NULL);
    cJSONUtils_ApplyPatches(NULL, item);
    cJSONUtils_ApplyPatchesCaseSensitive(item, NULL);
    cJSONUtils_ApplyPatchesCaseSensitive(NULL, item);
    TEST_ASSERT_NULL(cJSONUtils_MergePatch(item, NULL));
    item = cJSON_CreateString("item");
    TEST_ASSERT_NULL(cJSONUtils_MergePatchCaseSensitive(item, NULL));
    item = cJSON_CreateString("item");
    /* these calls are actually valid */
    /* cJSONUtils_MergePatch(NULL, item); */
    /* cJSONUtils_MergePatchCaseSensitive(NULL, item);*/
    /* cJSONUtils_GenerateMergePatch(item, NULL); */
    /* cJSONUtils_GenerateMergePatch(NULL, item); */
    /* cJSONUtils_GenerateMergePatchCaseSensitive(item, NULL); */
    /* cJSONUtils_GenerateMergePatchCaseSensitive(NULL, item); */

    TEST_ASSERT_NULL(cJSONUtils_FindPointerFromObjectTo(item, NULL));
    TEST_ASSERT_NULL(cJSONUtils_FindPointerFromObjectTo(NULL, item));
    cJSONUtils_SortObject(NULL);
    cJSONUtils_SortObjectCaseSensitive(NULL);

    cJSON_Delete(item);
}
开发者ID:Chinazhouwy,项目名称:cJSON,代码行数:40,代码来源:misc_utils_tests.c


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