The method was implementated as:
def check_representation(self):
"""
Checks that the internal representation is correct.
:raise: AssertionError if an error is found.
"""
for attribute in (self.max, self.head, self.size):
assert attribute >= 0, "{0} shouldn't be negative. ({1})".format(attribute, str(self))
assert ((self.head + self.size) % self.max == self.tail), str(self)
return
Notes
- This is for the fixed-size queue used in udacity's Software Testing class
- Since the second assertion checks an equation where the tail can never be negative if all the left-hand terms are positive, the tail isn't checked to see if it's positive