Testing code is fun and hard and looking at the problem in different ways is always good. Here’s a picture representing the behavior of a saturating subtraction operation, where the horizontal axes represent the inputs and the output is vertical:
And here are some of the functions handed in by my students in the fall:
The last one represents one of the most common failure modes: failing to account for the asymmetry where INT_MIN has no additive inverse. The thing that I like about these images is how glaringly obvious the bugs are.
Hey, who knew Gnuplot could do animated gifs now? I guess old dogs can learn new tricks.
(Note: I posted some of these a few years ago, but I like the pictures so much I wanted to do it again.)