digitalmars.D.learn - Unit tests for I/O functions
- Jason House (4/4) Apr 27 2007 If I have a class that reads from an InputStream and writes to an
- BCS (2/7) Apr 27 2007 that's what I do.
- Jason House (18/29) Apr 28 2007 So far, I haven't had any success with the unit tests even though the
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?
Apr 27 2007
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.
Apr 27 2007
BCS wrote:Reply to Jason,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); }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.
Apr 28 2007