On 2012-03-09 15:08:42 +0000, bearophile said:

Magnus Lie Hetland:

It seems that File has no method for reading the entire file contents into a string, so I'd have to read and concatenate lines or chunks or something?

There are std.file.read() and std.file.readText().

Yeah, I found those. I guess my post was a bit verbose, but the main point was that I have a File object, but no file name (because I'm using std.stdio.tmpfile() in a unit test), so std.file.read() and std.file.readText() are useless to me... :)

But I agree that std.stdio.File should have a readAll() method
:-) If you think this is a good idea, add it to Bugzilla.

Sure.

For now, though: What's The Way[TM] to write unit tests for code that writes to files? Use tmpfile and read/concatenate the file contents myself? Something else that's more practical? (I would have thought this kind of test would be common?-)

--
Magnus Lie Hetland
http://hetland.org

Reply via email to