• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ debugAssert函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中debugAssert函数的典型用法代码示例。如果您正苦于以下问题:C++ debugAssert函数的具体用法?C++ debugAssert怎么用?C++ debugAssert使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了debugAssert函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: switch

void Box::getFaceCorners(int f, Vector3& v0, Vector3& v1, Vector3& v2, Vector3& v3) const {
    switch (f) {
    case 0:
        v0 = _corner[0]; v1 = _corner[1]; v2 = _corner[2]; v3 = _corner[3];
        break;

    case 1:
        v0 = _corner[1]; v1 = _corner[5]; v2 = _corner[6]; v3 = _corner[2];
        break;

    case 2:
        v0 = _corner[7]; v1 = _corner[6]; v2 = _corner[5]; v3 = _corner[4];
        break;

    case 3:
        v0 = _corner[2]; v1 = _corner[6]; v2 = _corner[7]; v3 = _corner[3];
        break;

    case 4:
        v0 = _corner[3]; v1 = _corner[7]; v2 = _corner[4]; v3 = _corner[0];
        break;

    case 5:
        v0 = _corner[1]; v1 = _corner[0]; v2 = _corner[4]; v3 = _corner[5];
        break;

    default:
        debugAssert((f >= 0) && (f < 6));
    }
}
开发者ID:h4s0n,项目名称:Sandshroud,代码行数:30,代码来源:Box.cpp


示例2: testMatrix3

void testMatrix3() {
    printf("G3D::Matrix3  ");

    testEuler();

    {
        Matrix3 M = Matrix3::identity();
        for (int i = 0; i < 3; ++i) {
            for (int j = 0; j < 3; ++j) {
                M[i][j] = uniformRandom(0, 1);
            }
        }

        Vector3 v = Vector3::random();

        Vector3 x1 = v * M;
        Vector3 x2 = M.transpose() * v;

        debugAssert(x1 == x2);

    }


    printf("passed\n");
}
开发者ID:luaman,项目名称:g3d-cpp,代码行数:25,代码来源:tMatrix3.cpp


示例3: stringSplit

NetAddress::NetAddress(const std::string& hostnameAndPort) {

    Array<std::string> part = stringSplit(hostnameAndPort, ':');

    debugAssert(part.length() == 2);
    init(part[0], atoi(part[1].c_str()));
}
开发者ID:090809,项目名称:TrinityCore,代码行数:7,代码来源:NetAddress.cpp


示例4: testEuler

static void testEuler() {
    float x = 1;
    float y = 2;
    float z = -3;

    float x2, y2, z2;

    Matrix3 rX = Matrix3::fromAxisAngle(Vector3::unitX(), x);
    Matrix3 rY = Matrix3::fromAxisAngle(Vector3::unitY(), y);
    Matrix3 rZ = Matrix3::fromAxisAngle(Vector3::unitZ(), z);
    Matrix3 rot = rZ * rX * rY;
    rot.toEulerAnglesZXY(x2, y2, z2);
    debugAssert(fuzzyEq(x, x2));
    debugAssert(fuzzyEq(y, y2));
    debugAssert(fuzzyEq(z, z2));
}
开发者ID:luaman,项目名称:g3d-cpp,代码行数:16,代码来源:tMatrix3.cpp


示例5: debugAssert

BinaryOutput::~BinaryOutput() {
    debugAssert((m_buffer == NULL) || isValidHeapPointer(m_buffer));
    System::free(m_buffer);
    m_buffer = NULL;
    m_bufferLen = 0;
    m_maxBufferLen = 0;
}
开发者ID:Xadras,项目名称:TBCPvP,代码行数:7,代码来源:BinaryOutput.cpp


示例6: prepareToRead

void BinaryInput::readBytes(void* bytes, int64 n) {
    prepareToRead(n);
    debugAssert(isValidPointer(bytes));

    memcpy(bytes, m_buffer + m_pos, n);
    m_pos += n;
}
开发者ID:Blumfield,项目名称:ptc,代码行数:7,代码来源:BinaryInput.cpp


示例7: beforeRead

Any& Any::operator[](int i) {
    beforeRead();
    verifyType(ARRAY);
    debugAssert(m_data != NULL);
    Array<Any>& array = *(m_data->value.a);
    return array[i];
}
开发者ID:lsqtzj,项目名称:server,代码行数:7,代码来源:Any.cpp


示例8: debugAssert

