Add basic wxSVGFileDC unit tests (PR #27022)

21 views
Skip to first unread message

Blake-Madden

unread,
Sep 18, 2026, 11:59:07 AM (5 days ago) Sep 18
to wx-...@googlegroups.com, Subscribed

Added to test_gui in case peripheral graphics context usage complicates things


You can view, comment on, or merge this pull request online at:

  https://github.com/wxWidgets/wxWidgets/pull/27022

Commit Summary

  • a6accb7 Add basic wxSVGFileDC unit tests

File Changes

(8 files)

Patch Links:


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!
You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/27022@github.com>

VZ

unread,
Sep 20, 2026, 11:58:22 AM (3 days ago) Sep 20
to wx-...@googlegroups.com, Subscribed

@vadz commented on this pull request.

Thanks for the tests but please use CATCH matchers to make them more useful in case of failure. TIA!


In tests/graphics/svgfiledc.cpp:

> +
+} // namespace
+
+TEST_CASE("wxSVGFileDC::Ctor", "[svg][dcsvg]")
+{
+    wxSVGFileDC dc(wxString{}, 320, 240);
+
+    CHECK( dc.IsOk() );
+
+    wxSize size = dc.GetSize();
+    CHECK( size.GetWidth() == 320 );
+    CHECK( size.GetHeight() == 240 );
+
+    const wxString svg = dc.GetSVGDocument();
+    CHECK( svg.StartsWith("<?xml") );
+    CHECK( svg.Contains("<svg ") );

Please use

⬇️ Suggested change
-    CHECK( svg.Contains("<svg ") );
+CHECK_THAT( svg, Catch::Contains("<svg") );

for the same reason.

Also below.


In tests/graphics/svgfiledc.cpp:

> +}
+
+} // namespace
+
+TEST_CASE("wxSVGFileDC::Ctor", "[svg][dcsvg]")
+{
+    wxSVGFileDC dc(wxString{}, 320, 240);
+
+    CHECK( dc.IsOk() );
+
+    wxSize size = dc.GetSize();
+    CHECK( size.GetWidth() == 320 );
+    CHECK( size.GetHeight() == 240 );
+
+    const wxString svg = dc.GetSVGDocument();
+    CHECK( svg.StartsWith("<?xml") );

The problem with this check is that there is no information if the check fails — we don't know if the string is empty or there is some extra stuff before <?xml or something else. If you use

⬇️ Suggested change
-    CHECK( svg.StartsWith("<?xml") );
+    CHECK_THAT( svg, Catch::StartsWith("<?xml") );

CATCH would print the contents of svg if the check fails.


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/27022/review/5260989066@github.com>

Blake-Madden

unread,
Sep 20, 2026, 12:19:28 PM (3 days ago) Sep 20
to wx-...@googlegroups.com, Push

@Blake-Madden pushed 1 commit.


View it on GitHub or unsubscribe.


Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/27022/before/a6accb7988431488241e2926e4a7cbbf3cfb9a3b/after/2fcc9b8e230402a10fac77162a9bdf3131fa9906@github.com>

Blake-Madden

unread,
Sep 20, 2026, 1:15:12 PM (3 days ago) Sep 20
to wx-...@googlegroups.com, Subscribed

@Blake-Madden commented on this pull request.


In tests/graphics/svgfiledc.cpp:

> +
+} // namespace
+
+TEST_CASE("wxSVGFileDC::Ctor", "[svg][dcsvg]")
+{
+    wxSVGFileDC dc(wxString{}, 320, 240);
+
+    CHECK( dc.IsOk() );
+
+    wxSize size = dc.GetSize();
+    CHECK( size.GetWidth() == 320 );
+    CHECK( size.GetHeight() == 240 );
+
+    const wxString svg = dc.GetSVGDocument();
+    CHECK( svg.StartsWith("<?xml") );
+    CHECK( svg.Contains("<svg ") );

done


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/27022/review/5261179171@github.com>

Blake-Madden

unread,
Sep 20, 2026, 1:15:23 PM (3 days ago) Sep 20
to wx-...@googlegroups.com, Subscribed

@Blake-Madden commented on this pull request.


In tests/graphics/svgfiledc.cpp:

> +}
+
+} // namespace
+
+TEST_CASE("wxSVGFileDC::Ctor", "[svg][dcsvg]")
+{
+    wxSVGFileDC dc(wxString{}, 320, 240);
+
+    CHECK( dc.IsOk() );
+
+    wxSize size = dc.GetSize();
+    CHECK( size.GetWidth() == 320 );
+    CHECK( size.GetHeight() == 240 );
+
+    const wxString svg = dc.GetSVGDocument();
+    CHECK( svg.StartsWith("<?xml") );

done


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/27022/review/5261179598@github.com>

VZ

unread,
Sep 20, 2026, 4:59:06 PM (3 days ago) Sep 20
to wx-...@googlegroups.com, Subscribed

Closed #27022 via 06e1449.


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/27022/issue_event/31492705299@github.com>

Reply all
Reply to author
Forward
0 new messages