assert(«CONDITION») - Check that CONDITION is true. - If not, stop (crash gracefully) and report error immediately. - CONDITION must be true if *your code* is correct. - Do not use this for checking if someone else's code called your code correctly. - Do not use this to check a file exists. - Do not use this to check if the system is working properly and in a good state. - assert(…) lets you write code that tests itself. - assert(…) documents what you believe to be true in a dependable way. - Try to write the CONDITION to be clear and understandable. - Use this with sanity checks. - Not a substitute for regular testing. - Occassionally, I may use assert(…) for testing learning examples. - If CONDITION is false, then you know that *your code* has a *bug*. - "bug" means the programmer made a mistake. - "error" means something unexpected happened that interrupted the desired behavior. - ex: file not found - ex: someone else called our code incorrectly