2018-02-06 15:33:45 +01:00
|
|
|
|
|
|
|
// Test library configuration for windows.cfg
|
|
|
|
//
|
|
|
|
// Usage:
|
|
|
|
// $ cppcheck --check-library --library=windows --enable=information --error-exitcode=1 --inline-suppr --suppress=missingIncludeSystem test/cfg/windows.cpp
|
|
|
|
// =>
|
|
|
|
// No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0
|
|
|
|
//
|
|
|
|
|
2018-02-09 20:34:15 +01:00
|
|
|
#include <wx/app.h>
|
|
|
|
#include <wx/log.h>
|
2018-02-06 15:33:45 +01:00
|
|
|
#include <wx/filefn.h>
|
2018-02-09 20:34:15 +01:00
|
|
|
#include <wx/spinctrl.h>
|
|
|
|
#include <wx/artprov.h>
|
|
|
|
#include <wx/calctrl.h>
|
|
|
|
#include <wx/combo.h>
|
|
|
|
#include <wx/icon.h>
|
|
|
|
#include <wx/bitmap.h>
|
2018-02-06 15:33:45 +01:00
|
|
|
|
|
|
|
void validCode()
|
|
|
|
{
|
|
|
|
wxString str = wxGetCwd();
|
|
|
|
|
|
|
|
wxLogGeneric(wxLOG_Message, "test %d", 0);
|
|
|
|
wxLogMessage("test %s", "str");
|
|
|
|
|
|
|
|
wxString translation1 = _("text");
|
|
|
|
wxString translation2 = wxGetTranslation("text");
|
|
|
|
wxString translation3 = wxGetTranslation("string", "domain");
|
|
|
|
}
|
|
|
|
|
2018-02-09 20:34:15 +01:00
|
|
|
#if wxUSE_GUI==1
|
|
|
|
void validGuiCode()
|
|
|
|
{
|
|
|
|
#if wxUSE_SPINCTRL==1
|
|
|
|
extern wxSpinCtrl spinCtrlInstance;
|
|
|
|
spinCtrlInstance.SetBase(10);
|
|
|
|
spinCtrlInstance.SetBase(16);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2018-02-06 15:33:45 +01:00
|
|
|
void nullPointer()
|
|
|
|
{
|
|
|
|
// cppcheck-suppress nullPointer
|
2018-02-09 20:34:15 +01:00
|
|
|
wxLogGeneric(wxLOG_Message, (char*)NULL);
|
2018-02-06 15:33:45 +01:00
|
|
|
// cppcheck-suppress nullPointer
|
2018-02-09 20:34:15 +01:00
|
|
|
wxLogMessage((char*)NULL);
|
2018-02-06 15:33:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void ignoredReturnValue()
|
|
|
|
{
|
|
|
|
// cppcheck-suppress ignoredReturnValue
|
|
|
|
wxGetCwd();
|
|
|
|
}
|
|
|
|
|
|
|
|
void invalidFunctionArg()
|
|
|
|
{
|
2018-02-09 20:34:15 +01:00
|
|
|
#if wxUSE_SPINCTRL==1
|
|
|
|
extern wxSpinCtrl spinCtrlInstance;
|
2018-02-06 15:33:45 +01:00
|
|
|
// cppcheck-suppress invalidFunctionArg
|
2018-02-09 20:34:15 +01:00
|
|
|
spinCtrlInstance.SetBase(0);
|
2018-02-06 15:33:45 +01:00
|
|
|
// cppcheck-suppress invalidFunctionArg
|
2018-02-09 20:34:15 +01:00
|
|
|
spinCtrlInstance.SetBase(5);
|
|
|
|
#endif
|
2018-02-06 15:33:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void uninitvar()
|
|
|
|
{
|
|
|
|
wxLogLevel logLevelUninit;
|
|
|
|
char cBufUninit[10];
|
|
|
|
char *pcUninit;
|
|
|
|
// cppcheck-suppress uninitvar
|
|
|
|
wxLogGeneric(logLevelUninit, "test");
|
|
|
|
// cppcheck-suppress uninitvar
|
|
|
|
wxLogMessage(cBufUninit);
|
|
|
|
// cppcheck-suppress uninitvar
|
|
|
|
wxLogMessage(pcUninit);
|
|
|
|
}
|
2018-02-07 11:40:42 +01:00
|
|
|
|
2018-02-07 13:33:15 +01:00
|
|
|
void deprecatedFunctions(wxApp &a, const wxString &s, wxArtProvider *artProvider, wxCalendarCtrl &calenderCtrl, wxComboCtrl &comboCtrl)
|
2018-02-07 11:40:42 +01:00
|
|
|
{
|
2018-02-09 20:34:15 +01:00
|
|
|
#ifdef __WXOSX__
|
2018-02-07 11:40:42 +01:00
|
|
|
// cppcheck-suppress MacOpenFileCalled
|
|
|
|
a.MacOpenFile(s);
|
2018-02-09 20:34:15 +01:00
|
|
|
#endif
|
2018-02-11 16:58:39 +01:00
|
|
|
|
|
|
|
#if wxCHECK_VERSION(3, 1, 0) // wxWidets-3.1.0 or higher:
|
|
|
|
// Some functions are not available anymore in newer versions
|
|
|
|
|
|
|
|
// @todo cppcheck-suppress ShowPopupCalled
|
|
|
|
comboCtrl.ShowPopup();
|
|
|
|
#else
|
2018-02-07 11:40:42 +01:00
|
|
|
// cppcheck-suppress InsertCalled
|
|
|
|
wxArtProvider::Insert(artProvider);
|
2018-02-11 16:58:39 +01:00
|
|
|
|
|
|
|
// cppcheck-suppress GetTextIndentCalled
|
|
|
|
// cppcheck-suppress ignoredReturnValue
|
|
|
|
comboCtrl.GetTextIndent();
|
|
|
|
|
|
|
|
// cppcheck-suppress HidePopupCalled
|
|
|
|
comboCtrl.HidePopup(true);
|
|
|
|
// cppcheck-suppress HidePopupCalled
|
|
|
|
comboCtrl.HidePopup(false);
|
|
|
|
// cppcheck-suppress HidePopupCalled
|
|
|
|
comboCtrl.HidePopup(/*default=false*/);
|
|
|
|
|
|
|
|
// cppcheck-suppress SetTextIndentCalled
|
|
|
|
comboCtrl.SetTextIndent(0);
|
|
|
|
#endif
|
|
|
|
|
2018-02-09 20:34:15 +01:00
|
|
|
#if defined(__WXMSW__) || defined(__WXGTK__)
|
|
|
|
// EnableYearChange() is not available on these GUI systems
|
|
|
|
#else
|
2018-02-07 13:33:15 +01:00
|
|
|
// cppcheck-suppress EnableYearChangeCalled
|
|
|
|
calenderCtrl.EnableYearChange(false);
|
|
|
|
// cppcheck-suppress EnableYearChangeCalled
|
2018-02-11 16:58:39 +01:00
|
|
|
calenderCtrl.EnableYearChange(true);
|
|
|
|
// cppcheck-suppress EnableYearChangeCalled
|
2018-02-07 13:33:15 +01:00
|
|
|
calenderCtrl.EnableYearChange(/*default=yes*/);
|
2018-02-09 20:34:15 +01:00
|
|
|
#endif
|
2018-02-07 11:40:42 +01:00
|
|
|
}
|