From 64f7c232720e5240eba2a774ed437b432b5d67b2 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 20 Aug 2021 16:50:40 +0100 Subject: [PATCH] Add unit test for wxTextCtrl::EmptyUndoBuffer() Check that calling it results in CanUndo() returning false and really prevents Undo() from working. --- tests/controls/textctrltest.cpp | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/tests/controls/textctrltest.cpp b/tests/controls/textctrltest.cpp index 7098df48f8..d2dbc53222 100644 --- a/tests/controls/textctrltest.cpp +++ b/tests/controls/textctrltest.cpp @@ -1472,4 +1472,35 @@ TEST_CASE("wxTextCtrl::InitialCanUndo", "[wxTextCtrl][undo]") } } +// This test would always fail with MinGW-32 for the same reason as described +// above. +#ifndef __MINGW32_TOOLCHAIN__ + +TEST_CASE("wxTextCtrl::EmptyUndoBuffer", "[wxTextCtrl][undo]") +{ + wxScopedPtr text(new wxTextCtrl(wxTheApp->GetTopWindow(), + wxID_ANY, "", + wxDefaultPosition, + wxDefaultSize, + wxTE_MULTILINE | wxTE_RICH2)); + + text->AppendText("foo"); + + if ( !text->CanUndo() ) + { + WARN("Skipping test as Undo() is not supported on this platform."); + return; + } + + text->EmptyUndoBuffer(); + + CHECK_FALSE( text->CanUndo() ); + + CHECK_NOTHROW( text->Undo() ); + + CHECK( text->GetValue() == "foo" ); +} + +#endif // __MINGW32_TOOLCHAIN__ + #endif //wxUSE_TEXTCTRL