How do we test the following function?
bits(bitstring, i, j)
which returns a copy of the substring from
j of some
Consider the fixed 32-bit value:
We could manually pre-determine the correct return values for ~500 different combinations of
j. But this only covers
There are 232 ≈ 4 billion different strings like
Even for a non-exhaustive test, manually recording the constants we expect to get from any combination of (
j) does not seem like the best solution.
I imagine we can use the fact that bit strings map to unsigned integers and do some arithmetic to compare the return value of
Any help with vocabulary or classifying this validation problem would be appreciated, too.
Technical side note: My uncertainty lies in whether the bit manipulations are being performed correctly, since the bit substring does not necessarily begin or end on a byte boundary.
Another note: After a few edits I have realized the important question here is what are the different ways we can check that one bit string is a substring of another? But the original question has a broader scope so I will leave it as it is.