Hi!

I wrote a text parser that takes a File argument and parses that file's contents. Now I would like to write a unit-test for that parser. I need a File (or a general IO interface) that reads from an in-memory buffer, similar to python's `StringIO` or go's `strings.Reader`.

How can I achieve that?

Example of what I have in mind:

```d
unittest {
    string fakeContents = "foo\nbar\nbaz";
    File f = createFileFromString(fakeContents);
    assert(myParse(f) == MyParsedObject(...));
}
```

Reply via email to