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

C++ ASSERT_FAIL函数代码示例

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

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



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

示例1: Log_Trace

void SingleKeyspaceDB::OnExpiryTimer()
{
	uint64_t	expiryTime;
	Cursor		cursor;
	ByteString	key;

	Log_Trace();
	
	table->Iterate(NULL, cursor);	
	kdata.Set("!!t:");
	if (!cursor.Start(kdata))
		ASSERT_FAIL();
	cursor.Close();
	
	if (kdata.length < 2)
		ASSERT_FAIL();
	
	if (kdata.buffer[0] != '!' || kdata.buffer[1] != '!')
		ASSERT_FAIL();

	ReadExpiryTime(kdata, expiryTime, key);
	table->Delete(NULL, kdata);
	table->Delete(NULL, key);

	WriteExpiryKey(kdata, key);
	table->Delete(NULL, kdata);
	
	Log_Trace("Expiring key: %.*s", key.length, key.buffer);

	InitExpiryTimer();
}
开发者ID:benlaurie,项目名称:keyspace,代码行数:31,代码来源:SingleKeyspaceDB.cpp


示例2: test_wrong_op_fail

static void
test_wrong_op_fail(void)
{
	ASSERT_FAIL("'a' =! 'a'", PE_INVALID_EXPRESSION);
	ASSERT_FAIL("'a' => 'a'", PE_INVALID_EXPRESSION);
	ASSERT_FAIL("'a' =< 'a'", PE_INVALID_EXPRESSION);
}
开发者ID:KryDos,项目名称:vifm,代码行数:7,代码来源:compares.c


示例3: IoTHubMessage

/*this function "links" IoTHub to the serialization library*/
static IOTHUBMESSAGE_DISPOSITION_RESULT IoTHubMessage(IOTHUB_MESSAGE_HANDLE message, void* userContextCallback)
{
    const unsigned char* buffer;
    size_t size;
    if (IoTHubMessage_GetByteArray(message, &buffer, &size) != IOTHUB_MESSAGE_OK)
    {
        ASSERT_FAIL("unable to IoTHubMessage_GetByteArray");
    }
    else
    {
        /*buffer is not zero terminated*/
        char* buffer_string = (char*)malloc(size+1);
        ASSERT_IS_NOT_NULL(buffer_string);

        if (memcpy(buffer_string, buffer, size) == 0)
        {
            ASSERT_FAIL("memcpy failed for buffer");
        }
        else
        {
            buffer_string[size] = '\0';
            EXECUTE_COMMAND(userContextCallback, buffer_string);
        }
        free(buffer_string);
    }
    return IOTHUBMESSAGE_ACCEPTED;
}
开发者ID:Eclo,项目名称:azure-iot-sdks,代码行数:28,代码来源:serializer_e2e.cpp


示例4: Log_Trace

void ConfigQuorumContext::OnMessage(ReadBuffer buffer)
{
    char proto;
    
    Log_Trace("%R", &buffer);

    if (buffer.GetLength() < 2)
        ASSERT_FAIL();

    proto = buffer.GetCharAt(0);
    ASSERT(buffer.GetCharAt(1) == ':');
    
    switch(proto)
    {
        case PAXOSLEASE_PROTOCOL_ID:        // 'L':
            OnPaxosLeaseMessage(buffer);
            break;
        case PAXOS_PROTOCOL_ID:             // 'P':
            OnPaxosMessage(buffer);
            break;
        case CATCHUP_PROTOCOL_ID:           // 'C'
            OnCatchupMessage(buffer);
            break;
        default:
            ASSERT_FAIL();
            break;
    }
}
开发者ID:azybler,项目名称:scaliendb,代码行数:28,代码来源:ConfigQuorumContext.cpp


示例5: CTEST2

CTEST2(reorder, shuffle)
{
  memcpy(data->buffer, data->fororder, data->N * sizeof(*data->buffer));

  /* do this 10 times */
  for(idx_t e=0; e < 10; ++e) {
    shuffle_idx(data->buffer, data->N);
    idx_t same = 0;
    for(idx_t x=0; x < data->N; ++x) {
      if(data->fororder[x] == data->buffer[x]) {
        ++same;
      }
    }

    /* arbitrary */
    if(same > 4) {
      ASSERT_FAIL();
    }

    /* check for duplicate/missing values */
    memcpy(data->fororder, data->buffer, data->N * sizeof(*data->buffer));
    quicksort(data->fororder, data->N);
    for(idx_t x=0; x < data->N; ++x) {
      if(data->fororder[x] != x) {
        ASSERT_FAIL();
      }
    }
  }
}
开发者ID:ShadenSmith,项目名称:splatt,代码行数:29,代码来源:reorder_test.c


