Don't leave temporary files after running "Load" unit test

This test created temporary files but never deleted them.

Fix this by using TestFile helper class, which also simplifies the test
code.
This commit is contained in:
Vadim Zeitlin
2025-09-13 15:42:13 +02:00
parent b80da783a1
commit 9886f14fdb
+4 -9
View File
@@ -12,6 +12,8 @@
#include "testprec.h"
#include "testfile.h"
#include "wx/filename.h"
#include "wx/image.h"
@@ -146,17 +148,10 @@ TEST_CASE("Load", "[garbage]")
data[i] = rand();
// write it to a file
wxString garbagename = wxFileName::CreateTempFileName("garbage");
CHECK(!garbagename.empty());
wxFile garbage(garbagename, wxFile::write);
CHECK(garbage.IsOpened());
CHECK(garbage.Write(data, size) == size);
garbage.Close();
TestFile tf(data, size);
// try to load it by name
DoLoadGarbageFile(garbagename);
DoLoadGarbageFile(tf.GetName());
// try to load it from a wxInputStream
wxMemoryInputStream stream(data, size);