Compare a tool result with an independent reference
Check the computed SHA-256 hash against a fixed reference for abc.
Check the computed SHA-256 hash against a fixed reference for abc. Replacing the first digit makes the comparison fail. Testing the changed value confirms that the check can detect this error.
Work through the example
Equality requires all 64 hexadecimal digits to match. One changed digit is sufficient to fail.
Run the example as a separate Python file. The inputs are synthetic so you can change them and see exactly which assumption affects the result.
Run the example
import hashlib
expected = "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad"
actual = hashlib.sha256(b"abc").hexdigest()
print(actual == expected)
print(("0" + actual[1:]) == expected)
Expected output
True
False
Reference: https://docs.python.org/3/library/hashlib.html
The team guide · My original notes on testing coding agents · Working with Lightbulb Partners