POV-Ray : Newsgroups : povray.off-topic : Unit testing - simple question with long explanation for discussion... : Re: Unit testing - simple question with long explanation for discussion... Server Time
6 Sep 2024 11:17:56 EDT (-0400)
  Re: Unit testing - simple question with long explanation for discussion...  
From: Invisible
Date: 8 Jan 2009 07:22:42
Message: <4965f012$1@news.povray.org>
Darren New wrote:
> Orchid XP v8 wrote:
>> I'm currently trying to implement a PostScript interpretter. Do you 
>> have *any idea* how non-trivial it is to come up with good tests which 
>> cover all possible corner-cases? Do you have any idea how you verify 
>> what the "correct" result is even supposed to be? 
> 
> I don't think that's "unit tests", tho.

Depends what you test.

> Normally, a "unit test" covers 
> what would normally be one class, and not a whole operation.

Again, depends what you test.

> I can 
> imagine lots of tests for a postscript parser: The string "one two 
> three" parses into three words, the word "three" winds up on top of the 
> stack, that "1.0" parses as a number but "1X0" doesn't, etc.

That's the kind of thing I'm trying to do. Except that figuring out 
every possible case is surprisingly hard.

In particular, there is a user-level function available to take a string 
and parse the first token off of it, and the PostScript language spec 
stipulates exactly how much of the input should be gobbled up. A small 
number of PS programs might actually rely on this precise behaviour, so 
you have to get it exactly right.

I'm having difficulty figuring out a way to really thoroughly check that 
this works properly. Seemingly you'd need a really big stack of test 
cases, but how do you generate those? (And how do you figure out what 
the "correct" answer is? This is sometimes non-obvious.)

When/if I get to the point of actually executing stuff, that'll be a 
whole *other* picnic!


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.