uint32 BinaryInput::readBits(int numBits) {
    debugAssert(m_beginEndBits == 1);

    uint32 out = 0;

    const int total = numBits;
    while (numBits > 0) {
        if (m_bitPos > 7) {
            // Consume a new byte for reading.  We do this at the beginning
            // of the loop so that we don't try to read past the end of the file.
            m_bitPos = 0;
            m_bitString = readUInt8();
        }

        // Slide the lowest bit of the bitString into
        // the correct position.
        out |= (m_bitString & 1) << (total - numBits);

        // Shift over to the next bit
        m_bitString = m_bitString >> 1;
        ++m_bitPos;
        --numBits;
    }

    return out;
}
开发者ID:Blumfield,项目名称:ptc,代码行数:26,代码来源:BinaryInput.cpp


示例9: debugAssert

Any Entity::toAny() const {
    Any a = m_sourceAny;
    debugAssert(! a.isNil());
    if (a.isNil()) {
        // Fallback for release mode failure
        return a;
    }

    if (m_movedSinceLoad) {
        a["frame"] = m_frame;
    }

    const shared_ptr<SplineTrack>& splineTrack = dynamic_pointer_cast<SplineTrack>(m_track);
    if (notNull(splineTrack) && splineTrack->changed()) {
        // Update the spline
        const PhysicsFrameSpline& spline = splineTrack->spline();
        if (spline.control.size() == 1) {
            // Write out in short form for the single control point
            const PhysicsFrame& p = spline.control[0];
            if (p.rotation == Quat()) {
                // No rotation
                a["track"] = p.translation;
            } else {
                // Full coordinate frame
                a["track"] = CFrame(p);
            }
        } else {
            // Write the full spline
            a["track"] = spline;
        }
    }

    a.setName("Entity");
    return a;
}
开发者ID:jackpoz,项目名称:G3D-backup,代码行数:35,代码来源:Entity.cpp


示例10: getRootKeyFromString

bool RegistryUtil::writeInt32(const std::string& key, const std::string& value, int32 data) {
    size_t pos = key.find('\\', 0);
    if (pos == std::string::npos) {
        return false;
    }

    HKEY hkey = getRootKeyFromString(key.c_str(), pos);

    if (hkey == NULL) {
        return false;
    }

    HKEY openKey;
    int32 result = RegOpenKeyExA(hkey, (key.c_str() + pos + 1), 0, KEY_WRITE, &openKey);
    debugAssert(result == ERROR_SUCCESS || result == ERROR_FILE_NOT_FOUND);

    if (result == ERROR_SUCCESS) {
        result = RegSetValueExA(openKey, value.c_str(), 0, REG_DWORD, reinterpret_cast<const BYTE*>(&data), sizeof(int32));

        debugAssertM(result == ERROR_SUCCESS, "Could not write registry key value.");

        RegCloseKey(openKey);
    }
    return (result == ERROR_SUCCESS);
}
开发者ID:Akenyshka,项目名称:MythCore,代码行数:25,代码来源:RegistryUtil.cpp


示例11: reserveBytesWhenOutOfMemory

void BinaryOutput::reallocBuffer(size_t bytes, size_t oldBufferLen) {
    //debugPrintf("reallocBuffer(%d, %d)\n", bytes, oldBufferLen);

    size_t newBufferLen = (int)(m_bufferLen * 1.5) + 100;
    uint8* newBuffer = NULL;

    if ((m_filename == "<memory>") || (newBufferLen < MAX_BINARYOUTPUT_BUFFER_SIZE)) {
        // We're either writing to memory (in which case we *have* to try and allocate)
        // or we've been asked to allocate a reasonable size buffer.

        //debugPrintf("  realloc(%d)\n", newBufferLen);
        newBuffer = (uint8*)System::realloc(m_buffer, newBufferLen);
        if (newBuffer != NULL) {
            m_maxBufferLen = newBufferLen;
        }
    }

    if ((newBuffer == NULL) && (bytes > 0)) {
        // Realloc failed; we're probably out of memory.  Back out
        // the entire call and try to dump some data to disk.
        m_bufferLen = oldBufferLen;
        reserveBytesWhenOutOfMemory(bytes);
    } else {
        m_buffer = newBuffer;
        debugAssert(isValidHeapPointer(m_buffer));
    }
}
开发者ID:Xadras,项目名称:TBCPvP,代码行数:27,代码来源:BinaryOutput.cpp


示例12: needSwapBytes

