本文整理汇总了C++中ASSERT_RETURN函数的典型用法代码示例。如果您正苦于以下问题:C++ ASSERT_RETURN函数的具体用法?C++ ASSERT_RETURN怎么用?C++ ASSERT_RETURN使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ASSERT_RETURN函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ASSERT_RETURN
BOOL CFileVersionInfo::QueryStringValue( IN LPCTSTR lpszItem,
OUT LPTSTR lpszValue,
IN INT nBuf ) const
{
if( m_bValid == FALSE || lpszItem == NULL )
ASSERT_RETURN( FALSE );
if( lpszValue != NULL && nBuf <= 0 )
ASSERT_RETURN( FALSE );
::ZeroMemory( lpszValue, nBuf * sizeof( TCHAR ) );
TCHAR szSFI[ MAX_PATH ] = { 0 };
::wsprintf( szSFI, _T( "\\StringFileInfo\\%04X%04X\\%s" ),
GetCurLID(), GetCurCP(), lpszItem );
BOOL bRes = FALSE;
UINT uLen = 0;
LPTSTR lpszBuf = NULL;
if( ::VerQueryValue( m_lpbyVIB, (LPTSTR)szSFI, (LPVOID*)&lpszBuf, &uLen ) )
{
if( lpszValue != NULL && nBuf > 0 )
bRes = (BOOL)( ::lstrcpyn( lpszValue, lpszBuf, nBuf ) != NULL );
else
bRes = TRUE;
}
return ( bRes );
}
示例2: kdbus_test_sync_reply
int kdbus_test_sync_reply(struct kdbus_test_env *env)
{
pthread_t thread;
int ret;
conn_a = kdbus_hello(env->buspath, 0, NULL, 0);
conn_b = kdbus_hello(env->buspath, 0, NULL, 0);
ASSERT_RETURN(conn_a && conn_b);
pthread_create(&thread, NULL, run_thread, NULL);
ret = kdbus_msg_send(conn_b, NULL, cookie,
KDBUS_MSG_FLAGS_EXPECT_REPLY |
KDBUS_MSG_FLAGS_SYNC_REPLY,
5000000000ULL, 0, conn_a->id);
pthread_join(thread, NULL);
ASSERT_RETURN(ret == 0);
kdbus_printf("-- closing bus connections\n");
kdbus_conn_free(conn_a);
kdbus_conn_free(conn_b);
return TEST_OK;
}
示例3: ASSERT_RETURN
bool KBagManager::AddOneCell( const SC_BagAddResponse* pBAR )
{
ASSERT_RETURN(pBAR, false);
int nBagID = pBAR->byteBagID;
KBag* pBag = FindBag(nBagID);
ASSERT_RETURN(pBag, false);
KItem item;
item.Clear();
KMsgInputStream si(pBAR->GetItemBuffer(), pBAR->nItemBufferSize);
if(!item.Unserilize(si))
{
return false;
}
if(!pBag->AddOneCell(pBAR->nPos, item))
{
return false;
}
pBag->NumChange(item.GetID(), item.GetStackNumber());
// 通知界面
int nBoxID = BagId2BoxID(nBagID);
ASSERT_RETURN(-1 != nBoxID, false);
KItemBlock* pIB = KItemBlock::Alloc();
pIB->SetPos(nBoxID, pBAR->nPos);
KBlockBoxManager::Instance()->PutBlock(nBoxID, pBAR->nPos, pIB);
if (nBagID == enum_item_BagNormal)
{
KDynamicWorld::getSingleton().SendWorldMsg(LOGIC_WORLD_NORMAL_BAG_ITEM_CHANGE, item.GetID(), 0);
}
return true;
}
示例4: BoxID2BagID
bool KBagManager::IsValidCell( int nBoxId, int nPos ) const
{
int nBagId = BoxID2BagID(nBoxId);
ASSERT_RETURN(nBagId >= enum_item_Bag_Start, false);
const KBag* pBag = FindBag(nBagId);
ASSERT_RETURN(pBag, false);
return pBag->IsPosValid(nPos);
}
示例5: kdbus_test_fd_passing
int kdbus_test_fd_passing(struct kdbus_test_env *env)
{
struct kdbus_conn *conn_src, *conn_dst;
const char *str = "stackenblocken";
const struct kdbus_item *item;
struct kdbus_msg *msg;
unsigned int i;
int fds[2];
int ret;
/* create two connections */
conn_src = kdbus_hello(env->buspath, 0, NULL, 0);
conn_dst = kdbus_hello(env->buspath, 0, NULL, 0);
ASSERT_RETURN(conn_src && conn_dst);
/*
* Try to ass the handle of a connection as message payload.
* This must fail.
*/
ret = send_fd(conn_src, conn_dst->id, conn_src->fd);
ASSERT_RETURN(ret == -ELOOP);
ret = send_fd(conn_src, conn_dst->id, conn_dst->fd);
ASSERT_RETURN(ret == -ELOOP);
ret = pipe(fds);
ASSERT_RETURN(ret == 0);
i = write(fds[1], str, strlen(str));
ASSERT_RETURN(i == strlen(str));
ret = send_fd(conn_src, conn_dst->id, fds[0]);
ASSERT_RETURN(ret == 0);
ret = kdbus_msg_recv(conn_dst, &msg);
ASSERT_RETURN(ret == 0);
KDBUS_ITEM_FOREACH(item, msg, items) {
if (item->type == KDBUS_ITEM_FDS) {
char tmp[14];
int nfds = (item->size - KDBUS_ITEM_HEADER_SIZE) /
sizeof(int);
ASSERT_RETURN(nfds == 1);
i = read(item->fds[0], tmp, sizeof(tmp));
ASSERT_RETURN(i == sizeof(tmp));
ASSERT_RETURN(memcmp(tmp, str, sizeof(tmp)) == 0);
close(item->fds[0]);
break;
}
}
return TEST_OK;
}
示例6: PERF_COUNTER
bool KL2Map_Base::_InsertJointToBlock(const _Node_Lite * pNode)
{ PERF_COUNTER(KL2Map_Base__InsertJointToBlock);
ASSERT_RETURN(pNode, false);
int_r bx(-1), by(-1);
GetJointBlockPos(pNode->x, pNode->y, bx, by);
ASSERT_RETURN(bx >= 0, false);
ASSERT_RETURN(by >= 0, false);
return m_L2MapByBlock[bx][by].insert_unique(pNode) > -1;
}
示例7: unpriv_test_custom_ep
static int unpriv_test_custom_ep(const char *buspath)
{
int ret, ep_fd1, ep_fd2;
char *ep1, *ep2, *tmp1, *tmp2;
tmp1 = strdup(buspath);
tmp2 = strdup(buspath);
ASSERT_RETURN(tmp1 && tmp2);
ret = asprintf(&ep1, "%s/%u-%s", dirname(tmp1), getuid(), "apps1");
ASSERT_RETURN(ret >= 0);
ret = asprintf(&ep2, "%s/%u-%s", dirname(tmp2), getuid(), "apps2");
ASSERT_RETURN(ret >= 0);
free(tmp1);
free(tmp2);
/* endpoint only accessible to current uid */
ep_fd1 = create_endpoint(buspath, getuid(), "apps1", 0);
ASSERT_RETURN(ep_fd1 >= 0);
/* endpoint world accessible */
ep_fd2 = create_endpoint(buspath, getuid(), "apps2",
KDBUS_MAKE_ACCESS_WORLD);
ASSERT_RETURN(ep_fd2 >= 0);
ret = RUN_UNPRIVILEGED(UNPRIV_UID, UNPRIV_UID, ({
int ep_fd;
struct kdbus_conn *ep_conn;
/*
* Make sure that we are not able to create custom
* endpoints
*/
ep_fd = create_endpoint(buspath, getuid(),
"unpriv_costum_ep", 0);
ASSERT_EXIT(ep_fd == -EPERM);
/*
* Endpoint "apps1" only accessible to same users,
* that own the endpoint. Access denied by VFS
*/
ep_conn = kdbus_hello(ep1, 0, NULL, 0);
ASSERT_EXIT(!ep_conn && errno == EACCES);
/* Endpoint "apps2" world accessible */
ep_conn = kdbus_hello(ep2, 0, NULL, 0);
ASSERT_EXIT(ep_conn);
kdbus_conn_free(ep_conn);
_exit(EXIT_SUCCESS);
}),
示例8: kdbus_match_kdbus_pids
static int kdbus_match_kdbus_pids(struct kdbus_msg *msg,
const struct kdbus_pids *expected_pids)
{
struct kdbus_item *item;
item = kdbus_get_item(msg, KDBUS_ITEM_PIDS);
ASSERT_RETURN(item);
ASSERT_RETURN(memcmp(&item->pids, expected_pids,
sizeof(struct kdbus_pids)) == 0);
return 0;
}
示例9: switch
std::vector<std::wstring> NppInterface::GetOpenFilenames(ViewTarget viewTarget) const {
int enumVal = -1;
switch (viewTarget) {
case ViewTarget::primary:
enumVal = PRIMARY_VIEW;
break;
case ViewTarget::secondary:
enumVal = SECOND_VIEW;
break;
case ViewTarget::both:
enumVal = ALL_OPEN_FILES;
break;
}
ASSERT_RETURN(enumVal >= 0, {});
int count = SendMsgToNpp(NPPM_GETNBOPENFILES, 0, enumVal);
wchar_t** paths;
paths = new wchar_t *[count];
for (int i = 0; i < count; ++i)
paths[i] = new wchar_t[MAX_PATH];
int msg = -1;
switch (viewTarget) {
case ViewTarget::primary:
msg = NPPM_GETOPENFILENAMESPRIMARY;
break;
case ViewTarget::secondary:
msg = NPPM_GETOPENFILENAMESSECOND;
break;
case ViewTarget::both:
msg = NPPM_GETOPENFILENAMES;
break;
}
ASSERT_RETURN(msg >= 0, {}); {
auto ret = SendMsgToNpp(msg, reinterpret_cast<WPARAM>(paths), count);
ASSERT_RETURN(ret == count, {});
}
std::vector<std::wstring> res;
for (int i = 0; i < count; ++i) {
res.push_back(paths[i]);
delete[] paths[i];
}
delete[] paths;
return res;
}
示例10: FindBag
const KCreateInfo_ItemBase* KBagManager::GetOneItemCreateInfoBase( int nBagID, DWORD dwItemID )
{
const KBag* pBag = FindBag(nBagID);
ASSERT_RETURN(pBag, NULL);
int nPos = pBag->GetFirstPos(dwItemID);
ASSERT_RETURN(nPos >= 0, NULL);
const KCellBag* pCell = pBag->FindCell(nPos);
ASSERT_RETURN(pCell, NULL);
const KItem& item = pCell->GetItem();
ASSERT_I(item.GetID() == dwItemID);
return GetItemCreateInfo(dwItemID);
}
示例11: ASSERT_RETURN
bool KStoreProduct::AddProductPrice(int nMoneyType, int nTParam1, int nTParam2)
{
ASSERT_RETURN(nMoneyType > enumPT_none && nMoneyType < enumPT_count, false);
KStoreProductPrice price;
price.nMoneyType = nMoneyType;
price.nTParam1 = nTParam1;
price.nTParam2 = nTParam2;
int i = 0;
for(i=0;i<sizeof(m_Prices)/sizeof(m_Prices[0]);i++)
{
if(enumPT_none == m_Prices[i].nMoneyType) break;
if(m_Prices[i].nMoneyType == nMoneyType) return false;
}
if(i < PRICE_TYPE_MAX)
{
m_Prices[i].nMoneyType = nMoneyType;
m_Prices[i].nTParam1 = nTParam1;
m_Prices[i].nTParam2 = nTParam2;
return true;
}
return false;
}
示例12: ASSERT_RETURN
void CGraphicWindowChildFrame::moveForward()
{
ASSERT_RETURN( forwardTabCount() > 0 );
int newTab = m_forwardTabList[forwardTabCount()];
m_forwardTabList.remove(forwardTabCount());
SetTab( newTab );
}
示例13: FindCell
int KBagManager::GetCount(int nBagID, int nPos) const
{
const KCellBag* pCell = FindCell(nBagID, nPos);
ASSERT_RETURN(pCell, 0);
return pCell->GetItemStackNumber();
}
示例14: enlil_iptc_job_prepend
Enlil_IPTC_Job *
enlil_iptc_job_prepend(Enlil_Photo *photo,
Enlil_IPTC_Done_Cb cb,
void *data)
{
ASSERT_RETURN(photo != NULL);
Eina_List *l;
Enlil_IPTC_Job *job;
EINA_LIST_FOREACH(l_jobs, l, job)
if(job->photo == photo)
break;
if(!job)
{
job = calloc(1, sizeof(Enlil_IPTC_Job));
job->photo = photo;
job->cb = cb;
job->data = data;
}
else
l_jobs = eina_list_remove(l_jobs, job);
l_jobs = eina_list_prepend(l_jobs, job);
_job_next();
return job;
}
示例15: initPool
MemoryPool* initPool(size_t size, size_t increment)
{
MemoryPool *pool;
MemoryBlock *block;
void *buffer;
ASSERT_RETURN(size >= sizeof(MemoryPool)+sizeof(MemoryBlock), NULL);
buffer=malloc(size+sizeof(*pool)+sizeof(*block));
if (!buffer)
return NULL;
// Initialize first memory block
block = (MemoryBlock*) ((size_t)buffer+sizeof(*pool));
block->next = NULL;
block->start=(void*)((size_t)block+sizeof(*block));
block->pos=ALIGN_PTR(block->start, POOL_ALIGNMENT);
block->end=block->start+size;
// Initialize pool
pool = (MemoryPool*) buffer;
pool->lastAlloc = 0;
pool->capacity = size;
pool->increment = (increment) ? increment : (size_t)sysconf(_SC_PAGESIZE);
pool->base=block;
pool->cur=block;
PRINT("Pool created, used size=%ld, capacity=%ld, increment size=%ld", (((size_t)(pool->cur->start)) - (size_t)pool), pool->capacity, pool->increment);
return pool;
}