[Help] What is the best way to compare two forms for a sunit test?

Andreas Raab andreas.raab at gmx.de
Mon Mar 5 07:46:48 UTC 2007


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.
> 
> For each sample in the test I can get a form. Reduce
> it to the smallest meaningful depth. So the next step
> is to encode it into something that can be returned by
> a method and compared with (what is hopefully) the
> same form generated by the test.
> 
> What is the best way to do this?
> 
> I can anticipate this testing method coming up again.
> 
> It would be nice to automate the "encode it into a
> method" part. At least to the point where I had
> something that wrote the method (or most of it) into a
> code holder or some text buffer I could copy.
> 
> For testing purposes it would be sufficient to test
> the compressed forms (or even suitable hashes maybe).
> Just as long as I could have confidence that the two
> pictures matched.
> 
> I figure someone out there has probably tackled this
> problem before so I am hoping to avoid reinventing the
> wheel.
> 
> Yours in curiosity and service, --Jerome Peace
> 
> 
> 
> 
>  
> ____________________________________________________________________________________
> Do you Yahoo!?
> Everyone is raving about the all-new Yahoo! Mail beta.
> http://new.mail.yahoo.com
> 
> 




More information about the Squeak-dev mailing list