BinaryInput::BinaryInput(
    const uint8*        data,
    int64               dataLen,
    G3DEndian           dataEndian,
    bool                compressed,
    bool                copyMemory) {

    beginEndBits = 0;
    bitPos = 0;
    alreadyRead = 0;
    bufferLength = 0;

    freeBuffer = copyMemory || compressed;

    this->fileEndian = dataEndian;
    this->filename = "<memory>";
    pos = 0;
    swapBytes = needSwapBytes(fileEndian);

    if (compressed) {
        // Read the decompressed size from the first 4 bytes
        length = G3D::readUInt32(data, swapBytes);

        debugAssert(freeBuffer);
        buffer = (uint8*)System::malloc(length);

        unsigned long L = length;
        // Decompress with zlib
        int64 result = uncompress(buffer, (unsigned long*)&L, data + 4, dataLen - 4);
        length = L;
        bufferLength = L;
        debugAssert(result == Z_OK);
        (void)result;

    } else {
        length = dataLen;
        bufferLength = length;
        if (! copyMemory) {
            debugAssert(!freeBuffer);
            buffer = const_cast<uint8*>(data);
        } else {
            debugAssert(freeBuffer);
            buffer = (uint8*)System::malloc(length);
            System::memcpy(buffer, data, dataLen);
        }
    }
}
开发者ID:luaman,项目名称:g3d-cpp,代码行数:47,代码来源:BinaryInput.cpp


示例13: BinaryOutput

void BinaryOutput::reserveBytesWhenOutOfMemory(size_t bytes) {
    if (m_filename == "<memory>") {
        throw "Out of memory while writing to memory in BinaryOutput (no RAM left).";
    } else if ((int)bytes > (int)m_maxBufferLen) {
        throw "Out of memory while writing to disk in BinaryOutput (could not create a large enough buffer).";
    } else {
        // Dump the contents to disk.  In order to enable seeking backwards,
        // we keep the last 10 MB in memory.
        int writeBytes = m_bufferLen - 10 * 1024 * 1024;

        if (writeBytes < m_bufferLen / 3) {
            // We're going to write less than 1/3 of the file;
            // give up and just write the whole thing.
            writeBytes = m_bufferLen;
        }
        debugAssert(writeBytes > 0);

        //debugPrintf("Writing %d bytes to disk\n", writeBytes);

        const char* mode = (m_alreadyWritten > 0) ? "ab" : "wb";
        FILE* file = FileSystem::fopen(m_filename.c_str(), mode);
        debugAssert(file);

        size_t count = fwrite(m_buffer, 1, writeBytes, file);
        debugAssert((int)count == writeBytes); (void)count;

        fclose(file);
        file = NULL;

        // Record that we saved this data.
        m_alreadyWritten += writeBytes;
        m_bufferLen -= writeBytes;
        m_pos -= writeBytes;

        debugAssert(m_bufferLen < m_maxBufferLen);
        debugAssert(m_bufferLen >= 0);
        debugAssert(m_pos >= 0);
        debugAssert(m_pos <= m_bufferLen);

        // Shift the unwritten data back appropriately in the buffer.
        debugAssert(isValidHeapPointer(m_buffer));
        System::memcpy(m_buffer, m_buffer + writeBytes, m_bufferLen);
        debugAssert(isValidHeapPointer(m_buffer));

        // *now* we allocate bytes (there should presumably be enough
        // space in the buffer; if not, we'll come back through this
        // code and dump the last 10MB to disk as well.  Note that the
        // bytes > maxBufferLen case above would already have triggered
        // if this call couldn't succeed.
        reserveBytes(bytes);
    }
}
开发者ID:16898500,项目名称:SkyFireEMU,代码行数:52,代码来源:BinaryOutput.cpp


示例14: debugAssert

void MeshAlg::debugCheckConsistency(
    const Array<Face>&      faceArray,
    const Array<Edge>&      edgeArray,
    const Array<Vertex>&    vertexArray) {

#ifdef _DEBUG
    for (int v = 0; v < vertexArray.size(); ++v) {
        const MeshAlg::Vertex& vertex = vertexArray[v];

        for (int i = 0; i < vertex.edgeIndex.size(); ++i) {
            const int e = vertex.edgeIndex[i];
            debugAssert(edgeArray[(e >= 0) ? e : ~e].containsVertex(v));
        }

        for (int i = 0; i < vertex.faceIndex.size(); ++i) {
            const int f = vertex.faceIndex[i];
            debugAssert(faceArray[f].containsVertex(v));
        }

    }

    for (int e = 0; e < edgeArray.size(); ++e) {
        const MeshAlg::Edge& edge = edgeArray[e];

        for (int i = 0; i < 2; ++i) {
            debugAssert((edge.faceIndex[i] == MeshAlg::Face::NONE) ||
                faceArray[edge.faceIndex[i]].containsEdge(e));

            debugAssert(vertexArray[edge.vertexIndex[i]].inEdge(e));
        }        
    }

    // Every face's edge must be on that face
    for (int f = 0; f < faceArray.size(); ++f) {
        const MeshAlg::Face& face = faceArray[f];
        for (int i = 0; i < 3; ++i) {
            int e = face.edgeIndex[i];
            int ei = (e >= 0) ? e : ~e;
            debugAssert(edgeArray[ei].inFace(f));

            // Make sure the edge is oriented appropriately 
            if (e >= 0) {
                debugAssert(edgeArray[ei].faceIndex[0] == (int)f);
            } else {
                debugAssert(edgeArray[ei].faceIndex[1] == (int)f);
            }

            debugAssert(vertexArray[face.vertexIndex[i]].inFace(f));
        }
    }
#else
    (void)faceArray;
    (void)edgeArray;
    (void)vertexArray;
#endif // _DEBUG
}
开发者ID:Sandshroud,项目名称:Sandshroud-Prodigy,代码行数:56,代码来源:MeshAlgAdjacency.cpp


