Split wxPersistenceManager-related tests and actually build them

It seems better to organize the tests in different files and just
provide a common fixture-like class to reuse functionality.

Also use this as an opportunity to rewrite the tests to use Catch
directly instead of using CppUnit-compatible macros.

Finally, actually build these tests as part of the test suite.
This commit is contained in:
Vadim Zeitlin
2017-12-15 00:43:24 +01:00
parent 4e82f60b8a
commit 036870ab35
14 changed files with 328 additions and 230 deletions

View File

@@ -0,0 +1,45 @@
///////////////////////////////////////////////////////////////////////////////
// Name: tests/persistence/testpersistence.h
// Purpose: Fixture for wxPersistentObject unit tests
// Author: wxWidgets Team
// Created: 2017-08-23
// Copyright: (c) 2017 wxWidgets Team
///////////////////////////////////////////////////////////////////////////////
#ifndef WX_TESTS_PERSIST_TESTPERSISTENCE_H
#define WX_TESTS_PERSIST_TESTPERSISTENCE_H
#include "wx/app.h"
#include "wx/config.h"
#define PO_PREFIX "/Persistent_Options"
class PersistenceTests
{
public:
PersistenceTests()
: m_cleanup(false)
{
wxTheApp->SetAppName("wxPersistenceTests");
}
// The tests using this fixture should call this method when they don't
// need the values saved into wxConfig any more.
void EnableCleanup()
{
m_cleanup = true;
}
~PersistenceTests()
{
if ( m_cleanup )
{
wxConfig::Get()->DeleteGroup(PO_PREFIX);
}
}
private:
bool m_cleanup;
};
#endif // WX_TESTS_PERSIST_TESTPERSISTENCE_H