Hi,
I use a *lot* of invariants in my code. Some are there just during development; others "ride shotgun" over the code at run-time.
So, a lot of my formal testing is concerned with verifying these tings *can't* happen *and*, verifying the intended remedy when they *do*!
I'm looking for a reasonably portable (in the sense of "not toolchain dependant") way of presenting these regression tests that won't require the scaffolding that I particularly use.
For example, some structures (not "structs") that I enforce may not be possible to create *in* a source file. For these, I create "initializers" that actively build a nonconforming image prior to unleashing the code-under-test. If written correctly, the code being tested *should* detect the "CAN'T HAPPEN" conditions represented in that image and react accordingly (of course, this differs from the production run-time behavior as I *want* to see its results).
I can't see any other flexible way of doing this that wouldn't rely on knowing particulars of the compiler and target a priori.
Or, do folks just not *test* these sorts of things (formally)?