Unit tests for I/O functions
Jason House
jason.james.house at gmail.com
Sat Apr 28 11:50:33 PDT 2007
BCS wrote:
> Reply to Jason,
>
>> If I have a class that reads from an InputStream and writes to an
>> OutputStream, what is the recommended method for writing a unit test
>> for sending commands in one stream and testing its output of the other
>> stream? Would a pair of MemoryStream's be most appropriate?
>>
>
> that's what I do.
>
>
So far, I haven't had any success with the unit tests even though the
normal usage works fine...
The thread's run function has something to the effect of:
while(1){
char[] command = inStream.readLine();
process(command);
}
It seems that readLine does not block with a memoryStream like it does
with din and dout. What's the best work around?
PS: I tried the following but had no luck. process(command) never got
called after the unit test wrote to the stream (with writefln):
while(1){
char[] command = inStream.readLine();
if (command.length == 0)
continue;
process(command);
}
More information about the Digitalmars-d-learn
mailing list