Improve Your Programming with Asserts
By Bruce D. Rosenblum
Dr. Dobb's Journal December 1997
(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 3: Do not assert FALSE. Do not use (a), use (b) instead. If you have a switch statement that has no default case, it should be unconditionally asserted like (c).
Copyright © 1997, Dr. Dobb's Journal