CS 4448 - Spring 1998
Object-Oriented Programming and Design
Talk 11.2.1
by
Tao He

Code that Tests Itself
by
Charles Weir
- Definitions:
- Assertion
- pre- and postconditions
- invariants
- Requirements for implementing assertions
- compiling assertions must be optional
- if an assertion is false at any point, we need to get as much information as possible about the problem
- if someone accidentally produces code that relies on an assertion being the function call it looks like, then code will continue to work similarly, even if the assertion is compiled out
- Use assert() macro or your own ASSERT() function
- How to use assertions
- Do NOT use assertions to handle errors that may occur in the final system
- Requirements for implementing invariants
- inheritance
- virtual
- compiled out
- constant
- When to check invariant
- How to deal with exceptions
- An example that demonstrates the implementation of assertions
Copyright © University of Colorado. All rights reserved.
Revised: April 14, 1998