+ Reply to Thread
Results 1 to 2 of 2

Thread: What is ASSERT and how it is useful?

  1. #1
    Junior Member
    Join Date
    Feb 2012
    Posts
    49

    What is ASSERT and how it is useful?

    Hi All,

    What is ASSERT and how it is useful?

    How it is different than VERIFY?

    Regards.

  2. #2
    Hi,

    ASSERT works in Debug mode only.
    ASSERT evaluates an expression specified it as an argument. If it is false then it asserts an message to User while Debugging.

    Please note that ASSERT does not work in Release mode.

    This is where VERIFY comes in picture. VERIFY works in both Debug and Release modes.

    Following is the example:

    Code:
    void UseAssert()
    {
    	ASSERT( -1 >= 0) ;
    
    	char *pPointer = new char[10] ;
    
    	ASSERT(pPointer != NULL) ; 
    
    	delete pPointer ;
    	pPointer = NULL ;
    
    	ASSERT(pPointer != NULL) ; 
    
    	char *pVerify = NULL ;
    	//this works in both debug and release modes.
    	//please note that you should **not** use ASSERT here else in release build, pVerify will always be NULL! 
    	VERIFY( (pVerify = new char[10]) != NULL) ;
    
    	delete pVerify ;
    	pVerify = NULL ;
    }
    Regards.

+ Reply to Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts