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


C++ ASSERT_FAIL函数代码示例

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


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


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