C++ (Cpp) ASSERT Examples

C++ (Cpp) ASSERT - 30 examples found. These are the top rated real world C++ (Cpp) examples of ASSERT extracted from open source projects. You can rate examples to help us improve the quality of examples.
Example #1
0
const FramebufferAttachment *FramebufferState::getReadAttachment() const
{
    ASSERT(mReadBufferState == GL_BACK || (mReadBufferState >= GL_COLOR_ATTACHMENT0 && mReadBufferState <= GL_COLOR_ATTACHMENT15));
    size_t readIndex = (mReadBufferState == GL_BACK ? 0 : static_cast<size_t>(mReadBufferState - GL_COLOR_ATTACHMENT0));
    ASSERT(readIndex < mColorAttachments.size());
    return mColorAttachments[readIndex].isAttached() ? &mColorAttachments[readIndex] : nullptr;
}
Example #2
0
Item* Item::CreateItem(uint32 item, uint32 count, Player const* player)
{
    if (count < 1)
        return NULL;                                        //don't create item at zero count

    ItemPrototype const *pProto = ObjectMgr::GetItemPrototype(item);
    if (pProto)
    {
        if (count > pProto->GetMaxStackSize())
            count = pProto->GetMaxStackSize();

        ASSERT(count !=0 && "pProto->Stackable == 0 but checked at loading already");

        Item *pItem = NewItemOrBag(pProto);
        if (pItem->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_ITEM), item, player))
        {
            /** World of Warcraft Armory **/
            if (pProto->Quality > 2 && pProto->Flags != 2048 && (pProto->Class == ITEM_CLASS_WEAPON || pProto->Class == ITEM_CLASS_ARMOR) && player)
            {
                std::ostringstream ss;
                sLog->outDetail("WoWArmory: write feed log (guid: %u, type: 2, data: %u)", player->GetGUIDLow(), item);
                ss << "REPLACE INTO character_feed_log (guid, type, data, date, counter, item_guid) VALUES (" << player->GetGUIDLow() << ", 2, " << item << ", UNIX_TIMESTAMP(NOW()), 1," << pItem->GetGUIDLow()  << ")";
                CharacterDatabase.PExecute( ss.str().c_str() );
            }
            /** World of Warcraft Armory **/
            pItem->SetCount(count);
            return pItem;
        }
        else
            delete pItem;
    }
    else
        ASSERT(false);
    return NULL;
}
Example #3
0
void FormatDateTime(TCHAR * pszTemp, LPCTSTR pszFormat, const struct tm * ptmTemp)
{
    ASSERT(pszTemp != NULL);
    ASSERT(pszFormat != NULL);
    ASSERT(ptmTemp != NULL);

#ifdef _WIN32
    // on windows we need to set the invalid parameter handler, or else the program will terminate when a bad format is encountered
    _invalid_parameter_handler oldHandler, newHandler;
    newHandler = static_cast<_invalid_parameter_handler>(invalidParameterHandler);
#ifndef __MINGW32__
    oldHandler = _set_invalid_parameter_handler(newHandler);
#endif  // __MINGW32__
    try
    {
#endif

        if (strftime( pszTemp, maxTimeBufferSize, pszFormat, ptmTemp) == 0)
            pszTemp[0] = '\0';

#ifdef _WIN32
    }
    catch (...)
    {
        // since VS2010, it seems an exception gets thrown for invalid format strings too
        pszTemp[0] = '\0';
    }

    // restore previous parameter handler

#ifndef __MINGW32__
    _set_invalid_parameter_handler(oldHandler);
#endif  // __MINGW32__
#endif
}
void AnimationTimeline::serviceAnimations(TimingUpdateReason reason)
{
    TRACE_EVENT0("blink", "AnimationTimeline::serviceAnimations");

    m_lastCurrentTimeInternal = currentTimeInternal();

    HeapVector<Member<Animation>> animations;
    animations.reserveInitialCapacity(m_animationsNeedingUpdate.size());
    for (Animation* animation : m_animationsNeedingUpdate)
        animations.append(animation);

    std::sort(animations.begin(), animations.end(), Animation::hasLowerPriority);

    for (Animation* animation : animations) {
        if (!animation->update(reason))
            m_animationsNeedingUpdate.remove(animation);
    }

    ASSERT(m_outdatedAnimationCount == 0);
    ASSERT(m_lastCurrentTimeInternal == currentTimeInternal() || (std::isnan(currentTimeInternal()) && std::isnan(m_lastCurrentTimeInternal)));

#if ENABLE(ASSERT)
    for (const auto& animation : m_animationsNeedingUpdate)
        ASSERT(!animation->outdated());
#endif
}
Example #5
0
void XMLHttpRequest::handleAsynchronousPreflightResult()
{
    ASSERT(m_inPreflight);
    ASSERT(m_async);

    m_inPreflight = false;

    KURL url = m_url;
    url.setUser(String());
    url.setPass(String());

    ResourceRequest request(url);
    request.setHTTPMethod(m_method);
    request.setAllowHTTPCookies(m_includeCredentials);
    request.setHTTPOrigin(scriptExecutionContext()->securityOrigin()->toString());

    if (m_requestHeaders.size() > 0)
        request.addHTTPHeaderFields(m_requestHeaders);

    if (m_requestEntityBody) {
        ASSERT(m_method != "GET");
        request.setHTTPBody(m_requestEntityBody.release());
    }

    loadRequestAsynchronously(request);
}
//**********************************************************************************
BOOL CBCGPSkinManager::SaveState (LPCTSTR lpszProfileName)
{
    CString strProfileName = ::BCGPGetRegPath (strSkinProfile, lpszProfileName);

    BOOL bResult = FALSE;

    CString strLibraryPath;
    CString strSkinName;
    int iSkin = BCG_DEFUALT_SKIN;

    if (m_iActiveSkin != BCG_DEFUALT_SKIN)
    {
        ASSERT (m_iActiveSkin >= 0);
        ASSERT (m_iActiveSkin < m_Skins.GetSize ());

        strLibraryPath = m_Skins[m_iActiveSkin].m_strLibraryPath;
        strSkinName = m_Skins[m_iActiveSkin].m_strSkinName;
        iSkin = m_Skins[m_iActiveSkin].m_iSkinIndexInLibrary;
    }

    CBCGPRegistrySP regSP;
    CBCGPRegistry& reg = regSP.Create (FALSE, FALSE);

    if (reg.CreateKey (strProfileName + strRegEntryName))
    {
        bResult =	reg.Write (REG_ENTRY_LIBRARY_NAME, strLibraryPath) &&
                    reg.Write (REG_ENTRY_SKIN_NAME, strSkinName) &&
                    reg.Write (REG_ENTRY_SKIN_INDEX, iSkin);
    }

    return bResult;
}