News for hackers. Stuff that matters.
Re:How to write unit tests in C++ relying on non-code files? by cgh on Thursday February 22, 2024 @11:00PM (#39476801)
Java has in-memory file systems that are essentially geared for this exact use case, eg jimfs[0]. You create your filesystem and any files you need when your tests are starting up, and your classes talk to them rather than the “real” ones. Maybe a similar project exists for the C++ ecosystem?

[0] https://github.com/google/jimfs

Re:How to write unit tests in C++ relying on non-code files? by seeknotfind on Friday February 23, 2024 @12:49AM (#39477401)
You can use FUSE :)
Re:How to write unit tests in C++ relying on non-code files? by vardump on Friday February 23, 2024 @08:49AM (#39480525)
Sadly, FUSE is far from fast.

Great for quick fixes though, it's crazy to be able to locally mount a disk image that sits on the other side of the world on an HTTP server.

Re:How to write unit tests in C++ relying on non-code files? by seeknotfind on Friday February 23, 2024 @08:29PM (#39488298)
As far as it's ability as an FS mocking layer for tests, I'd think its principle disadvantage would be on FUSE only making sense on UNIX-like systems.