本文整理汇总了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();
}
示例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);
}
示例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;
}
示例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;
}
}
示例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();
}
}
}
}
示例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;
}
}
示例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);
}
示例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());
}
示例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;
}
示例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;
}
示例11: ASSERT_FAIL
const Endpoint ReplicatedConfig::GetEndpoint(unsigned i)
{
if (i < 0 || i >= numNodes)
ASSERT_FAIL();
return endpoints[i];
}
示例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();
}
示例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;
}
}
}
示例14: ASSERT_FAIL
char ReadBuffer::GetCharAt(unsigned i) const
{
if (i > length - 1)
ASSERT_FAIL();
return *(buffer + i);
}
示例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;
}