本文整理汇总了C++中MY_ASSERT函数的典型用法代码示例。如果您正苦于以下问题:C++ MY_ASSERT函数的具体用法?C++ MY_ASSERT怎么用?C++ MY_ASSERT使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了MY_ASSERT函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
//main
int main(int argc , char *argv[])
{
int fd_listen, fd_client;
MY_ASSERT((fd_listen = socket(AF_INET, SOCK_STREAM , 0)) != -1 ,"listen socket init");//socket
struct sockaddr_in seraddr, clientaddr;
socklen_t sock_len = sizeof(clientaddr);
memset(&seraddr, 0, sizeof(seraddr));
seraddr.sin_family = AF_INET;
seraddr.sin_port = htons(atoi(argv[2]) );
seraddr.sin_addr.s_addr = inet_addr(argv[1]);
MY_ASSERT(bind(fd_listen, (struct sockaddr*)&seraddr, sizeof(seraddr))==0, "bind");//bind
MY_ASSERT(listen(fd_listen, 5) == 0, "listen");//listen
while(1)
{
sock_len =sizeof(clientaddr);
memset(&clientaddr, 0, sock_len);
fd_client = accept(fd_listen ,(struct sockaddr*)&clientaddr, &sock_len );
printf("client %s:%d connect!\n", inet_ntoa(clientaddr.sin_addr), ntohs(clientaddr.sin_port));
if(fork() == 0)
{
close(fd_listen);
child_main(fd_client);
close(fd_client);
exit(1);
}
close(fd_client);
}
}
示例2: MY_ASSERT
bool BuffManager::BuildStub(BuffModify *e)
{
if (!e)
return false;
MY_ASSERT(1 != e->m_WillActTimes);
m_buffList[e->m_ID] = e;
e->m_curStep = 0;
if (0 != e->m_WillActTimes)
EventManager::GetInstance().Register(e, e->m_Margin);
// 主动触发第一个事件
//if (e->m_WillActTimes>2)
{
e->OnTimer(0);
}
e->SendNotify(true);
// 建立Buff组映射
BuffGroup::iterator it = m_buffGroup.find(e->m_GroupID);
MY_ASSERT(it == m_buffGroup.end());
m_buffGroup.insert(make_pair(e->m_GroupID, e->m_ID));
// 加入交叉索引
e->m_pusher->m_buffMgr.m_buffToOther.insert(e);
return TRUE;
}
示例3: range_test
void range_test()
{
vector<point_t> points;
vector<range_t> ranges;
for (size_t i = 0; i < 1000; ++i)
{
const coord_t x = rand();
const coord_t y = rand();
points.push_back(point_t(x, y));
points.push_back(point_t(x, rand()));
}
for (size_t i = 0; i < 1000; ++i)
{
coord_t inf = rand();
coord_t sup = rand();
if (sup < inf)
std::swap(inf, sup);
ranges.push_back(range_t(inf, sup));
}
/*
for (size_t i = 0; i < 10; ++i)
points.push_back(point_t(i, 5));
*/
const range_tree_t range_tree(points);
// auto ind = range_tree.query(range_t(2, 8), range_t(4, 9));
vector<bool> returned;
for (size_t i = 0; i < ranges.size() / 2; ++i)
{
returned.resize(range_tree.points().size(), false);
range_t x_range = ranges.at(i * 2 + 0);
range_t y_range = ranges.at(i * 2 + 1);
const auto indices = range_tree.query(x_range, y_range);
BOOST_FOREACH(const auto index, indices)
{
returned.at(index) = true;
const point_t point = range_tree.points().at(index);
MY_ASSERT(point.x >= x_range.inf && point.x < x_range.sup && point.y >= y_range.inf && point.y < y_range.sup);
}
for (size_t index = 0; index < range_tree.points().size(); ++index)
{
const point_t point = range_tree.points().at(index);
if (!returned.at(index))
MY_ASSERT(point.x < x_range.inf || point.x >= x_range.sup || point.y < y_range.inf || point.y >= y_range.sup);
}
}
示例4: Test1
static void Test1()
{
printf("Test1...\n");
emThread::StartUnmanaged(ThreadFunc1,(void*)"hello 1");
MY_ASSERT(!Event1.Receive(1,1000));
MY_ASSERT(Event1.Receive(1,1000));
}
示例5: SAFE_RELEASE
//------------------------------------------------------------------------------------------
bool CGraphicDevice::Reset(int i_nWidth, int i_nHeight )
{
HRESULT hr;
// サーフェースの破棄
SAFE_RELEASE( m_pd3dSurface9 );
// デバイスのリセット
// Presentation Parameter の初期化
m_d3dpp.BackBufferWidth = i_nWidth;
m_d3dpp.BackBufferHeight = i_nHeight;
hr = m_pd3dDevice9->Reset( &m_d3dpp );
MY_ASSERT( SUCCEEDED(hr) );
// サーフェースを新しいサイズで再作成
bool ret = CreateRenderTarget( i_nWidth, i_nHeight );
MY_ASSERT( ret );
m_nWidth = i_nWidth;
m_nHeight = i_nHeight;
// ビューポートの設定
m_viewport.X = 0;
m_viewport.Y = 0;
m_viewport.Width = i_nWidth;
m_viewport.Height = i_nHeight;
m_viewport.MinZ = 0.0f;
m_viewport.MaxZ = 1.0f;
return ret;
}
示例6: read_public_key
void read_public_key(drown_ctx * dctx, char *filename)
{
// Read file
FILE * fp = fopen(filename, "r");
MY_ASSERT(fp != NULL, "can't open certificate file");
// Read cert
X509 *cert = PEM_read_X509(fp, NULL, NULL, NULL);
MY_ASSERT(cert != NULL, "file is not a certificate");
// Read public key
EVP_PKEY * pkey = X509_get_pubkey(cert);
MY_ASSERT(pkey != NULL, "can't get public key from certificate");
// Check RSA key
MY_ASSERT(pkey->type == EVP_PKEY_RSA, "public key is not RSA");
MY_ASSERT(EVP_PKEY_bits(pkey) == 2048, "only RSA-2048 is supported for now");
// Read RSA key
RSA *rsa = EVP_PKEY_get1_RSA(pkey);
// Copy the public key
BN_copy(dctx->n, rsa->n);
BN_copy(dctx->e, rsa->e);
RSA_free(rsa);
EVP_PKEY_free(pkey);
X509_free(cert);
fclose(fp);
}
示例7: MY_ASSERT
void CExchangeGoods::ExchgLoseStatus()
{
CPlayer *pPlayer = static_cast<CPlayer *>(this);
if (!pPlayer)
return;
// 首先看看是否在等待交易回应
if (pPlayer->m_ChxSentOut.size())
{
for (CPlayer::CHXQuestList::iterator it = pPlayer->m_ChxSentOut.begin(); it != pPlayer->m_ChxSentOut.end(); ++it)
{
CPlayer *pDestPlayer = (CPlayer *)GetPlayerByGID(it->first)->DynamicCast(IID_PLAYER);
if (!pDestPlayer)
continue;
MY_ASSERT(pDestPlayer->m_CurHp);
pDestPlayer->m_ChxGetIn.erase(pPlayer->GetGID());
}
pPlayer->m_ChxSentOut.clear();
}
// 是否在等待响应交易请求
if (pPlayer->m_ChxGetIn.size())
{
CPlayer::CHXQuestList tempCopy(pPlayer->m_ChxGetIn);
for (CPlayer::CHXQuestList::iterator it = tempCopy.begin(); it != tempCopy.end(); ++it)
{
CPlayer *pQuest = (CPlayer *)GetPlayerByGID(it->first)->DynamicCast(IID_PLAYER);
if (pQuest)
{
MY_ASSERT(pQuest->m_CurHp);
// 超时,拒绝
SQQuestExchangeMsg rejectMsg;
rejectMsg.bAccept = false;
rejectMsg.dnidClient = 0;
rejectMsg.dwDestGID = pPlayer->GetGID();
rejectMsg.dwSrcGID = it->first;
RecvQuestExchangeMsg(&rejectMsg, true);
}
else
{
MY_ASSERT(0);
pPlayer->m_ChxGetIn.erase(it->first);
}
}
MY_ASSERT(pPlayer->m_ChxGetIn.empty());
}
// 是否处于交易中
if (pPlayer->InExchange())
{
CExchangeGoods::TheEnd();
}
}
示例8: ThreadFunc1
static int ThreadFunc1(void * arg)
{
MY_ASSERT(strcmp((char*)arg,"hello 1")==0);
emSleepMS(1500);
MY_ASSERT(Event1.GetCount()==-1);
Event1.Send();
return 0;
}
示例9: rfalse
bool BuffManager::CanAddBuff(const SBuffBaseData *pData, CFightObject *pSender)
{
if (!pData)
{
rfalse(4,1,"BuffManager::CanAddBuff(const SBuffBaseData *pData)1");
return false;
}
if (m_curObj&&pSender)
{
if (m_curObj->GetGID() != pSender->GetGID()) //给目标添加BUFF
{
if (!m_curObj->m_bPlayerAction[CST_ADDBUFF])
{
rfalse(2, 1, "目标当前无法添加BUFF");
return false;
}
}
}
BuffGroup::iterator groupIt = m_buffGroup.find(pData->m_GroupID);
if (groupIt == m_buffGroup.end())
{
//rfalse(2, 1, "玩家身上没有Buff组%d中的Buff", pData->m_GroupID);
//MY_ASSERT(m_buffList.end() == m_buffList.find(pData->m_ID));
return true;
}
BuffList::iterator buffIt = m_buffList.find(groupIt->second);
if (buffIt == m_buffList.end())
{
rfalse(4,1,"BuffManager::CanAddBuff(const SBuffBaseData *pData)2");
return false;
}
MY_ASSERT(m_buffList.end() != buffIt);
//TODO:Tony Modify [2012-3-11]Comment:[IF语句后面有;]
//if (pData->m_GroupID != buffIt->second->m_GroupID);
///////////////////////////////////////////////////////////////////
if (pData->m_GroupID != buffIt->second->m_GroupID)
{
rfalse(4,1,"BuffManager::CanAddBuff(const SBuffBaseData *pData)3");
return false;
}
MY_ASSERT(pData->m_GroupID == buffIt->second->m_GroupID);
if (!buffIt->second->m_CanBeReplaced)
return false;
// 如果可被替换,那么查看权重
if (buffIt->second->m_Weight > pData->m_Weight)
return false;
// 顶替
RemoveBuff(buffIt->second);
return true;
}
示例10: rfalse
void CExchangeGoods::ExchangeCancel(CPlayer *pDestPlayer, bool isSrc)
{
if (!pDestPlayer)
return;
CPlayer *pSrcPlayer = static_cast<CPlayer *>(this);
if (!pSrcPlayer)
return;
// 交易取消,需要恢复被锁定的道具和金钱
for (int i=0; i<m_MyBox.m_SellNumber; i++)
{
SPackageItem &item = m_MyBox.m_GoodsArray[i];
SPackageItem *pItem = pSrcPlayer->FindItemByPos(item.wCellPos, XYD_FT_ONLYLOCK);
if (!pItem)
{
rfalse(4, 1, "ExchangeGoods.cpp - ExchangeCancel() - !pItem");
return;
}
MY_ASSERT(pItem);
pSrcPlayer->LockItemCell(pItem->wCellPos, false);
}
for (int i=0; i<m_YouBox.m_SellNumber; i++)
{
SPackageItem &item = m_YouBox.m_GoodsArray[i];
SPackageItem *pItem = pDestPlayer->FindItemByPos(item.wCellPos, XYD_FT_ONLYLOCK);
if (!pItem)
{
rfalse(4, 1, "ExchangeGoods.cpp - ExchangeCancel() - !pItem");
return;
}
MY_ASSERT(pItem);
pDestPlayer->LockItemCell(pItem->wCellPos, false);
}
// 清除当前的交易状态(包括了金钱的锁定)
memset((CExchangeGoods *)pSrcPlayer, 0, sizeof(CExchangeGoods));
memset((CExchangeGoods *)pDestPlayer, 0, sizeof(CExchangeGoods));
// 通知客户端交易被取消
SAExchangeOperationMsg opmsg;
opmsg.dwSrcGID = pSrcPlayer->GetGID();
opmsg.dwDestGID = pDestPlayer->GetGID();
opmsg.isSrc = isSrc;
opmsg.operation = SAExchangeOperationMsg::CANCEL;
g_StoreMessage(pSrcPlayer->m_ClientIndex, &opmsg, sizeof(SAExchangeOperationMsg));
g_StoreMessage(pDestPlayer->m_ClientIndex, &opmsg, sizeof(SAExchangeOperationMsg));
return;
}
示例11: JAWT_GetAWT
/*****************************************************************************
*
* Class : NativeView
* Method : getNativeWindow
* Signature : ()J
* Description: returns the native systemw window handle of this object
*/
JNIEXPORT jlong JNICALL Java_NativeView_getNativeWindow
(JNIEnv * env, jobject obj_this)
{
jboolean result ;
jint lock ;
JAWT awt ;
JAWT_DrawingSurface* ds ;
JAWT_DrawingSurfaceInfo* dsi ;
JAWT_Win32DrawingSurfaceInfo* dsi_win ;
HDC hdc ;
HWND hWnd ;
LONG hFuncPtr;
/* Get the AWT */
awt.version = JAWT_VERSION_1_3;
result = JAWT_GetAWT(env, &awt);
MY_ASSERT(result!=JNI_FALSE,"wrong jawt version");
/* Get the drawing surface */
if ((ds = awt.GetDrawingSurface(env, obj_this)) == NULL)
return 0L;
/* Lock the drawing surface */
lock = ds->Lock(ds);
MY_ASSERT((lock & JAWT_LOCK_ERROR)==0,"can't lock the drawing surface");
/* Get the drawing surface info */
dsi = ds->GetDrawingSurfaceInfo(ds);
/* Get the platform-specific drawing info */
dsi_win = (JAWT_Win32DrawingSurfaceInfo*)dsi->platformInfo;
hdc = dsi_win->hdc;
hWnd = dsi_win->hwnd;
/* Free the drawing surface info */
ds->FreeDrawingSurfaceInfo(dsi);
/* Unlock the drawing surface */
ds->Unlock(ds);
/* Free the drawing surface */
awt.FreeDrawingSurface(ds);
/* Register own window procedure
Do it one times only! Otherwhise
multiple instances will be registered
and calls on such construct produce
a stack overflow.
*/
if (GetProp( hWnd, OLD_PROC_KEY )==0)
{
hFuncPtr = SetWindowLong( hWnd, GWL_WNDPROC, (DWORD)NativeViewWndProc );
SetProp( hWnd, OLD_PROC_KEY, (HANDLE)hFuncPtr );
}
return ((jlong)hWnd);
}
示例12: Test6
static void Test6()
{
printf("Test6...\n");
emThreadMutex c[5];
DiningPhilosopher * p[5];
char str[256],str2[256];
emUInt64 clk;
int i;
for (i=0; i<5; i++) p[i]=new DiningPhilosopher(c[i],c[(i+1)%5]);
clk=emGetClockMS();
str2[0]=0;
while (emGetClockMS()-clk<3000) {
PrintEvent.Receive();
strcpy(str,
" ? \n"
" - - \n"
"? ?\n"
" - - \n"
" ? - ? \n"
);
PrintDataMutex.Lock();
MY_ASSERT(!p[0]->IsEating() || !p[1]->IsEating());
MY_ASSERT(!p[1]->IsEating() || !p[2]->IsEating());
MY_ASSERT(!p[2]->IsEating() || !p[3]->IsEating());
MY_ASSERT(!p[3]->IsEating() || !p[4]->IsEating());
MY_ASSERT(!p[4]->IsEating() || !p[0]->IsEating());
if (p[0]->IsThinking()) str[04]='T';
if (p[1]->IsThinking()) str[28]='T';
if (p[2]->IsThinking()) str[47]='T';
if (p[3]->IsThinking()) str[41]='T';
if (p[4]->IsThinking()) str[20]='T';
if (p[0]->IsEating()) str[04]='E';
if (p[1]->IsEating()) str[28]='E';
if (p[2]->IsEating()) str[47]='E';
if (p[3]->IsEating()) str[41]='E';
if (p[4]->IsEating()) str[20]='E';
if (c[0].IsLocked()) str[12]=' ';
if (c[1].IsLocked()) str[16]=' ';
if (c[2].IsLocked()) str[37]=' ';
if (c[3].IsLocked()) str[44]=' ';
if (c[4].IsLocked()) str[31]=' ';
PrintDataMutex.Unlock();
if (strcmp(str,str2)!=0) {
strcpy(str2,str);
printf("\n\n%s",str);
}
}
for (i=0; i<5; i++) delete p[i];
}
示例13: JAWT_GetAWT
/*****************************************************************************
*
* Class : NativeView
* Method : getNativeWindow
* Signature : ()J
* Description: returns the native systemw window handle of this object
*/
JNIEXPORT jlong JNICALL Java_embeddedobj_test_NativeView_getNativeWindow
(JNIEnv * env, jobject obj_this)
{
jboolean result ;
jint lock ;
JAWT awt ;
JAWT_DrawingSurface* ds ;
JAWT_DrawingSurfaceInfo* dsi ;
#ifdef WNT
JAWT_Win32DrawingSurfaceInfo* dsi_win ;
#else
// FIXME: Where is dsi_x11 defined?
// Added below because I'm guessing this test breaks
// JAWT_X11DrawingSurfaceInfo*dsi_x11 ;
#endif
jlong drawable;
/* Get the AWT */
awt.version = JAWT_VERSION_1_3;
result = JAWT_GetAWT(env, &awt);
MY_ASSERT(result!=JNI_FALSE,"wrong jawt version");
/* Get the drawing surface */
if ((ds = awt.GetDrawingSurface(env, obj_this)) == NULL)
return 0L;
/* Lock the drawing surface */
lock = ds->Lock(ds);
MY_ASSERT((lock & JAWT_LOCK_ERROR)==0,"can't lock the drawing surface");
/* Get the drawing surface info */
dsi = ds->GetDrawingSurfaceInfo(ds);
/* Get the platform-specific drawing info */
#ifdef WNT
dsi_win = (JAWT_Win32DrawingSurfaceInfo*)dsi->platformInfo;
drawable = (jlong)dsi_win->hwnd;
#else
dsi_x11 = (JAWT_X11DrawingSurfaceInfo*)dsi->platformInfo;
drawable = (jlong)dsi_x11->drawable;
#endif
/* Free the drawing surface info */
ds->FreeDrawingSurfaceInfo(dsi);
/* Unlock the drawing surface */
ds->Unlock(ds);
/* Free the drawing surface */
awt.FreeDrawingSurface(ds);
return drawable;
}
示例14: Test4
static void Test4()
{
printf("Test4...\n");
emThread t;
Int4=0;
Mutex4a.Lock();
t.Start(ThreadFunc4,NULL);
emSleepMS(100);
MY_ASSERT(Int4++==0);
Mutex4a.Unlock();
emSleepMS(100);
Mutex4a.Lock();
MY_ASSERT(Int4++==3);
emSleepMS(100);
MY_ASSERT(Int4++==4);
Mutex4a.Unlock();
Mutex4b.Lock();
MY_ASSERT(Int4++==7);
emSleepMS(500);
MY_ASSERT(Int4++==8);
Mutex4b.Unlock();
emSleepMS(100);
Mutex4c.Lock();
MY_ASSERT(Int4++==11);
MY_ASSERT(Mutex4b.Lock(0));
MY_ASSERT(t.WaitForTermination(1000)==true);
}
示例15: ThreadFunc4
static int ThreadFunc4(void * arg)
{
Mutex4a.Lock();
MY_ASSERT(Int4++==1);
emSleepMS(200);
MY_ASSERT(Int4++==2);
Mutex4b.Lock();
Mutex4a.Unlock();
emSleepMS(100);
Mutex4a.Lock();
Mutex4a.Unlock();
MY_ASSERT(Int4++==5);
emSleepMS(100);
MY_ASSERT(Int4++==6);
Mutex4b.Unlock();
emSleepMS(100);
MY_ASSERT(!Mutex4b.LockReadOnly(100));
MY_ASSERT(Mutex4b.LockReadOnly(1000));
Mutex4c.Lock();
Mutex4b.UnlockReadOnly();
MY_ASSERT(Int4++==9);
emSleepMS(200);
MY_ASSERT(Int4++==10);
Mutex4c.Unlock();
return 0;
}