Skip to content

Commit

Permalink
Fix encoding warnings on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Jul 6, 2015
1 parent f4f7924 commit 5d1306b
Showing 1 changed file with 98 additions and 6 deletions.
104 changes: 98 additions & 6 deletions tests/src/core/testqgspallabeling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,104 @@ void TestQgsPalLabeling::graphemes()
QCOMPARE( QgsPalLabeling::splitToGraphemes( "abcd" ) , QStringList() << "a" << "b" << "c" << "d" );
QCOMPARE( QgsPalLabeling::splitToGraphemes( "ab cd" ) , QStringList() << "a" << "b" << " " << "c" << "d" );
QCOMPARE( QgsPalLabeling::splitToGraphemes( "ab cd " ) , QStringList() << "a" << "b" << " " << "c" << "d" << " " );
QCOMPARE( QgsPalLabeling::splitToGraphemes( QString::fromUtf8( "\u179F\u17D2\u178F\u17D2\u179A\u17B8\u179B\u17D2" ) ) , QStringList() << QString::fromUtf8( "\u179F\u17D2\u178F\u17D2\u179A\u17B8" ) << QString::fromUtf8( "\u179B\u17D2" ) );
QCOMPARE( QgsPalLabeling::splitToGraphemes( QString::fromUtf8( "\u1780\u17D2\u179A\u17BB\u1798\u17A2\u1784\u17D2\u1782\u1780\u17B6\u179A\u179F\u17B7\u1791\u17D2\u1792\u17B7\u1798\u1793\u17BB\u179F\u17D2\u179F" ) ) ,
QStringList() << QString::fromUtf8( "\u1780\u17D2\u179A\u17BB" ) << QString::fromUtf8( "\u1798" ) << QString::fromUtf8( "\u17A2" )
<< QString::fromUtf8( "\u1784\u17D2\u1782" ) << QString::fromUtf8( "\u1780\u17B6" ) << QString::fromUtf8( "\u179A" )
<< QString::fromUtf8( "\u179F\u17B7" ) << QString::fromUtf8( "\u1791\u17D2\u1792\u17B7" ) << QString::fromUtf8( "\u1798" )
<< QString::fromUtf8( "\u1793\u17BB" ) << QString::fromUtf8( "\u179F\u17D2\u179F" ) );

//note - have to use this method to build up unicode QStrings to avoid issues with Windows
//builds and invalid codepages
QString str1;
str1 += QChar( 0x179F );
str1 += QChar( 0x17D2 );
str1 += QChar( 0x178F );
str1 += QChar( 0x17D2 );
str1 += QChar( 0x179A );
str1 += QChar( 0x17B8 );
str1 += QChar( 0x179B );
str1 += QChar( 0x17D2 );
QString expected1Pt1;
expected1Pt1 += QChar( 0x179F );
expected1Pt1 += QChar( 0x17D2 );
expected1Pt1 += QChar( 0x178F );
expected1Pt1 += QChar( 0x17D2 );
expected1Pt1 += QChar( 0x179A );
expected1Pt1 += QChar( 0x17B8 );
QString expected1Pt2;
expected1Pt2 += QChar( 0x179B );
expected1Pt2 += QChar( 0x17D2 );

QCOMPARE( QgsPalLabeling::splitToGraphemes( str1 ), QStringList() << expected1Pt1 << expected1Pt2 );

QString str2;
str2 += QChar( 0x1780 );
str2 += QChar( 0x17D2 );
str2 += QChar( 0x179A );
str2 += QChar( 0x17BB );
str2 += QChar( 0x1798 );
str2 += QChar( 0x17A2 );
str2 += QChar( 0x1784 );
str2 += QChar( 0x17D2 );
str2 += QChar( 0x1782 );
str2 += QChar( 0x1780 );
str2 += QChar( 0x17B6 );
str2 += QChar( 0x179A );
str2 += QChar( 0x179F );
str2 += QChar( 0x17B7 );
str2 += QChar( 0x1791 );
str2 += QChar( 0x17D2 );
str2 += QChar( 0x1792 );
str2 += QChar( 0x17B7 );
str2 += QChar( 0x1798 );
str2 += QChar( 0x1793 );
str2 += QChar( 0x17BB );
str2 += QChar( 0x179F );
str2 += QChar( 0x17D2 );
str2 += QChar( 0x179F );

QString expected2Pt1;
expected2Pt1 += QChar( 0x1780 );
expected2Pt1 += QChar( 0x17D2 );
expected2Pt1 += QChar( 0x179A );
expected2Pt1 += QChar( 0x17BB );
QString expected2Pt2;
expected2Pt2 += QChar( 0x1798 );
QString expected2Pt3;
expected2Pt3 += QChar( 0x17A2 );
QString expected2Pt4;
expected2Pt4 += QChar( 0x1784 );
expected2Pt4 += QChar( 0x17D2 );
expected2Pt4 += QChar( 0x1782 );
QString expected2Pt5;
expected2Pt5 += QChar( 0x1780 );
expected2Pt5 += QChar( 0x17B6 );
QString expected2Pt6;
expected2Pt6 += QChar( 0x179A );
QString expected2Pt7;
expected2Pt7 += QChar( 0x179F );
expected2Pt7 += QChar( 0x17B7 );
QString expected2Pt8;
expected2Pt8 += QChar( 0x1791 );
expected2Pt8 += QChar( 0x17D2 );
expected2Pt8 += QChar( 0x1792 );
expected2Pt8 += QChar( 0x17B7 );
QString expected2Pt9;
expected2Pt9 += QChar( 0x1798 );
QString expected2Pt10;
expected2Pt10 += QChar( 0x1793 );
expected2Pt10 += QChar( 0x17BB );
QString expected2Pt11;
expected2Pt11 += QChar( 0x179F );
expected2Pt11 += QChar( 0x17D2 );
expected2Pt11 += QChar( 0x179F );

QCOMPARE( QgsPalLabeling::splitToGraphemes( str2 ), QStringList() << expected2Pt1
<< expected2Pt2
<< expected2Pt3
<< expected2Pt4
<< expected2Pt5
<< expected2Pt6
<< expected2Pt7
<< expected2Pt8
<< expected2Pt9
<< expected2Pt10
<< expected2Pt11 );
}

QTEST_MAIN( TestQgsPalLabeling )
Expand Down

0 comments on commit 5d1306b

Please sign in to comment.