From 91dfb07a8c7e299e336e5486a8b3f6110cdd44b0 Mon Sep 17 00:00:00 2001 From: andyque Date: Tue, 14 Jul 2015 15:28:36 +0800 Subject: [PATCH] add more descriptive message to ASSET macro. --- cocos/2d/CCActionEase.cpp | 2 +- cocos/2d/CCActionGrid.cpp | 6 +- cocos/2d/CCActionInterval.cpp | 18 +- cocos/2d/CCActionManager.cpp | 18 +- cocos/2d/CCCamera.cpp | 4 +- cocos/2d/CCGrid.cpp | 6 +- cocos/2d/CCMenu.cpp | 12 +- cocos/2d/CCParticleSystem.cpp | 2 +- cocos/2d/CCSprite.cpp | 7 +- cocos/2d/CCTMXXMLParser.cpp | 2 +- cocos/base/CCEventDispatcher.cpp | 3 +- cocos/base/CCEventListenerAcceleration.cpp | 2 +- cocos/base/CCScheduler.cpp | 12 +- cocos/base/ZipUtils.cpp | 4 +- .../editor-support/cocosbuilder/CCBReader.cpp | 2 +- .../cocosbuilder/CCNodeLoader.cpp | 6 +- .../editor-support/cocostudio/CCArmature.cpp | 2 +- .../editor-support/cocostudio/TriggerObj.cpp | 6 +- cocos/renderer/CCGLProgramState.cpp | 2 +- cocos/renderer/CCTexture2D.cpp | 2 +- cocos/renderer/CCTextureAtlas.cpp | 2 +- .../js-bindings/manual/cocos2d_specifics.cpp | 7 +- cocos/ui/UIWidget.cpp | 2 +- .../UISliderTest/UISliderTest.cpp | 1 + tests/cpp-tests/Classes/UnitTest/UnitTest.cpp | 242 +++++++++--------- 25 files changed, 189 insertions(+), 183 deletions(-) diff --git a/cocos/2d/CCActionEase.cpp b/cocos/2d/CCActionEase.cpp index 46335fd0aa..fff07e2c2b 100644 --- a/cocos/2d/CCActionEase.cpp +++ b/cocos/2d/CCActionEase.cpp @@ -46,7 +46,7 @@ NS_CC_BEGIN bool ActionEase::initWithAction(ActionInterval *action) { - CCASSERT(action != nullptr, ""); + CCASSERT(action != nullptr, "action couldn't be nullptr!"); if (ActionInterval::initWithDuration(action->getDuration())) { diff --git a/cocos/2d/CCActionGrid.cpp b/cocos/2d/CCActionGrid.cpp index 0c42ef8cfb..d00e8b50e9 100644 --- a/cocos/2d/CCActionGrid.cpp +++ b/cocos/2d/CCActionGrid.cpp @@ -57,13 +57,13 @@ void GridAction::startWithTarget(Node *target) if (targetGrid && targetGrid->getReuseGrid() > 0) { if (targetGrid->isActive() && targetGrid->getGridSize().width == _gridSize.width - && targetGrid->getGridSize().height == _gridSize.height /*&& dynamic_cast(targetGrid) != nullptr*/) + && targetGrid->getGridSize().height == _gridSize.height) { targetGrid->reuse(); } else { - CCASSERT(0, ""); + CCASSERT(0, "Invalid grid parameters!"); } } else @@ -93,7 +93,7 @@ GridAction* GridAction::reverse() const GridBase* GridAction::getGrid() { // Abstract class needs implementation - CCASSERT(0, ""); + CCASSERT(0, "Subclass should implement this method!"); return nullptr; } diff --git a/cocos/2d/CCActionInterval.cpp b/cocos/2d/CCActionInterval.cpp index 2ac44d820b..9c9eec5bc8 100644 --- a/cocos/2d/CCActionInterval.cpp +++ b/cocos/2d/CCActionInterval.cpp @@ -134,13 +134,13 @@ void ActionInterval::setAmplitudeRate(float amp) { CC_UNUSED_PARAM(amp); // Abstract class needs implementation - CCASSERT(0, ""); + CCASSERT(0, "Subclass should implement this method!"); } float ActionInterval::getAmplitudeRate() { // Abstract class needs implementation - CCASSERT(0, ""); + CCASSERT(0, "Subclass should implement this method!"); return 0; } @@ -248,8 +248,8 @@ Sequence* Sequence::create(const Vector& arrayOfActions) bool Sequence::initWithTwoActions(FiniteTimeAction *actionOne, FiniteTimeAction *actionTwo) { - CCASSERT(actionOne != nullptr, ""); - CCASSERT(actionTwo != nullptr, ""); + CCASSERT(actionOne != nullptr, "actionOne can't be nullptr!"); + CCASSERT(actionTwo != nullptr, "actionTwo can't be nullptr!"); float d = actionOne->getDuration() + actionTwo->getDuration(); ActionInterval::initWithDuration(d); @@ -504,7 +504,7 @@ RepeatForever *RepeatForever::create(ActionInterval *action) bool RepeatForever::initWithAction(ActionInterval *action) { - CCASSERT(action != nullptr, ""); + CCASSERT(action != nullptr, "action can't be nullptr!"); action->retain(); _innerAction = action; return true; @@ -645,8 +645,8 @@ Spawn* Spawn::createWithTwoActions(FiniteTimeAction *action1, FiniteTimeAction * bool Spawn::initWithTwoActions(FiniteTimeAction *action1, FiniteTimeAction *action2) { - CCASSERT(action1 != nullptr, ""); - CCASSERT(action2 != nullptr, ""); + CCASSERT(action1 != nullptr, "action1 can't be nullptr!"); + CCASSERT(action2 != nullptr, "action2 can't be nullptr!"); bool ret = false; @@ -2189,8 +2189,8 @@ ReverseTime* ReverseTime::create(FiniteTimeAction *action) bool ReverseTime::initWithAction(FiniteTimeAction *action) { - CCASSERT(action != nullptr, ""); - CCASSERT(action != _other, ""); + CCASSERT(action != nullptr, "action can't be nullptr!"); + CCASSERT(action != _other, "action doesn't equal to _other!"); if (ActionInterval::initWithDuration(action->getDuration())) { diff --git a/cocos/2d/CCActionManager.cpp b/cocos/2d/CCActionManager.cpp index df7f082e99..3fc938cc29 100644 --- a/cocos/2d/CCActionManager.cpp +++ b/cocos/2d/CCActionManager.cpp @@ -168,8 +168,8 @@ void ActionManager::resumeTargets(const Vector& targetsToResume) void ActionManager::addAction(Action *action, Node *target, bool paused) { - CCASSERT(action != nullptr, ""); - CCASSERT(target != nullptr, ""); + CCASSERT(action != nullptr, "action can't be nullptr!"); + CCASSERT(target != nullptr, "target can't be nullptr!"); tHashElement *element = nullptr; // we should convert it to Ref*, because we save it as Ref* @@ -186,7 +186,7 @@ void ActionManager::addAction(Action *action, Node *target, bool paused) actionAllocWithHashElement(element); - CCASSERT(! ccArrayContainsObject(element->actions, action), ""); + CCASSERT(! ccArrayContainsObject(element->actions, action), "action already be added!"); ccArrayAppendObject(element->actions, action); action->startWithTarget(target); @@ -265,8 +265,8 @@ void ActionManager::removeAction(Action *action) void ActionManager::removeActionByTag(int tag, Node *target) { - CCASSERT(tag != Action::INVALID_TAG, ""); - CCASSERT(target != nullptr, ""); + CCASSERT(tag != Action::INVALID_TAG, "Invalid tag value!"); + CCASSERT(target != nullptr, "target can't be nullptr!"); tHashElement *element = nullptr; HASH_FIND_PTR(_targets, &target, element); @@ -289,8 +289,8 @@ void ActionManager::removeActionByTag(int tag, Node *target) void ActionManager::removeAllActionsByTag(int tag, Node *target) { - CCASSERT(tag != Action::INVALID_TAG, ""); - CCASSERT(target != nullptr, ""); + CCASSERT(tag != Action::INVALID_TAG, "Invalid tag value!"); + CCASSERT(target != nullptr, "target can't be nullptr!"); tHashElement *element = nullptr; HASH_FIND_PTR(_targets, &target, element); @@ -321,7 +321,7 @@ void ActionManager::removeActionsByFlags(unsigned int flags, Node *target) { return; } - CCASSERT(target != nullptr, ""); + CCASSERT(target != nullptr, "target can't be nullptr!"); tHashElement *element = nullptr; HASH_FIND_PTR(_targets, &target, element); @@ -352,7 +352,7 @@ void ActionManager::removeActionsByFlags(unsigned int flags, Node *target) // and, it is not possible to get the address of a reference Action* ActionManager::getActionByTag(int tag, const Node *target) const { - CCASSERT(tag != Action::INVALID_TAG, ""); + CCASSERT(tag != Action::INVALID_TAG, "Invalid tag value!"); tHashElement *element = nullptr; HASH_FIND_PTR(_targets, &target, element); diff --git a/cocos/2d/CCCamera.cpp b/cocos/2d/CCCamera.cpp index 880d3ee3d7..c62171c54c 100644 --- a/cocos/2d/CCCamera.cpp +++ b/cocos/2d/CCCamera.cpp @@ -238,7 +238,7 @@ Vec2 Camera::project(const Vec3& src) const Vec4 clipPos; getViewProjectionMatrix().transformVector(Vec4(src.x, src.y, src.z, 1.0f), &clipPos); - CCASSERT(clipPos.w != 0.0f, ""); + CCASSERT(clipPos.w != 0.0f, "clipPos.w can't be 0.0f!"); float ndcX = clipPos.x / clipPos.w; float ndcY = clipPos.y / clipPos.w; @@ -255,7 +255,7 @@ Vec2 Camera::projectGL(const Vec3& src) const Vec4 clipPos; getViewProjectionMatrix().transformVector(Vec4(src.x, src.y, src.z, 1.0f), &clipPos); - CCASSERT(clipPos.w != 0.0f, ""); + CCASSERT(clipPos.w != 0.0f, "clipPos.w can't be 0.0f!"); float ndcX = clipPos.x / clipPos.w; float ndcY = clipPos.y / clipPos.w; diff --git a/cocos/2d/CCGrid.cpp b/cocos/2d/CCGrid.cpp index 9ccbd06b90..5426ad3bd1 100644 --- a/cocos/2d/CCGrid.cpp +++ b/cocos/2d/CCGrid.cpp @@ -245,17 +245,17 @@ void GridBase::afterDraw(cocos2d::Node *target) void GridBase::blit(void) { - CCASSERT(0, ""); + CCASSERT(0, "Subclass should implement it."); } void GridBase::reuse(void) { - CCASSERT(0, ""); + CCASSERT(0, "Subclass should implement it!"); } void GridBase::calculateVertexPoints(void) { - CCASSERT(0, ""); + CCASSERT(0, "Subclass should implement it."); } // implementation of Grid3D diff --git a/cocos/2d/CCMenu.cpp b/cocos/2d/CCMenu.cpp index 2b8ceea7d5..2a17e75578 100644 --- a/cocos/2d/CCMenu.cpp +++ b/cocos/2d/CCMenu.cpp @@ -376,11 +376,11 @@ void Menu::alignItemsInColumnsWithArray(const ValueVector& rows) int rowColumns = 0; for(const auto &child : _children) { - CCASSERT(row < rows.size(), ""); + CCASSERT(row < rows.size(), "row should less than rows.size()!"); rowColumns = rows[row].asInt(); // can not have zero columns on a row - CCASSERT(rowColumns, ""); + CCASSERT(rowColumns, "rowColumns can't be 0."); float tmp = child->getContentSize().height; rowHeight = (unsigned int)((rowHeight >= tmp || isnan(tmp)) ? rowHeight : tmp); @@ -397,7 +397,7 @@ void Menu::alignItemsInColumnsWithArray(const ValueVector& rows) } // check if too many rows/columns for available menu items - CCASSERT(! columnsOccupied, ""); + CCASSERT(! columnsOccupied, "columnsOccupied should be 0."); Size winSize = Director::getInstance()->getWinSize(); @@ -472,11 +472,11 @@ void Menu::alignItemsInRowsWithArray(const ValueVector& columns) for(const auto &child : _children) { // check if too many menu items for the amount of rows/columns - CCASSERT(column < columns.size(), ""); + CCASSERT(column < columns.size(), "column should be less than columns.size()."); columnRows = columns[column].asInt(); // can't have zero rows on a column - CCASSERT(columnRows, ""); + CCASSERT(columnRows, "columnRows can't be 0."); // columnWidth = fmaxf(columnWidth, [item contentSize].width); float tmp = child->getContentSize().width; @@ -499,7 +499,7 @@ void Menu::alignItemsInRowsWithArray(const ValueVector& columns) } // check if too many rows/columns for available menu items. - CCASSERT(! rowsOccupied, ""); + CCASSERT(! rowsOccupied, "rowsOccupied should be 0."); Size winSize = Director::getInstance()->getWinSize(); diff --git a/cocos/2d/CCParticleSystem.cpp b/cocos/2d/CCParticleSystem.cpp index 170c8231a0..92d485d1e3 100644 --- a/cocos/2d/CCParticleSystem.cpp +++ b/cocos/2d/CCParticleSystem.cpp @@ -384,7 +384,7 @@ bool ParticleSystem::initWithDictionary(ValueMap& dictionary, const std::string& else if( dictionary.find("textureImageData") != dictionary.end() ) { std::string textureData = dictionary.at("textureImageData").asString(); - CCASSERT(!textureData.empty(), ""); + CCASSERT(!textureData.empty(), "textureData can't be empty!"); auto dataLen = textureData.size(); if (dataLen != 0) diff --git a/cocos/2d/CCSprite.cpp b/cocos/2d/CCSprite.cpp index faa5b61e79..7f02f088d0 100644 --- a/cocos/2d/CCSprite.cpp +++ b/cocos/2d/CCSprite.cpp @@ -205,7 +205,7 @@ bool Sprite::initWithSpriteFrameName(const std::string& spriteFrameName) bool Sprite::initWithSpriteFrame(SpriteFrame *spriteFrame) { - CCASSERT(spriteFrame != nullptr, ""); + CCASSERT(spriteFrame != nullptr, "spriteFrame can't be nullptr!"); bool bRet = initWithTexture(spriteFrame->getTexture(), spriteFrame->getRect()); setSpriteFrame(spriteFrame); @@ -673,7 +673,7 @@ void Sprite::addChild(Node *child, int zOrder, int tag) { Sprite* childSprite = dynamic_cast(child); CCASSERT( childSprite, "CCSprite only supports Sprites as children when using SpriteBatchNode"); - CCASSERT(childSprite->getTexture()->getName() == _textureAtlas->getTexture()->getName(), ""); + CCASSERT(childSprite->getTexture()->getName() == _textureAtlas->getTexture()->getName(), "childSprite's texture name should be equal to _textureAtlas's texture name!"); //put it in descendants array of batch node _batchNode->appendChild(childSprite); @@ -694,7 +694,8 @@ void Sprite::addChild(Node *child, int zOrder, const std::string &name) { Sprite* childSprite = dynamic_cast(child); CCASSERT( childSprite, "CCSprite only supports Sprites as children when using SpriteBatchNode"); - CCASSERT(childSprite->getTexture()->getName() == _textureAtlas->getTexture()->getName(), ""); + CCASSERT(childSprite->getTexture()->getName() == _textureAtlas->getTexture()->getName(), + "childSprite's texture name should be equal to _textureAtlas's texture name."); //put it in descendants array of batch node _batchNode->appendChild(childSprite); diff --git a/cocos/2d/CCTMXXMLParser.cpp b/cocos/2d/CCTMXXMLParser.cpp index e559550a58..a6b318f741 100644 --- a/cocos/2d/CCTMXXMLParser.cpp +++ b/cocos/2d/CCTMXXMLParser.cpp @@ -643,7 +643,7 @@ void TMXMapInfo::endElement(void *ctx, const char *name) ssize_t sizeHint = s.width * s.height * sizeof(unsigned int); ssize_t CC_UNUSED inflatedLen = ZipUtils::inflateMemoryWithHint(buffer, len, &deflated, sizeHint); - CCASSERT(inflatedLen == sizeHint, ""); + CCASSERT(inflatedLen == sizeHint, "inflatedLen should be equal to sizeHint!"); free(buffer); buffer = nullptr; diff --git a/cocos/base/CCEventDispatcher.cpp b/cocos/base/CCEventDispatcher.cpp index 914a8d34d6..8b5428d4af 100644 --- a/cocos/base/CCEventDispatcher.cpp +++ b/cocos/base/CCEventDispatcher.cpp @@ -1027,7 +1027,8 @@ void EventDispatcher::dispatchTouchEvent(EventTouch* event) return true; } - CCASSERT((*touchesIter)->getID() == (*mutableTouchesIter)->getID(), ""); + CCASSERT((*touchesIter)->getID() == (*mutableTouchesIter)->getID(), + "touchesIter ID should be equal to mutableTouchesIter's ID."); if (isClaimed && listener->_isRegistered && listener->_needSwallow) { diff --git a/cocos/base/CCEventListenerAcceleration.cpp b/cocos/base/CCEventListenerAcceleration.cpp index 099919be97..4bcdb6ce08 100644 --- a/cocos/base/CCEventListenerAcceleration.cpp +++ b/cocos/base/CCEventListenerAcceleration.cpp @@ -89,7 +89,7 @@ EventListenerAcceleration* EventListenerAcceleration::clone() bool EventListenerAcceleration::checkAvailable() { - CCASSERT(onAccelerationEvent, ""); + CCASSERT(onAccelerationEvent, "onAccelerationEvent can't be nullptr!"); return true; } diff --git a/cocos/base/CCScheduler.cpp b/cocos/base/CCScheduler.cpp index 8ed57ecab6..63fb852354 100644 --- a/cocos/base/CCScheduler.cpp +++ b/cocos/base/CCScheduler.cpp @@ -300,7 +300,7 @@ void Scheduler::schedule(const ccSchedulerFunc& callback, void *target, float in } else { - CCASSERT(element->paused == paused, ""); + CCASSERT(element->paused == paused, "element's paused should be paused!"); } if (element->timers == nullptr) @@ -694,7 +694,7 @@ void Scheduler::unscheduleScriptEntry(unsigned int scheduleScriptEntryID) void Scheduler::resumeTarget(void *target) { - CCASSERT(target != nullptr, ""); + CCASSERT(target != nullptr, "target can't be nullptr!"); // custom selectors tHashTimerEntry *element = nullptr; @@ -709,14 +709,14 @@ void Scheduler::resumeTarget(void *target) HASH_FIND_PTR(_hashForUpdates, &target, elementUpdate); if (elementUpdate) { - CCASSERT(elementUpdate->entry != nullptr, ""); + CCASSERT(elementUpdate->entry != nullptr, "elementUpdate's entry can't be nullptr!"); elementUpdate->entry->paused = false; } } void Scheduler::pauseTarget(void *target) { - CCASSERT(target != nullptr, ""); + CCASSERT(target != nullptr, "target can't be nullptr!"); // custom selectors tHashTimerEntry *element = nullptr; @@ -731,7 +731,7 @@ void Scheduler::pauseTarget(void *target) HASH_FIND_PTR(_hashForUpdates, &target, elementUpdate); if (elementUpdate) { - CCASSERT(elementUpdate->entry != nullptr, ""); + CCASSERT(elementUpdate->entry != nullptr, "elementUpdate's entry can't be nullptr!"); elementUpdate->entry->paused = true; } } @@ -1001,7 +1001,7 @@ void Scheduler::schedule(SEL_SCHEDULE selector, Ref *target, float interval, uns } else { - CCASSERT(element->paused == paused, ""); + CCASSERT(element->paused == paused, "element's paused should be paused."); } if (element->timers == nullptr) diff --git a/cocos/base/ZipUtils.cpp b/cocos/base/ZipUtils.cpp index 2110643d41..30ac76fd94 100644 --- a/cocos/base/ZipUtils.cpp +++ b/cocos/base/ZipUtils.cpp @@ -252,8 +252,8 @@ int ZipUtils::inflateGZipFile(const char *path, unsigned char **out) int len; unsigned int offset = 0; - CCASSERT(out, ""); - CCASSERT(&*out, ""); + CCASSERT(out, "out can't be nullptr."); + CCASSERT(&*out, "&*out can't be nullptr."); gzFile inFile = gzopen(path, "rb"); if( inFile == nullptr ) { diff --git a/cocos/editor-support/cocosbuilder/CCBReader.cpp b/cocos/editor-support/cocosbuilder/CCBReader.cpp index c0a408bb20..6b7d9c8f8a 100644 --- a/cocos/editor-support/cocosbuilder/CCBReader.cpp +++ b/cocos/editor-support/cocosbuilder/CCBReader.cpp @@ -128,7 +128,7 @@ CCBReader::~CCBReader() void CCBReader::setCCBRootPath(const char* ccbRootPath) { - CCASSERT(ccbRootPath != nullptr, ""); + CCASSERT(ccbRootPath != nullptr, "ccbRootPath can't be nullptr!"); _CCBRootPath = ccbRootPath; } diff --git a/cocos/editor-support/cocosbuilder/CCNodeLoader.cpp b/cocos/editor-support/cocosbuilder/CCNodeLoader.cpp index 071f3e3e68..cc375f129e 100644 --- a/cocos/editor-support/cocosbuilder/CCNodeLoader.cpp +++ b/cocos/editor-support/cocosbuilder/CCNodeLoader.cpp @@ -968,7 +968,8 @@ Node * NodeLoader::parsePropTypeCCBFile(Node * pNode, Node * pParent, CCBReader auto& ownerCallbackNodes = reader->getOwnerCallbackNodes(); if (!ownerCallbackNames.empty() && !ownerCallbackNodes.empty()) { - CCASSERT(ownerCallbackNames.size() == ownerCallbackNodes.size(), ""); + CCASSERT(ownerCallbackNames.size() == ownerCallbackNodes.size(), + "ownerCallbackNames size should equal to ownerCallbackNodes size."); ssize_t nCount = ownerCallbackNames.size(); for (ssize_t i = 0 ; i < nCount; i++) @@ -982,7 +983,8 @@ Node * NodeLoader::parsePropTypeCCBFile(Node * pNode, Node * pParent, CCBReader auto ownerOutletNodes = reader->getOwnerOutletNodes(); if (!ownerOutletNames.empty() && !ownerOutletNodes.empty()) { - CCASSERT(ownerOutletNames.size() == ownerOutletNodes.size(), ""); + CCASSERT(ownerOutletNames.size() == ownerOutletNodes.size(), + "ownerOutletNames size should be equal to ownerOutletNodes's size."); ssize_t nCount = ownerOutletNames.size(); for (ssize_t i = 0 ; i < nCount; i++) diff --git a/cocos/editor-support/cocostudio/CCArmature.cpp b/cocos/editor-support/cocostudio/CCArmature.cpp index c0b9cf4853..396f7bf30a 100644 --- a/cocos/editor-support/cocostudio/CCArmature.cpp +++ b/cocos/editor-support/cocostudio/CCArmature.cpp @@ -137,7 +137,7 @@ bool Armature::init(const std::string& name) ArmatureData *armatureData = armatureDataManager->getArmatureData(name); - CCASSERT(armatureData, ""); + CCASSERT(armatureData, "armatureData doesn't exists!"); _armatureData = armatureData; diff --git a/cocos/editor-support/cocostudio/TriggerObj.cpp b/cocos/editor-support/cocostudio/TriggerObj.cpp index f2316466d0..018c4b468c 100755 --- a/cocos/editor-support/cocostudio/TriggerObj.cpp +++ b/cocos/editor-support/cocostudio/TriggerObj.cpp @@ -185,10 +185,10 @@ void TriggerObj::serialize(const rapidjson::Value &val) if(con == nullptr) { CCLOG("class %s can not be implemented!", classname); - CCASSERT(con != nullptr, ""); + CCASSERT(con != nullptr, "con can't be nullptr!"); } - CCASSERT(con != nullptr, ""); + CCASSERT(con != nullptr, "con can't be nullptr!"); con->serialize(subDict); con->init(); _cons.pushBack(con); @@ -207,7 +207,7 @@ void TriggerObj::serialize(const rapidjson::Value &val) if(act == nullptr) { CCLOG("class %s can not be implemented!", classname); - CCASSERT(act != nullptr, ""); + CCASSERT(act != nullptr, "act can't be nullptr!"); } act->serialize(subDict); act->init(); diff --git a/cocos/renderer/CCGLProgramState.cpp b/cocos/renderer/CCGLProgramState.cpp index 616e5b2d92..b5728c6a17 100644 --- a/cocos/renderer/CCGLProgramState.cpp +++ b/cocos/renderer/CCGLProgramState.cpp @@ -239,7 +239,7 @@ void UniformValue::setVec4v(ssize_t size, const Vec4* pointer) void UniformValue::setMat4(const Mat4& value) { - CCASSERT(_uniform->type == GL_FLOAT_MAT4, ""); + CCASSERT(_uniform->type == GL_FLOAT_MAT4, "_uniform's type should be equal GL_FLOAT_MAT4."); memcpy(_value.matrixValue, &value, sizeof(_value.matrixValue)); _type = Type::VALUE; } diff --git a/cocos/renderer/CCTexture2D.cpp b/cocos/renderer/CCTexture2D.cpp index 634c7c0f1c..b9e0a581ae 100644 --- a/cocos/renderer/CCTexture2D.cpp +++ b/cocos/renderer/CCTexture2D.cpp @@ -670,7 +670,7 @@ bool Texture2D::initWithMipmaps(MipmapInfo* mipmaps, int mipmapsNum, PixelFormat CCLOG("cocos2d: Texture2D. WARNING. Mipmap level %u is not squared. Texture won't render correctly. width=%d != height=%d", i, width, height); } - GLenum err = glGetError(); + err = glGetError(); if (err != GL_NO_ERROR) { CCLOG("cocos2d: Texture2D: Error uploading compressed texture level: %u . glError: 0x%04X", i, err); diff --git a/cocos/renderer/CCTextureAtlas.cpp b/cocos/renderer/CCTextureAtlas.cpp index 630236c571..fde935cac5 100644 --- a/cocos/renderer/CCTextureAtlas.cpp +++ b/cocos/renderer/CCTextureAtlas.cpp @@ -171,7 +171,7 @@ bool TextureAtlas::initWithTexture(Texture2D *texture, ssize_t capacity) CC_SAFE_RETAIN(_texture); // Re-initialization is not allowed - CCASSERT(_quads == nullptr && _indices == nullptr, ""); + CCASSERT(_quads == nullptr && _indices == nullptr, "_quads and _indices should be nullptr."); _quads = (V3F_C4B_T2F_Quad*)malloc( _capacity * sizeof(V3F_C4B_T2F_Quad) ); _indices = (GLushort *)malloc( _capacity * 6 * sizeof(GLushort) ); diff --git a/cocos/scripting/js-bindings/manual/cocos2d_specifics.cpp b/cocos/scripting/js-bindings/manual/cocos2d_specifics.cpp index 87603e33ed..1eb050e935 100644 --- a/cocos/scripting/js-bindings/manual/cocos2d_specifics.cpp +++ b/cocos/scripting/js-bindings/manual/cocos2d_specifics.cpp @@ -50,7 +50,8 @@ JSTouchDelegate::~JSTouchDelegate() void JSTouchDelegate::setDelegateForJSObject(JSObject* pJSObj, JSTouchDelegate* pDelegate) { - CCASSERT(sTouchDelegateMap.find(pJSObj) == sTouchDelegateMap.end(), ""); + CCASSERT(sTouchDelegateMap.find(pJSObj) == sTouchDelegateMap.end(), + "pJSObj can't be found in sTouchDelegateMap."); sTouchDelegateMap.insert(TouchDelegatePair(pJSObj, pDelegate)); } @@ -68,7 +69,7 @@ JSTouchDelegate* JSTouchDelegate::getDelegateForJSObject(JSObject* pJSObj) void JSTouchDelegate::removeDelegateForJSObject(JSObject* pJSObj) { TouchDelegateMap::iterator iter = sTouchDelegateMap.find(pJSObj); - CCASSERT(iter != sTouchDelegateMap.end(), ""); + CCASSERT(iter != sTouchDelegateMap.end(), "pJSObj can't be found in sTouchDelegateMap!"); sTouchDelegateMap.erase(pJSObj); } @@ -1386,7 +1387,7 @@ void JSScheduleWrapper::dump() jsfuncTargetCount++; } } - CCASSERT(nativeTargetsCount == jsfuncTargetCount, ""); + CCASSERT(nativeTargetsCount == jsfuncTargetCount, "nativeTargetsCount should be equal to jsfuncTargetCount."); CCLOG("\n---------JSScheduleWrapper dump end--------------\n"); #endif } diff --git a/cocos/ui/UIWidget.cpp b/cocos/ui/UIWidget.cpp index 54c16e0f16..86bd7c5387 100644 --- a/cocos/ui/UIWidget.cpp +++ b/cocos/ui/UIWidget.cpp @@ -1296,7 +1296,7 @@ void Widget::copyProperties(Widget *widget) float Widget::getScale()const { - CCASSERT(this->getScaleX() == this->getScaleY(), ""); + CCASSERT(this->getScaleX() == this->getScaleY(), "scaleX should be equal to scaleY."); return this->getScaleX(); } diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISliderTest/UISliderTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISliderTest/UISliderTest.cpp index 3dd0e3ff93..6083704502 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISliderTest/UISliderTest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISliderTest/UISliderTest.cpp @@ -349,6 +349,7 @@ bool UISliderNewEventCallbackTest::init() slider->addEventListener([=](Ref* widget,Slider::EventType type) { Slider* slider = (Slider*)widget; + CC_UNUSED_PARAM(slider); if(type == Slider::EventType::ON_SLIDEBALL_DOWN) { CCLOG("slider button pressed!"); diff --git a/tests/cpp-tests/Classes/UnitTest/UnitTest.cpp b/tests/cpp-tests/Classes/UnitTest/UnitTest.cpp index 4bf497f369..33d11f9507 100644 --- a/tests/cpp-tests/Classes/UnitTest/UnitTest.cpp +++ b/tests/cpp-tests/Classes/UnitTest/UnitTest.cpp @@ -60,51 +60,51 @@ void TemplateVectorTest::onEnter() UnitTestDemo::onEnter(); Vector vec; - CCASSERT(vec.empty(), ""); - CCASSERT(vec.capacity() == 0, ""); - CCASSERT(vec.size() == 0, ""); - CCASSERT(vec.max_size() > 0, ""); + CCASSERT(vec.empty(), "vec should be empty."); + CCASSERT(vec.capacity() == 0, "vec.capacity should be 0."); + CCASSERT(vec.size() == 0, "vec.size should be 0."); + CCASSERT(vec.max_size() > 0, "vec.max_size should > 0."); auto node1 = Node::create(); node1->setTag(1); vec.pushBack(node1); - CCASSERT(node1->getReferenceCount() == 2, ""); + CCASSERT(node1->getReferenceCount() == 2, "node1->getReferenceCount should be 2."); auto node2 = Node::create(); node2->setTag(2); vec.pushBack(node2); - CCASSERT(vec.getIndex(node1) == 0, ""); - CCASSERT(vec.getIndex(node2) == 1, ""); + CCASSERT(vec.getIndex(node1) == 0, "node1 should at index 0 in vec."); + CCASSERT(vec.getIndex(node2) == 1, "node2 should at index 1 in vec."); auto node3 = Node::create(); node3->setTag(3); vec.insert(1, node3); - CCASSERT(vec.at(0)->getTag() == 1, ""); - CCASSERT(vec.at(1)->getTag() == 3, ""); - CCASSERT(vec.at(2)->getTag() == 2, ""); + CCASSERT(vec.at(0)->getTag() == 1, "The element at 0, tag should be 1."); + CCASSERT(vec.at(1)->getTag() == 3, "The element at 1, tag should be 3."); + CCASSERT(vec.at(2)->getTag() == 2, "The element at 2, tag should be 2."); // Test copy constructor Vector vec2(vec); - CCASSERT(vec2.size() == vec.size(), ""); + CCASSERT(vec2.size() == vec.size(), "vec2 and vec should have equal size."); ssize_t size = vec.size(); for (ssize_t i = 0; i < size; ++i) { - CCASSERT(vec2.at(i) == vec.at(i), ""); - CCASSERT(vec.at(i)->getReferenceCount() == 3, ""); - CCASSERT(vec2.at(i)->getReferenceCount() == 3, ""); + CCASSERT(vec2.at(i) == vec.at(i), "The element at the same index in vec2 and vec2 should be equal."); + CCASSERT(vec.at(i)->getReferenceCount() == 3, "The reference cound of element in vec is 3. "); + CCASSERT(vec2.at(i)->getReferenceCount() == 3, "The reference cound of element in vec2 is 3. "); } // Test copy assignment operator Vector vec3; vec3 = vec2; - CCASSERT(vec3.size() == vec2.size(), ""); + CCASSERT(vec3.size() == vec2.size(), "vec3 and vec2 should have equal size."); size = vec3.size(); for (ssize_t i = 0; i < size; ++i) { - CCASSERT(vec3.at(i) == vec2.at(i), ""); - CCASSERT(vec3.at(i)->getReferenceCount() == 4, ""); - CCASSERT(vec2.at(i)->getReferenceCount() == 4, ""); - CCASSERT(vec.at(i)->getReferenceCount() == 4, ""); + CCASSERT(vec3.at(i) == vec2.at(i), "The element at the same index in vec3 and vec2 should be equal."); + CCASSERT(vec3.at(i)->getReferenceCount() == 4, "The reference cound of element in vec3 is 4. "); + CCASSERT(vec2.at(i)->getReferenceCount() == 4, "The reference cound of element in vec2 is 4. "); + CCASSERT(vec.at(i)->getReferenceCount() == 4, "The reference cound of element in vec is 4. "); } // Test move constructor @@ -130,75 +130,75 @@ void TemplateVectorTest::onEnter() for (const auto& child : vec4) { CC_UNUSED_PARAM(child); - CCASSERT(child->getReferenceCount() == 2, ""); + CCASSERT(child->getReferenceCount() == 2, "child's reference count should be 2."); } // Test init Vector with capacity Vector vec5(10); - CCASSERT(vec5.capacity() == 10, ""); + CCASSERT(vec5.capacity() == 10, "vec5's capacity should be 10."); vec5.reserve(20); - CCASSERT(vec5.capacity() == 20, ""); + CCASSERT(vec5.capacity() == 20, "vec5's capacity should be 20."); - CCASSERT(vec5.size() == 0, ""); - CCASSERT(vec5.empty(), ""); + CCASSERT(vec5.size() == 0, "vec5's size should be 0."); + CCASSERT(vec5.empty(), "vec5 is empty now."); auto toRemovedNode = Node::create(); vec5.pushBack(toRemovedNode); - CCASSERT(toRemovedNode->getReferenceCount() == 2, ""); + CCASSERT(toRemovedNode->getReferenceCount() == 2, "toRemovedNode's reference count is 2."); // Test move assignment operator vec5 = createVector(); - CCASSERT(toRemovedNode->getReferenceCount() == 1, ""); + CCASSERT(toRemovedNode->getReferenceCount() == 1, "toRemovedNode's reference count is 1."); CCASSERT(vec5.size() == 20, "size should be 20"); for (const auto& child : vec5) { CC_UNUSED_PARAM(child); - CCASSERT(child->getReferenceCount() == 2, ""); + CCASSERT(child->getReferenceCount() == 2, "child's reference count is 2."); } // Test Vector::find - CCASSERT(vec.find(node3) == (vec.begin() + 1), ""); - CCASSERT(std::find(std::begin(vec), std::end(vec), node2) == (vec.begin() + 2), ""); + CCASSERT(vec.find(node3) == (vec.begin() + 1), "node3 is the 2nd element in vec."); + CCASSERT(std::find(std::begin(vec), std::end(vec), node2) == (vec.begin() + 2), "node2 is the 3rd element in vec."); - CCASSERT(vec.front()->getTag() == 1, ""); - CCASSERT(vec.back()->getTag() == 2, ""); + CCASSERT(vec.front()->getTag() == 1, "vec's front element's tag is 1."); + CCASSERT(vec.back()->getTag() == 2, "vec's back element's tag is 2."); - CCASSERT(vec.getRandomObject(), ""); - CCASSERT(!vec.contains(Node::create()), ""); - CCASSERT(vec.contains(node1), ""); - CCASSERT(vec.contains(node2), ""); - CCASSERT(vec.contains(node3), ""); - CCASSERT(vec.equals(vec2), ""); - CCASSERT(vec.equals(vec3), ""); + CCASSERT(vec.getRandomObject(), "vec getRandomObject should return true."); + CCASSERT(!vec.contains(Node::create()), "vec doesn't contain a empty Node instance."); + CCASSERT(vec.contains(node1), "vec contains node1."); + CCASSERT(vec.contains(node2), "vec contains node2."); + CCASSERT(vec.contains(node3), "vec contains node3."); + CCASSERT(vec.equals(vec2), "vec is equal to vec2."); + CCASSERT(vec.equals(vec3), "vec is equal to vec3."); // Insert vec5.insert(2, node1); - CCASSERT(vec5.at(2)->getTag() == 1, ""); - CCASSERT(vec5.size() == 21, ""); + CCASSERT(vec5.at(2)->getTag() == 1, "vec5's 3rd element's tag is 1."); + CCASSERT(vec5.size() == 21, "vec5's size is 21."); vec5.back()->setTag(100); vec5.popBack(); - CCASSERT(vec5.size() == 20, ""); - CCASSERT(vec5.back()->getTag() != 100, ""); + CCASSERT(vec5.size() == 20, "vec5's size is 20."); + CCASSERT(vec5.back()->getTag() != 100, "the back element of vec5's tag is 100."); // Erase and clear Vector vec6 = createVector(); Vector vec7 = vec6; // Copy for check - CCASSERT(vec6.size() == 20, ""); + CCASSERT(vec6.size() == 20, "vec6's size is 20."); vec6.erase(vec6.begin() + 1); // - CCASSERT(vec6.size() == 19, ""); - CCASSERT((*(vec6.begin() + 1))->getTag() == 1002, ""); + CCASSERT(vec6.size() == 19, "vec6's size is 19."); + CCASSERT((*(vec6.begin() + 1))->getTag() == 1002, "The 2rd element in vec6's tag is 1002."); vec6.erase(vec6.begin() + 2, vec6.begin() + 10); - CCASSERT(vec6.size() == 11, ""); - CCASSERT(vec6.at(0)->getTag() == 1000, ""); - CCASSERT(vec6.at(1)->getTag() == 1002, ""); - CCASSERT(vec6.at(2)->getTag() == 1011, ""); - CCASSERT(vec6.at(3)->getTag() == 1012, ""); + CCASSERT(vec6.size() == 11, "vec6's size is 11."); + CCASSERT(vec6.at(0)->getTag() == 1000, "vec6's first element's tag is 1000."); + CCASSERT(vec6.at(1)->getTag() == 1002, "vec6's second element's tag is 1002."); + CCASSERT(vec6.at(2)->getTag() == 1011, "vec6's third element's tag is 1011."); + CCASSERT(vec6.at(3)->getTag() == 1012, "vec6's fouth element's tag is 1012."); vec6.erase(3); - CCASSERT(vec6.at(3)->getTag() == 1013, ""); + CCASSERT(vec6.at(3)->getTag() == 1013, "vec6's 4th elemetn's tag is 1013."); vec6.eraseObject(vec6.at(2)); - CCASSERT(vec6.at(2)->getTag() == 1013, ""); + CCASSERT(vec6.at(2)->getTag() == 1013, "vec6's 3rd element's tag is 1013."); vec6.clear(); auto objA = Node::create(); // retain count is 1 @@ -220,9 +220,9 @@ void TemplateVectorTest::onEnter() for (auto obj : array1) { array2.eraseObject(obj); } - CCASSERT(objA->getReferenceCount() == 4, ""); + CCASSERT(objA->getReferenceCount() == 4, "objA's reference count is 4."); } - CCASSERT(objA->getReferenceCount() == 1, ""); + CCASSERT(objA->getReferenceCount() == 1, "objA's reference count is 1."); { Vector array1; @@ -230,24 +230,24 @@ void TemplateVectorTest::onEnter() array1.pushBack(objA); // retain count is 2 array1.pushBack(objA); // retain count is 3 array1.pushBack(objA); // retain count is 4 - CCASSERT(objA->getReferenceCount() == 4, ""); + CCASSERT(objA->getReferenceCount() == 4, "objA's reference count is 4."); array1.eraseObject(objA, true); // Remove all occurrences in the Vector. - CCASSERT(objA->getReferenceCount() == 1, ""); + CCASSERT(objA->getReferenceCount() == 1, "objA's reference count is 1."); array1.pushBack(objA); // retain count is 2 array1.pushBack(objA); // retain count is 3 array1.pushBack(objA); // retain count is 4 array1.eraseObject(objA, false); - CCASSERT(objA->getReferenceCount() == 3, ""); // Only remove the first occurrence in the Vector. + CCASSERT(objA->getReferenceCount() == 3, "objA's reference count is 3."); // Only remove the first occurrence in the Vector. } // Check the retain count in vec7 - CCASSERT(vec7.size() == 20, ""); + CCASSERT(vec7.size() == 20, "vec7's size is 20."); for (const auto& child : vec7) { CC_UNUSED_PARAM(child); - CCASSERT(child->getReferenceCount() == 2, ""); + CCASSERT(child->getReferenceCount() == 2, "child's reference count is 2."); } // Sort @@ -258,32 +258,32 @@ void TemplateVectorTest::onEnter() for (int i = 0; i < 20; ++i) { - CCASSERT(vecForSort.at(i)->getTag() - 1000 == (19 - i), ""); + CCASSERT(vecForSort.at(i)->getTag() - 1000 == (19 - i), "vecForSort's element's tag is invalid."); } // Reverse vecForSort.reverse(); for (int i = 0; i < 20; ++i) { - CCASSERT(vecForSort.at(i)->getTag() - 1000 == i, ""); + CCASSERT(vecForSort.at(i)->getTag() - 1000 == i, "vecForSort's element's tag is invalid."); } // Swap Vector vecForSwap = createVector(); vecForSwap.swap(2, 4); - CCASSERT(vecForSwap.at(2)->getTag() == 1004, ""); - CCASSERT(vecForSwap.at(4)->getTag() == 1002, ""); + CCASSERT(vecForSwap.at(2)->getTag() == 1004, "vecForSwap's 3nd element's tag is 1004."); + CCASSERT(vecForSwap.at(4)->getTag() == 1002, "vecForSwap's 5rd element's tag is 1002."); vecForSwap.swap(vecForSwap.at(2), vecForSwap.at(4)); - CCASSERT(vecForSwap.at(2)->getTag() == 1002, ""); - CCASSERT(vecForSwap.at(4)->getTag() == 1004, ""); + CCASSERT(vecForSwap.at(2)->getTag() == 1002, "vecForSwap's 3rd element's tag is 1002."); + CCASSERT(vecForSwap.at(4)->getTag() == 1004, "vecForSwap's 5rd element's tag is 1004."); // shrinkToFit Vector vecForShrink = createVector(); vecForShrink.reserve(100); - CCASSERT(vecForShrink.capacity() == 100, ""); + CCASSERT(vecForShrink.capacity() == 100, "vecForShrink's capacity is 100."); vecForShrink.pushBack(Node::create()); vecForShrink.shrinkToFit(); - CCASSERT(vecForShrink.capacity() == 21, ""); + CCASSERT(vecForShrink.capacity() == 21, "vecForShrink's capacity is 21."); // get random object // Set the seed by time @@ -299,21 +299,21 @@ void TemplateVectorTest::onEnter() // Self assignment Vector vecSelfAssign = createVector(); vecSelfAssign = vecSelfAssign; - CCASSERT(vecSelfAssign.size() == 20, ""); + CCASSERT(vecSelfAssign.size() == 20, "vecSelfAssign's size is 20."); for (const auto& child : vecSelfAssign) { CC_UNUSED_PARAM(child); - CCASSERT(child->getReferenceCount() == 2, ""); + CCASSERT(child->getReferenceCount() == 2, "child's reference count is 2."); } vecSelfAssign = std::move(vecSelfAssign); - CCASSERT(vecSelfAssign.size() == 20, ""); + CCASSERT(vecSelfAssign.size() == 20, "vecSelfAssign's size is 20."); for (const auto& child : vecSelfAssign) { CC_UNUSED_PARAM(child); - CCASSERT(child->getReferenceCount() == 2, ""); + CCASSERT(child->getReferenceCount() == 2, "child's reference count is 2."); } // const at @@ -352,17 +352,17 @@ void TemplateMapTest::onEnter() // Default constructor Map map1; - CCASSERT(map1.empty(), ""); - CCASSERT(map1.size() == 0, ""); - CCASSERT(map1.keys().empty(), ""); - CCASSERT(map1.keys(Node::create()).empty(), ""); + CCASSERT(map1.empty(), "map1 is empty."); + CCASSERT(map1.size() == 0, "map1's size is 0."); + CCASSERT(map1.keys().empty(), "map1's keys are empty."); + CCASSERT(map1.keys(Node::create()).empty(), "map1's keys don't contain a empty Node."); // Move constructor Map map2 = createMap(); for (const auto& e : map2) { CC_UNUSED_PARAM(e); - CCASSERT(e.second->getReferenceCount() == 2, ""); + CCASSERT(e.second->getReferenceCount() == 2, "e.second element's reference count is 2."); } // Copy constructor @@ -370,7 +370,7 @@ void TemplateMapTest::onEnter() for (const auto& e : map3) { CC_UNUSED_PARAM(e); - CCASSERT(e.second->getReferenceCount() == 3, ""); + CCASSERT(e.second->getReferenceCount() == 3, "e.second's reference count is 3."); } // Move assignment operator @@ -378,11 +378,11 @@ void TemplateMapTest::onEnter() auto unusedNode = Node::create(); map4.insert("unused",unusedNode); map4 = createMap(); - CCASSERT(unusedNode->getReferenceCount() == 1, ""); + CCASSERT(unusedNode->getReferenceCount() == 1, "unusedNode's reference count is 1."); for (const auto& e : map4) { CC_UNUSED_PARAM(e); - CCASSERT(e.second->getReferenceCount() == 2, ""); + CCASSERT(e.second->getReferenceCount() == 2, "e.second's reference count is 2."); } // Copy assignment operator @@ -391,16 +391,16 @@ void TemplateMapTest::onEnter() for (const auto& e : map5) { CC_UNUSED_PARAM(e); - CCASSERT(e.second->getReferenceCount() == 3, ""); + CCASSERT(e.second->getReferenceCount() == 3, "e.second's reference count is 3."); } // Check size - CCASSERT(map4.size() == map5.size(), ""); + CCASSERT(map4.size() == map5.size(), "map4's size is equal to map5.size."); for (const auto& e : map4) { CC_UNUSED_PARAM(e); - CCASSERT(e.second == map5.find(e.first)->second, ""); + CCASSERT(e.second == map5.find(e.first)->second, "e.second can't be found in map5."); } // bucket_count, bucket_size(n), bucket @@ -444,7 +444,7 @@ void TemplateMapTest::onEnter() // find auto nodeToFind = map4.find("10"); CC_UNUSED_PARAM(nodeToFind); - CCASSERT(nodeToFind->second->getTag() == 1010, ""); + CCASSERT(nodeToFind->second->getTag() == 1010, "nodeToFind's tag value is 1010."); // insert Map map6; @@ -458,29 +458,29 @@ void TemplateMapTest::onEnter() map6.insert("insert02", node2); map6.insert("insert03", node3); - CCASSERT(node1->getReferenceCount() == 2, ""); - CCASSERT(node2->getReferenceCount() == 2, ""); - CCASSERT(node3->getReferenceCount() == 2, ""); - CCASSERT(map6.at("insert01") == node1, ""); - CCASSERT(map6.at("insert02") == node2, ""); - CCASSERT(map6.at("insert03") == node3, ""); + CCASSERT(node1->getReferenceCount() == 2, "node1's reference count is 2."); + CCASSERT(node2->getReferenceCount() == 2, "node2's reference count is 2."); + CCASSERT(node3->getReferenceCount() == 2, "node3's reference count is 2."); + CCASSERT(map6.at("insert01") == node1, "The element at insert01 is equal to node1."); + CCASSERT(map6.at("insert02") == node2, "The element at insert02 is equal to node2."); + CCASSERT(map6.at("insert03") == node3, "The element at insert03 is equal to node3."); // erase Map mapForErase = createMap(); mapForErase.erase(mapForErase.find("9")); - CCASSERT(mapForErase.find("9") == mapForErase.end(), ""); - CCASSERT(mapForErase.size() == 19, ""); + CCASSERT(mapForErase.find("9") == mapForErase.end(), "9 is already removed."); + CCASSERT(mapForErase.size() == 19, "mapForErase's size is 19."); mapForErase.erase("7"); - CCASSERT(mapForErase.find("7") == mapForErase.end(), ""); - CCASSERT(mapForErase.size() == 18, ""); + CCASSERT(mapForErase.find("7") == mapForErase.end(), "7 is already removed."); + CCASSERT(mapForErase.size() == 18, "mapForErase's size is 18."); std::vector itemsToRemove; itemsToRemove.push_back("2"); itemsToRemove.push_back("3"); itemsToRemove.push_back("4"); mapForErase.erase(itemsToRemove); - CCASSERT(mapForErase.size() == 15, ""); + CCASSERT(mapForErase.size() == 15, "mapForErase's size is 15."); // clear Map mapForClear = createMap(); @@ -490,7 +490,7 @@ void TemplateMapTest::onEnter() for (const auto& e : mapForClearCopy) { CC_UNUSED_PARAM(e); - CCASSERT(e.second->getReferenceCount() == 2, ""); + CCASSERT(e.second->getReferenceCount() == 2, "e.second's reference count is 2."); } // get random object @@ -507,21 +507,21 @@ void TemplateMapTest::onEnter() // Self assignment Map mapForSelfAssign = createMap(); mapForSelfAssign = mapForSelfAssign; - CCASSERT(mapForSelfAssign.size() == 20, ""); + CCASSERT(mapForSelfAssign.size() == 20, "mapForSelfAssign's size is 20."); for (const auto& e : mapForSelfAssign) { CC_UNUSED_PARAM(e); - CCASSERT(e.second->getReferenceCount() == 2, ""); + CCASSERT(e.second->getReferenceCount() == 2, "e.second's reference count is 2."); } mapForSelfAssign = std::move(mapForSelfAssign); - CCASSERT(mapForSelfAssign.size() == 20, ""); + CCASSERT(mapForSelfAssign.size() == 20, "mapForSelfAssign's size is 20."); for (const auto& e : mapForSelfAssign) { CC_UNUSED_PARAM(e); - CCASSERT(e.second->getReferenceCount() == 2, ""); + CCASSERT(e.second->getReferenceCount() == 2, "e.second's reference's count is 2."); } } @@ -543,37 +543,37 @@ void ValueTest::onEnter() UnitTestDemo::onEnter(); Value v1; - CCASSERT(v1.getType() == Value::Type::NONE, ""); - CCASSERT(v1.isNull(), ""); + CCASSERT(v1.getType() == Value::Type::NONE, "v1's value type should be VALUE::Type::NONE."); + CCASSERT(v1.isNull(), "v1 is null."); Value v2(100); - CCASSERT(v2.getType() == Value::Type::INTEGER, ""); - CCASSERT(!v2.isNull(), ""); + CCASSERT(v2.getType() == Value::Type::INTEGER, "v2's value type should be VALUE::Type::INTEGER."); + CCASSERT(!v2.isNull(), "v2 is not null."); Value v3(101.4f); - CCASSERT(v3.getType() == Value::Type::FLOAT, ""); - CCASSERT(!v3.isNull(), ""); + CCASSERT(v3.getType() == Value::Type::FLOAT, "v3's value type should be VALUE::Type::FLOAT."); + CCASSERT(!v3.isNull(), "v3 is not null."); Value v4(106.1); - CCASSERT(v4.getType() == Value::Type::DOUBLE, ""); - CCASSERT(!v4.isNull(), ""); + CCASSERT(v4.getType() == Value::Type::DOUBLE, "v4's value type should be VALUE::Type::DOUBLE."); + CCASSERT(!v4.isNull(), "v4 is not null."); unsigned char byte = 50; Value v5(byte); - CCASSERT(v5.getType() == Value::Type::BYTE, ""); - CCASSERT(!v5.isNull(), ""); + CCASSERT(v5.getType() == Value::Type::BYTE, "v5's value type should be Value::Type::BTYE."); + CCASSERT(!v5.isNull(), "v5 is not null."); Value v6(true); - CCASSERT(v6.getType() == Value::Type::BOOLEAN, ""); - CCASSERT(!v6.isNull(), ""); + CCASSERT(v6.getType() == Value::Type::BOOLEAN, "v6's value type is Value::Type::BOOLEAN."); + CCASSERT(!v6.isNull(), "v6 is not null."); Value v7("string"); - CCASSERT(v7.getType() == Value::Type::STRING, ""); - CCASSERT(!v7.isNull(), ""); + CCASSERT(v7.getType() == Value::Type::STRING, "v7's value type is Value::type::STRING."); + CCASSERT(!v7.isNull(), "v7 is not null."); Value v8(std::string("string2")); - CCASSERT(v8.getType() == Value::Type::STRING, ""); - CCASSERT(!v8.isNull(), ""); + CCASSERT(v8.getType() == Value::Type::STRING, "v8's value type is Value::Type::STRING."); + CCASSERT(!v8.isNull(), "v8 is not null."); auto createValueVector = [&](){ ValueVector ret; @@ -585,8 +585,8 @@ void ValueTest::onEnter() Value v9(createValueVector()); - CCASSERT(v9.getType() == Value::Type::VECTOR, ""); - CCASSERT(!v9.isNull(), ""); + CCASSERT(v9.getType() == Value::Type::VECTOR, "v9's value type is Value::Type::VECTOR."); + CCASSERT(!v9.isNull(), "v9 is not null."); auto createValueMap = [&](){ ValueMap ret; @@ -597,8 +597,8 @@ void ValueTest::onEnter() }; Value v10(createValueMap()); - CCASSERT(v10.getType() == Value::Type::MAP, ""); - CCASSERT(!v10.isNull(), ""); + CCASSERT(v10.getType() == Value::Type::MAP, "v10's value type is Value::Type::MAP."); + CCASSERT(!v10.isNull(), "v10 is not null."); auto createValueMapIntKey = [&](){ ValueMapIntKey ret; @@ -609,8 +609,8 @@ void ValueTest::onEnter() }; Value v11(createValueMapIntKey()); - CCASSERT(v11.getType() == Value::Type::INT_KEY_MAP, ""); - CCASSERT(!v11.isNull(), ""); + CCASSERT(v11.getType() == Value::Type::INT_KEY_MAP, "v11's value type is Value::Type::INT_KEY_MAP."); + CCASSERT(!v11.isNull(), "v11 is not null."); } std::string ValueTest::subtitle() const