示例6: Log_Trace

void ContextTransport::OnMessage(uint64_t nodeID, ReadBuffer msg)
{
    int         nread;
    char        proto;
    
    Log_Trace("%R", &msg);
    
    if (msg.GetLength() < 2)
        ASSERT_FAIL();

    nread = msg.Readf("%c:", &proto);
    if (nread < 2)
        ASSERT_FAIL();

    msg.Advance(2);
    
    switch (proto)
    {
        case PROTOCOL_CLUSTER:
            OnClusterMessage(nodeID, msg);
            break;
        case PROTOCOL_QUORUM:
            OnQuorumMessage(nodeID, msg);
            break;
        default:
            ASSERT_FAIL();
            break;
    }
}
开发者ID:rokiCode,项目名称:scaliendb,代码行数:29,代码来源:ContextTransport.cpp


示例7: test_spaces_in_op_fail

static void
test_spaces_in_op_fail(void)
{
	ASSERT_FAIL("'a' ! = 'a'", PE_INVALID_EXPRESSION);
	ASSERT_FAIL("'a' = = 'a'", PE_INVALID_EXPRESSION);
	ASSERT_FAIL("'a' > = 'a'", PE_INVALID_EXPRESSION);
	ASSERT_FAIL("'a' < = 'a'", PE_INVALID_EXPRESSION);
}
开发者ID:KryDos,项目名称:vifm,代码行数:8,代码来源:compares.c


示例8: test_spaces_and_fail_position_correct

static void
test_spaces_and_fail_position_correct(void)
{
	ASSERT_FAIL("  'b' c", PE_INVALID_EXPRESSION)
	assert_string_equal("'b' c", get_last_position());

	ASSERT_FAIL("  a b", PE_INVALID_EXPRESSION)
	assert_string_equal("a b", get_last_position());
}
开发者ID:KryDos,项目名称:vifm,代码行数:9,代码来源:general_tests.c


示例9: IoTHubCallback

static int IoTHubCallback(void* context, const char* data, size_t size)
{
    EXPECTED_SEND_DATA* expectedData = (EXPECTED_SEND_DATA*)context;
    int result = 0; // 0 means "keep processing"

    if (expectedData != NULL)
    {
        if (Lock(expectedData->lock) != LOCK_OK)
        {
            ASSERT_FAIL("unable to lock");
        }
        else
        {
            if (
                (strlen(expectedData->expectedString) == size) &&
                (memcmp(expectedData->expectedString, data, size) == 0)
                )
            {
                expectedData->wasFound = true;
                result = 1;
            }
            (void)Unlock(expectedData->lock);
        }
    }
    return result;
}
开发者ID:MBLight,项目名称:azure-iot-sdk-c,代码行数:26,代码来源:iothubclient_http_e2e.c


示例10: screen_key_event_handler

static bool screen_key_event_handler(void *usr, key_event_t *e)
{
    PyObject *func = (PyObject *)usr;
    PyObject *args = PyTuple_New(1);
    PyTuple_SetItem(args, 0, PyInt_FromLong(e->key_code));
    PyObject *result = PyObject_CallObject(func, args);

    bool ret = false;
    if(!PyBool_Check(result)) {
        ERROR("python key handler did not return a boolean\n");
        ret = false;
    } else if(result == Py_True) {
        ret = true;
    } else if(result == Py_False) {
        ret = false;
    } else {
        ASSERT_FAIL("screen_key_event_handler: this should never happen...");
    }

    // some cleanup
    Py_DECREF(result);
    Py_DECREF(args);

    return ret;
}
开发者ID:ajbonkoski,项目名称:pye,代码行数:25,代码来源:execution_screen.c


示例11: ASSERT_FAIL

const Endpoint ReplicatedConfig::GetEndpoint(unsigned i)
{
	if (i < 0 || i >= numNodes)
		ASSERT_FAIL();
	
	return endpoints[i];
}
开发者ID:KingJiangNet,项目名称:NPaxosLease,代码行数:7,代码来源:ReplicatedConfig.cpp


示例12: Log_Trace