示例15: debugAssert

void GThread::waitForCompletion() {
    if (m_status == STATUS_COMPLETED) {
        // Must be done
        return;
    }

#   ifdef G3D_WIN32
        debugAssert(m_event);
        ::WaitForSingleObject(m_event, INFINITE);
#   else
        debugAssert(m_handle);
        //printf("Before pthread_join\n"); // TODO: remove
        //printf("m_status = %d\n", m_status);
        pthread_join(m_handle, NULL);
        //printf("After pthread_join\n"); // TODO: remove
#   endif
}
开发者ID:A7med-Shoukry,项目名称:g3d,代码行数:17,代码来源:GThread.cpp


示例16: debugAssert

void VAR::vertexAttribPointer(uint attribNum, bool normalize) const {
	debugAssert(valid());
    if (GLCaps::supports_GL_ARB_vertex_program()) {
	    glEnableVertexAttribArrayARB(attribNum);
	    glVertexAttribPointerARB(attribNum, elementSize / sizeOfGLFormat(underlyingRepresentation),
                          underlyingRepresentation, normalize, elementSize, _pointer);
    }
}
开发者ID:Jekls,项目名称:PhantomCore,代码行数:8,代码来源:VAR.cpp


示例17: tinyFree

    void tinyFree(void* ptr) {
        debugAssert(tinyPoolSize < maxTinyBuffers);

        // Put the pointer back into the free list
        tinyPool[tinyPoolSize] = ptr;
        ++tinyPoolSize;

    }
开发者ID:arcticdev,项目名称:arctic-test,代码行数:8,代码来源:System.cpp


示例18: debugAssert

void Box::init(
    const Vector3& min,
    const Vector3& max) {

    debugAssert(
        (min.x <= max.x) &&
        (min.y <= max.y) &&
        (min.z <= max.z));

    setMany(0, 1, 2, 3, z, max);
    setMany(4, 5, 6, 7, z, min);

    setMany(1, 2, 5, 6, x, max);
    setMany(0, 3, 4, 7, x, min);

    setMany(3, 2, 6, 7, y, max);
    setMany(0, 1, 5, 4, y, min);

    _extent = max - min;

    _axis[0] = Vector3::unitX();
    _axis[1] = Vector3::unitY();
    _axis[2] = Vector3::unitZ();

    if (_extent.isFinite()) {
        _volume = _extent.x * _extent.y * _extent.z;
    } else {
        _volume = G3D::finf();
    }

    debugAssert(! isNaN(_extent.x));

    _area = 2 *
        (_extent.x * _extent.y +
         _extent.y * _extent.z +
         _extent.z * _extent.x);

    _center = (max + min) * 0.5f;

    // If the extent is infinite along an axis, make the center zero to avoid NaNs
    for (int i = 0; i < 3; ++i) {
        if (! G3D::isFinite(_extent[i])) {
            _center[i] = 0.0f;
        }
    }
}
开发者ID:Gigelf,项目名称:Infinity_Core,代码行数:46,代码来源:Box.cpp


示例19: beforeRead

	void Any::set(const std::string& k, const Any& v) {
		beforeRead();
		v.beforeRead();
		verifyType(TABLE);
		debugAssert(m_data != NULL);
		Table<std::string, Any>& table = *(m_data->value.t);
		table.set(k, v);
	}
开发者ID:lev1976g,项目名称:easywow,代码行数:8,代码来源:Any.cpp


示例20: debugAssert

void SDLWindow::notifyResize(int w, int h) {
    debugAssert(w > 0);
    debugAssert(h > 0);
    _settings.width = w;
    _settings.height = h;

	// Mutate the SDL surface (which one is not supposed to do).
	// We can't resize the actual surface or SDL will destroy
	// our GL context, however.
	SDL_Surface* surface = SDL_GetVideoSurface();
	surface->w = w;
	surface->h = h;
	surface->clip_rect.x = 0;
	surface->clip_rect.y = 0;
	surface->clip_rect.w = w;
	surface->clip_rect.h = h;
}
开发者ID:luaman,项目名称:g3d-cpp,代码行数:17,代码来源:SDLWindow.cpp



注:本文中的debugAssert函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ debugAssertM函数代码示例发布时间:2022-05-30
下一篇:
C++ debug4函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap