On Monday, 21 May 2018 at 17:03:40 UTC, Russel Winder wrote:
On Mon, 2018-05-21 at 15:16 +0000, Atila Neves via Digitalmars-d-learn wrote:
On Friday, 18 May 2018 at 15:16:52 UTC, Russel Winder wrote:
> Hi,
> > What's the current official position on how to create > temporary files for use during a unittest. I found

Not official, but...

     import unit_threaded;

     with(const Sandbox()) {
         writeFile("myfile.txt", "contents");
         shouldExist("myfile.txt");
         shouldEqualContent("myfile.txt", "contents");
         fileShouldContain("myfile.txt", "cont");
     }

Atila

OK, we like this. A lot.

:)

Given I use Unit-Threaded, why did I not know this. Ah, OK, RTFM. :-)

It's got so many features that I don't know how to document everything and make it accessible at the same time.

Did I mention how much I like this RAII approach?

Me too - RAII is definitely C++'s gift to the world. I've been abusing `with` lately quite a bit. I think it's underused.


Reply via email to