void ReplicatedKeyspaceDB::FailKeyspaceOps()
{
	Log_Trace();

	KeyspaceOp	**it;
	KeyspaceOp	*op;
	for (it = ops.Head(); it != NULL; /* advanded in body */)
	{
		op = *it;
		
		it = ops.Remove(it);
		op->status = false;
		if (op->service)
			op->service->OnComplete(op);
		else
		{
			assert(op->type == KeyspaceOp::EXPIRE);
			delete op;
		}
	}

	expiryAdded = false;

	if (ops.Length() > 0)
		ASSERT_FAIL();
}
开发者ID:benlaurie,项目名称:keyspace,代码行数:26,代码来源:ReplicatedKeyspaceDB.cpp


示例13: res

void RGB24Buffer::drawFlowBuffer(FlowBuffer *src, int32_t y, int32_t x)
{
    int i,j;
    for (i = 0; i < src->h; i++)
    {
        for (j = 0; j < src->w; j++)
        {
            if (!src->isElementKnown(i,j))
            {
                continue;
            }
            FlowElement vec = src->element(i,j);

#ifdef ASSERTS
            Vector2d32 res(vec);
            res += Vector2d32(j, i);
            if (!this->isValidCoord(res))
            {
                ASSERT_FAIL("Overflow in the flow");
            }
#endif

            RGBColor color = RGBColor(128 + (vec.x() * 5),128 + (vec.y() * 5), 0);

            this->element(i + y, j + x) = color;
        }
    }
}
开发者ID:ArsenyChernyaev,项目名称:corecvs,代码行数:28,代码来源:rgb24Buffer.cpp


示例14: ASSERT_FAIL

char ReadBuffer::GetCharAt(unsigned i) const
{
    if (i > length - 1)
        ASSERT_FAIL();
    
    return *(buffer + i);
}
开发者ID:azybler,项目名称:scaliendb,代码行数:7,代码来源:ReadBuffer.cpp


示例15: ASSERT_FAIL

bool IOProcessor::Add(IOOperation* ioop)
{
	if (ioop->active)
	{
		ASSERT_FAIL();
//		return true;
	}

	// empty buffer indicates that we are waiting for accept event
	if (ioop->type == TCP_READ && ioop->data.buffer == NULL)
		return StartAsyncAccept(ioop);

	// zero length indicates that we are waiting for connect event
	if (ioop->type == TCP_WRITE && ioop->data.length == 0)
		return StartAsyncConnect(ioop);

	switch (ioop->type)
	{
	case TCP_READ:
	case UDP_READ:
		return RequestReadNotification(ioop);
		break;
	case TCP_WRITE:
	case UDP_WRITE:
		return RequestWriteNotification(ioop);
		break;
	}

	return false;
}
开发者ID:agazso,项目名称:keyspace,代码行数:30,代码来源:IOProcessor_Windows.cpp


示例16: IoTHubCallback

 static int IoTHubCallback(void* context, const char* data, size_t size)
 {
     int result = 0; // 0 means "keep processing"
     EXPECTED_SEND_DATA* expectedData = (EXPECTED_SEND_DATA*)context;
     //printf("Received: %*.*s\n", (int)size, (int)size, data);
     if (expectedData != NULL)
     {
         if (Lock(expectedData->lock) != LOCK_OK)
         {
             ASSERT_FAIL("unable to lock");
         }
         else
         {
             if (size != strlen(expectedData->expectedString))
             {
                 result = 0;
             }
             else
             {
                 if (memcmp(expectedData->expectedString, data, size) == 0)
                 {
                     expectedData->wasFound = true;
                     result = 1;
                 }
                 else
                 {
                     result = 0;
                 }
             }
             (void)Unlock(expectedData->lock);
         }
     }
     return result;
 }
开发者ID:Eclo,项目名称:azure-iot-sdks,代码行数:34,代码来源:serializer_e2e.cpp


示例17: EventData_Create

static EXPECTED_SEND_DATA* EventData_Create(void)
{
    EXPECTED_SEND_DATA* result = (EXPECTED_SEND_DATA*)malloc(sizeof(EXPECTED_SEND_DATA));
    if (result != NULL)
    {
        if ((result->lock = Lock_Init()) == NULL)
        {
            ASSERT_FAIL("unable to Lock_Init");
        }
        else
        {
            char temp[1000];
            char* tempString;
            time_t t = time(NULL);
            sprintf(temp, TEST_EVENT_DATA_FMT, ctime(&t), g_iotHubTestId);
            if ((tempString = (char*)malloc(strlen(temp) + 1)) == NULL)
            {
                Lock_Deinit(result->lock);
                free(result);
                result = NULL;
            }
            else
            {
                strcpy(tempString, temp);
                result->expectedString = tempString;
                result->wasFound = false;
                result->dataWasRecv = false;
            }
        }
    }
    return result;
}
开发者ID:MBLight,项目名称:azure-iot-sdk-c,代码行数:32,代码来源:iothubclient_http_e2e.c


