-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
More comprehensive tests against any assumption of zeroed arrays.
We use a test-only macro to insert a non-zero initial value that changes with each invocation. So, any reliance on a zeroed input array would manifest as different results across repeated calls in the test suite. In effect, all tests are now checking against "dirty" input buffers, eliminating the need for dedicated tests with less coverage.
- Loading branch information
Showing
9 changed files
with
84 additions
and
128 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#ifndef UTILS_H | ||
#define UTILS_H | ||
|
||
// This generates a different initial value for each vector() that might store results. | ||
// The aim is to check that our functions ignore the initial contents of each output array. | ||
// Otherwise, we might miss subtle bugs from an incorrect assumption of default-initialized contents. | ||
// We make the values vary across calls rather than using a constant, | ||
// as this allows us to catch bugs via tests that check for consistency between calls. | ||
inline int initial_value() { | ||
static int counter = 0; | ||
if (counter == 255) { | ||
counter = 1; | ||
} else { | ||
++counter; | ||
} | ||
return counter; | ||
} | ||
|
||
#endif |