Thread overview | |||||
---|---|---|---|---|---|
|
April 28, 2007 Unit tests for I/O functions | ||||
---|---|---|---|---|
| ||||
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? |
April 28, 2007 Re: Unit tests for I/O functions | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jason House | 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.
|
April 28, 2007 Re: Unit tests for I/O functions | ||||
---|---|---|---|---|
| ||||
Posted in reply to BCS | 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);
}
|
Copyright © 1999-2021 by the D Language Foundation