示例18: sanity_checks

static void sanity_checks(unsigned int check)
{
	if (check >= NUM_TEST_TYPES) {
		CTEST_LOG("WARNING: argument check out of bounds");
		ASSERT_FAIL();
	}
}
开发者ID:gokulvasan,项目名称:CapacityShifting,代码行数:7,代码来源:test_tsaheylu.c


示例19: Log_Trace

void ReplicatedLog::OnMessage(PaxosMessage& imsg)
{
    Log_Trace();
    bool processed;

    processed = false;
    if (imsg.type == PAXOS_PREPARE_REQUEST)
        processed = OnPrepareRequest(imsg);
    else if (imsg.IsPrepareResponse())
        processed = OnPrepareResponse(imsg);
    else if (imsg.type == PAXOS_PROPOSE_REQUEST)
        processed = OnProposeRequest(imsg);
    else if (imsg.IsProposeResponse())
        processed = OnProposeResponse(imsg);
    else if (imsg.IsLearn())
        processed = OnLearnChosen(imsg);
    else if (imsg.type == PAXOS_REQUEST_CHOSEN)
        processed = OnRequestChosen(imsg);
    else if (imsg.type == PAXOS_START_CATCHUP)
        processed = OnStartCatchup(imsg);
    else
        ASSERT_FAIL();

    if (processed)
        context->OnMessageProcessed();
}
开发者ID:scalien,项目名称:scaliendb,代码行数:26,代码来源:ReplicatedLog.cpp


示例20: base_test

int base_test()
{
	int64_t llval;
	fc_conf_t conf;
	fc_item_t item, item2;

	fc_conf_init(&conf);
	conf.ksem = SEMKEY;
	conf.kmem = SHMKEY;
	conf.memsize = SHMSIZE;

	memset(&item, 0, sizeof(item));
	memset(&item2, 0, sizeof(item2));

	ASSERT_OK(fc_init(&conf)==0,"[%d:%s]",ERRPAIR);
	SETKV(item2,"yingyuan","");
	ASSERT_FAIL(fc_get(&item2)==0,"[%d:%s]%s:%s",ERRPAIR,ITPAIR(item2));
	SETKV(item,"yingyuan","Cheng Yingyuan");
	ASSERT_OK(fc_add(&item)==0,"[%d:%s]%s:%s",ERRPAIR,ITPAIR(item));
	ASSERT_OK(fc_get(&item2)==0,"[%d:%s]%s:%s",ERRPAIR,ITPAIR(item2));
	ASSERT_EQ(item,item2);
	ASSERT_FAIL(fc_add(&item)==0,"[%d:%s]%s:%s",ERRPAIR,ITPAIR(item));
	//SETKV(item2, "yingyuanx", "xxxxxx");
	//ASSERT_OK(fc_get(&item2)==0,"[%d:%s]%s:%s",ERRPAIR,ITPAIR(item2));
	//ASSERT_EQ(item,item2);
	//SETKV(item, "yingyuan", "REAL WORLD");
	//ASSERT_OK(fc_get(&item2)==0,"[%d:%s]%s:%s",ERRPAIR,ITPAIR(item2));
	//ASSERT_EQ(item,item2);
	//SETKV(item,"yingyuanx","Cheng");
	//SETKV(item2,"yingyuanx","");
	//ASSERT_OK(fc_get(&item2)==0,"[%d:%s]%s:%s",ERRPAIR,ITPAIR(item2));
	//ASSERT_EQ(item,item2);
	SETKV(item2,"age","");
	item2.value = (char *)&llval;
	item2.vlen = sizeof(llval);
	llval=1000;
	ASSERT_OK(llval==2000,"inlegal llval %llu",llval);
	//SETKV(item2, "yingyuanx","");
	/*fc_debug(stdout, 1);
	fc_dump(stdout);*/
	SETKV(item,"yingyuan","");
	//ASSERT_FAIL(fc_get(&item)==0,"%s","error test fail");
	/*ASSERT_OK(fc_destroy()==0,"%s","base test");*/
	printf("PASS!!!\n");
	return 0;
}
开发者ID:angelasong,项目名称:ConstCache,代码行数:46,代码来源:test.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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