From b1dcdb864cbbf8e798b1e34ba148d459c0541501 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 17 Sep 2018 15:20:48 +0200 Subject: [PATCH] Add simple unit tests for the new wxFont features Check that calling SetFractionalPointSize() and SetNumericWeight() at the very least results in the expected return values from GetFractionalPointSize() and GetNumericWeight(). --- tests/font/fonttest.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/font/fonttest.cpp b/tests/font/fonttest.cpp index 480278c2b5..a79b64fa51 100644 --- a/tests/font/fonttest.cpp +++ b/tests/font/fonttest.cpp @@ -148,6 +148,16 @@ TEST_CASE("wxFont::Size", "[font][size]") // one, taking wxFontInfo, doesn't support them. CHECK( wxFont(wxFontInfo(70)).GetPointSize() == 70 ); CHECK( wxFont(wxFontInfo(90)).GetPointSize() == 90 ); + + // Check fractional point sizes as well. + wxFont font(wxFontInfo(12.25)); + CHECK( font.GetFractionalPointSize() == 12.25 ); + CHECK( font.GetPointSize() == 12 ); + + font = *wxNORMAL_FONT; + font.SetFractionalPointSize(9.5); + CHECK( font.GetFractionalPointSize() == 9.5 ); + CHECK( font.GetPointSize() == 10 ); } TEST_CASE("wxFont::Style", "[font][style]") @@ -185,6 +195,15 @@ TEST_CASE("wxFont::Style", "[font][style]") TEST_CASE("wxFont::Weight", "[font][weight]") { + wxFont font; + font.SetNumericWeight(123); + CHECK( font.GetNumericWeight() == 123 ); + CHECK( font.GetWeight() == wxFONTWEIGHT_THIN ); + + font.SetNumericWeight(wxFONTWEIGHT_SEMIBOLD); + CHECK( font.GetNumericWeight() == wxFONTWEIGHT_SEMIBOLD ); + CHECK( font.GetWeight() == wxFONTWEIGHT_SEMIBOLD ); + #if WXWIN_COMPATIBILITY_3_0 // Disable the warning about deprecated wxNORMAL as we use it here // intentionally.