[Lula] Intermediate C class in the LA area?
Jesse W
jessw at netwood.net
Mon Jul 30 20:37:16 EDT 2007
On Jul 30, 2007, at 1:58 PM, Dan Kegel wrote:
> On 7/28/07, Jesse W <jessw at netwood.net> wrote:
>> However, I am now throughly stuck regarding exercise 5.11, which asks
>> for a tabs-to-spaces (and reverse) program that takes a list of tab
>> stops as an argument. What I'm stuck on is trying to figure out how
>> to
>> test it properly.
>
> Write test code like this:
> create test input file and redirect stdin from it
> capture stdout
> run your function
> assert that it has the desired output exactly
>
> You might create a struct containing one input string and expected
> output string,
> then create an array of those, and run through all the test cases in a
> loop.
I understand that framework well enough -- what I'm stuck on is
deciding what permutations would be necessary to test. The ones I've
come up with so far are:
(Starting string -> entabed <- detabed ) (if entabing and detabing give
the same, use <->)
1) empty string <-> empty string.
2) no tabs or spaces or newlines <-> same string
3) newlines, but no tabs or spaces <-> same string
4) one tab <-> as many spaces as the first tab stop
5) two tabs <-> the sum of the first two tab stops expressed as spaces
6) a space, followed by a tab -> as many spaces as the first tab stop
<- one tab (as long as the first tab stop is more than 1)
and that's where I get lost -- what other combinations should I test?
Some combinations are invertable (i.e. if ~/foo contains the input
text, then cat ~/foo | ./entab | ./detab | cmp - ~/foo is true), and
others are not (like the last one I listed) -- I suppose I need to test
both kinds... Also, there are various pathological tab stop lists I
should examine... I get lost.
I think the code I have works *some of the time* -- it's those last few
cases I can't figure out how to get a handle on...
Jesse Weinstein
More information about the Lula
mailing list