← Back to team overview

kicad-developers team mailing list archive

Re: UTF-8 change please test on Windows/Mac

 

Hi Seth,

I noticed in that commit some test data to tools/utf8_test.cpp. However,
the "Utf8AndWx" test case in qa_common doesn't work with Unicode in the
input string.

Doing a quick check back, this never worked, but wasn't covered in the
tests, which only used ASCII literals for the conversion/equality tests.

Here's a demo patch for the failing tests (adds a test for conversion of
ASCII-only and UTF8 strings, the second one fails). Maybe I'm holding it
wrong, but it seems to me this should work:

    #define UTF8_LITERAL "This is a test of UTF-8: ü‱☺😕😱" // Why so
serious?

    UTF8 utf8_inited { UTF8_LITERAL };
    wxString wx_inited { UTF8_LITERAL };

    wxString wx_copied_from_utf8 = utf8_inited;
    BOOST_CHECK_EQUAL( wx_inited, wx_copied_from_utf8 );

Cheers,

John

On Wed, Oct 17, 2018 at 8:42 PM <seth@xxxxxxxxxxxxx> wrote:

> On 2018-10-17 12:19, jp charras wrote:
> >>
> >>
> >> OK, I'll need to look at this more deeply.  Does W7 work with the
> >> example unicode 😕?  This is the one given in the bug report that
> >> crashes Linux.
> >>
> >> -Seth
> >>
> >
> > It is incorrectly displayed in dialogs, but it does not create issues
> > in
> > eeschema and pcbnew.
> > I tested 2 other unicode chars (‱ and ☺) shown in dialogs and ‱ is
> > shown
> > with our graphic font.
> > I am thinking these two unicode chars have a code > 16 bits.
>
> Both the bp and smile are in the basic plane (0x2031 and 0x263A).  They
> both worked correctly under Linux without the change.
>
> Here are a few codeblocks that did crash Linux (any symbol in them):
> https://en.wikipedia.org/wiki/Mathematical_Alphanumeric_Symbols
> https://en.wikipedia.org/wiki/Emoticons_(Unicode_block)
> https://en.wikipedia.org/wiki/CJK_Compatibility_Ideographs_Supplement
>
> I've pushed an update that hopefully fixes the MSW crash.  Let me know
> if it doesn't work for you.
>
> -Seth
>
> _______________________________________________
> Mailing list: https://launchpad.net/~kicad-developers
> Post to     : kicad-developers@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~kicad-developers
> More help   : https://help.launchpad.net/ListHelp
>
From b4bebf1347fc94ebfe1ed258c6a9fe99bdf6651d Mon Sep 17 00:00:00 2001
From: John Beard <john.j.beard@xxxxxxxxx>
Date: Thu, 18 Oct 2018 11:13:55 +0100
Subject: [PATCH] QA: Test strings containing unicode can convert to wxString
 and compare

---
 qa/common/test_utf8.cpp | 32 +++++++++++++++++++++++++++-----
 1 file changed, 27 insertions(+), 5 deletions(-)

diff --git a/qa/common/test_utf8.cpp b/qa/common/test_utf8.cpp
index c52ca1ff7..a8ba07535 100644
--- a/qa/common/test_utf8.cpp
+++ b/qa/common/test_utf8.cpp
@@ -39,15 +39,18 @@ struct Utf8Fixture
  */
 BOOST_FIXTURE_TEST_SUITE( Utf8, Utf8Fixture )
 
+// Define, not static because we might not want to type-convert
+#define ASCII_LITERAL "This is a test of ASCII"
+#define UTF8_LITERAL "This is a test of UTF-8: ü‱☺😕😱"
 
 /**
  * Check direct and copy construction from std::string
  */
 BOOST_AUTO_TEST_CASE( Utf8AndStdString )
 {
-    std::string str { "input" };
+    std::string str { UTF8_LITERAL };
 
-    UTF8 utf8_inited { "input" };
+    UTF8 utf8_inited { UTF8_LITERAL };
     UTF8 utf8_copied_from_stdstr = str;
 
     BOOST_CHECK_EQUAL( utf8_inited, utf8_copied_from_stdstr );
@@ -61,10 +64,10 @@ BOOST_AUTO_TEST_CASE( Utf8AndStdString )
 /**
  * Check direct and copy construction from wxString
  */
-BOOST_AUTO_TEST_CASE( Utf8AndWx )
+BOOST_AUTO_TEST_CASE( Utf8AndWxAscii )
 {
-    UTF8 utf8_inited { "input" };
-    wxString wx_inited { "input" };
+    UTF8 utf8_inited { ASCII_LITERAL };
+    wxString wx_inited { ASCII_LITERAL };
 
     // Check that we can copy convert WxString and compare
     wxString wx_copied_from_utf8 = utf8_inited;
@@ -75,6 +78,25 @@ BOOST_AUTO_TEST_CASE( Utf8AndWx )
     BOOST_CHECK_EQUAL( utf8_inited, utf8_copied_from_wxstring );
 }
 
+
+/**
+ * Check direct and copy construction from wxString
+ */
+BOOST_AUTO_TEST_CASE( Utf8AndWxUnicode )
+{
+    UTF8 utf8_inited { UTF8_LITERAL };
+    wxString wx_inited { UTF8_LITERAL };
+
+    // Check that we can copy convert WxString and compare
+    wxString wx_copied_from_utf8 = utf8_inited;
+    BOOST_CHECK_EQUAL( wx_inited, wx_copied_from_utf8 );
+
+    // Check we can copy-construct from a WxString
+    UTF8 utf8_copied_from_wxstring = wx_inited;
+    BOOST_CHECK_EQUAL( utf8_inited, utf8_copied_from_wxstring );
+}
+
+
 /**
  * UTF8::uni_iter null tests
  */
-- 
2.19.0


Follow ups

References