Improve Your Programming with Asserts by Bruce D. Rosenblum Example 1: (a) h = GlobalAlloc(size_t, flags); ASSERT(h != NULL, "Allocation failed"); (b) m_pBtn = new CButton (); ASSERT(m_pBtn != NULL, "Button not instantiated"); Example 2: m_bmpSplash.LoadDIBitmap ( IDB_SPLASH ); ASSERT( m_bmpSplash != NULL, "Bitmap not loaded"); Example 3: (a) if ( m_hinst == NULL ) ASSERT( FALSE, "Null Handle"); (b) ASSERT( m_hinst != NULL, "Null Handle"); (c) switch ( i ) { case 1: DoSomething (); break; case 2: DoSomething2 (); break; default: ASSERT ( FALSE, "Unknown switch case" ); } Example 4: (a) VERIFY((z = x * y) < kMaxValue); (b) z = x * y; ASSERT( z < kMaxValue, "z exceeds valid limit"); 1