[Help] What is the best way to compare two forms for a sunit test?
Hi Andreas,
Thanks for your help. Very informatiive.
I think it turned out a little more than I needed for the purpose I had in mind. My problem was how to store something to compare with the graphic forms generated on the fly. Since the test had control of the size and depth of the generated form, I settled for storing the hashes of the bits for each form generated. If they match nothing has changed and the test is green. If they don't then the examples need to be visually inspected which will point to whether the problem is with the testee or the test. If the testee passes the original visual test then the test can be fixed by simply creating new hashes. And of course looking into what changed to cause the testing to fail.
I am not sure how the bit hashes will fare across platforms but that will have to be faced when it happens. Generating platform specific hashes is always a possibility.
Thanks again for your reply. I'm sure I will find a good use for the information.
Yours in curiosity and service, -- Jerome Peace
***
Andreas Raab andreas.raab at gmx.de Mon Mar 5 07:46:48 UTC 2007 replied:
Combination rule 32 (RGB diff) which counts the
number
of differing pixels in two forms is your friend. For example:
(BitBlt toForm: Display)
sourceForm: Display; combinationRule: 32; copyBits.
will answer zero (no difference, since it's the
same
form). One caveat though: This only works for >=16bpp; if you need
less
than you may have to look at rule 22 which is a bit tricky since it
does
not clip properly (but it may still be good enough for your
purposes).
Cheers, - Andreas
Jerome Peace wrote:
I have some code for which I have created
graphical
tests .
These tests will produce a picture that looks
right
when the code is working.
Now I want to (as lazily as possible) create unit tests to prove the code and get it past the
release
team watch dogs.
____________________________________________________________________________________ Do you Yahoo!? Everyone is raving about the all-new Yahoo! Mail beta. http://new.mail.yahoo.com
squeak-dev@lists.squeakfoundation.org