diff --git a/tests/controls/spinctrldbltest.cpp b/tests/controls/spinctrldbltest.cpp index 1d31f10798..7416423881 100644 --- a/tests/controls/spinctrldbltest.cpp +++ b/tests/controls/spinctrldbltest.cpp @@ -224,4 +224,38 @@ void SpinCtrlDoubleTestCase::Digits() CPPUNIT_ASSERT_EQUAL(5, m_spin->GetDigits()); } +static inline unsigned int GetInitialDigits(double inc) +{ + wxSpinCtrlDouble* sc = new wxSpinCtrlDouble(wxTheApp->GetTopWindow(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, + 0, 50, 0, inc); + unsigned int digits = sc->GetDigits(); + delete sc; + return digits; +} + +TEST_CASE("SpinCtrlDoubleTestCase::InitialDigits", "[spinctrldouble][initialdigits]") +{ + REQUIRE(GetInitialDigits(15) == 0); + REQUIRE(GetInitialDigits(10) == 0); + REQUIRE(GetInitialDigits(1) == 0); + REQUIRE(GetInitialDigits(0.999) == 1); + REQUIRE(GetInitialDigits(0.15) == 1); + REQUIRE(GetInitialDigits(0.11) == 1); + REQUIRE(GetInitialDigits(0.1) == 1); + REQUIRE(GetInitialDigits(0.0999) == 2); + REQUIRE(GetInitialDigits(0.015) == 2); + REQUIRE(GetInitialDigits(0.011) == 2); + REQUIRE(GetInitialDigits(0.01) == 2); + REQUIRE(GetInitialDigits(9.99e-5) == 5); + REQUIRE(GetInitialDigits(1e-5) == 5); + REQUIRE(GetInitialDigits(9.9999e-10) == 10); + REQUIRE(GetInitialDigits(1e-10) == 10); + REQUIRE(GetInitialDigits(9.9999e-20) == 20); + REQUIRE(GetInitialDigits(1e-20) == 20); + REQUIRE(GetInitialDigits(9.9999e-21) == 20); + REQUIRE(GetInitialDigits(1e-21) == 20); + REQUIRE(GetInitialDigits(9.9999e-22) == 20); + REQUIRE(GetInitialDigits(1e-22) == 20); +} + #endif