On 27/11/2017 03:04, Michael Torrie wrote:
On 11/26/2017 08:39 AM, bartc wrote:
The problem was traced to two lines that were in the wrong order (in the
original program). I can't see how unit tests can have helped in any way
at all, and it would probably have taken much longer.

What makes you think that?  Surely other decoders were doing the right
thing and you could compare your output against theirs?  JPEGs may be
lossy but the path through the decoder should be deterministic.

Or even if every decoder is slightly unique, at least yours should
output self-consistent data.

The original used some floating point code, I changed that to use integer code (eg a combination of multiplying and shifting; it make a difference on compiled version, perhaps not so much in .py).

But also (IIRC) there was a difference in taking the remainder of negative integer division, where different compilers may round up or down.

So there can easily be differences when compared at the binary level, but which shouldn't be noticeable with the human eye.

(https://pastebin.com/P7V1Bvkk
https://pastebin.com/raw/P7V1Bvkk  raw version with no ads, or colour)

 In other words, once you know you fixed
the chroma problem, you can use that jpeg as a unit test to make sure
future big fixes and enhancements don't break something else.
Regression testing is very important. Many times I've fixed a bug, only
to introduce new ones that broke formerly correct behavior.

Anyway, unit testing is certainly a challenging concept, and I'm no more
good at it than you are.

Some people are obsessed with having unit tests. Others are the same about using debuggers, especially in compiled code.

I've never used either, but I do alright. Some of the stuff I do is unsuitable for those for technical reasons, but also some of the problems I've come across just don't fit into such patterns.

People should use what works best for them, unless they're in a team where the have to use certain tools and working methods.


--
bartc
--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to