@ -53,15 +53,15 @@ GeoIPTests::testJSON()
GeoIPJSON handler ;
auto tz = handler . processReply ( json_data_attribute ) ;
QCOMPARE ( tz . first , Q Latin1 String( " Europe " ) ) ;
QCOMPARE ( tz . second , Q Latin1 String( " Amsterdam " ) ) ;
QCOMPARE ( tz . first , Q StringLiteral ( " Europe " ) ) ;
QCOMPARE ( tz . second , Q StringLiteral ( " Amsterdam " ) ) ;
// JSON is quite tolerant
tz = handler . processReply ( " time_zone: \" Europe/Brussels \" " ) ;
QCOMPARE ( tz . second , Q Latin1 String( " Brussels " ) ) ;
QCOMPARE ( tz . second , Q StringLiteral ( " Brussels " ) ) ;
tz = handler . processReply ( " time_zone: America/New_York \n " ) ;
QCOMPARE ( tz . first , Q Latin1 String( " America " ) ) ;
QCOMPARE ( tz . first , Q StringLiteral ( " America " ) ) ;
}
void GeoIPTests : : testJSONalt ( )
@ -72,8 +72,8 @@ void GeoIPTests::testJSONalt()
QCOMPARE ( tz . first , QString ( ) ) ; // Not found
tz = handler . processReply ( " tarifa: 12 \n zona_de_hora: Europe/Madrid " ) ;
QCOMPARE ( tz . first , Q Latin1 String( " Europe " ) ) ;
QCOMPARE ( tz . second , Q Latin1 String( " Madrid " ) ) ;
QCOMPARE ( tz . first , Q StringLiteral ( " Europe " ) ) ;
QCOMPARE ( tz . second , Q StringLiteral ( " Madrid " ) ) ;
}
void
@ -122,8 +122,8 @@ GeoIPTests::testXML()
GeoIPXML handler ;
auto tz = handler . processReply ( xml_data_ubiquity ) ;
QCOMPARE ( tz . first , Q Latin1 String( " Europe " ) ) ;
QCOMPARE ( tz . second , Q Latin1 String( " Amsterdam " ) ) ;
QCOMPARE ( tz . first , Q StringLiteral ( " Europe " ) ) ;
QCOMPARE ( tz . second , Q StringLiteral ( " Amsterdam " ) ) ;
# endif
}
@ -137,8 +137,8 @@ GeoIPTests::testXML2()
GeoIPXML handler ;
auto tz = handler . processReply ( data ) ;
QCOMPARE ( tz . first , Q Latin1 String( " America " ) ) ;
QCOMPARE ( tz . second , Q Latin1 String( " North_Dakota/Beulah " ) ) ; // Without space
QCOMPARE ( tz . first , Q StringLiteral ( " America " ) ) ;
QCOMPARE ( tz . second , Q StringLiteral ( " North_Dakota/Beulah " ) ) ; // Without space
# endif
}
@ -149,8 +149,8 @@ void GeoIPTests::testXMLalt()
GeoIPXML handler ( " ZT " ) ;
auto tz = handler . processReply ( " <A><B/><C><ZT>Moon/Dark_side</ZT></C></A> " ) ;
QCOMPARE ( tz . first , Q Latin1 String( " Moon " ) ) ;
QCOMPARE ( tz . second , Q Latin1 String( " Dark_side " ) ) ;
QCOMPARE ( tz . first , Q StringLiteral ( " Moon " ) ) ;
QCOMPARE ( tz . second , Q StringLiteral ( " Dark_side " ) ) ;
# endif
}
@ -172,26 +172,26 @@ GeoIPTests::testXMLbad()
void GeoIPTests : : testSplitTZ ( )
{
auto tz = GeoIP : : splitTZString ( Q Latin1 String( " Moon/Dark_side " ) ) ;
QCOMPARE ( tz . first , Q Latin1 String( " Moon " ) ) ;
QCOMPARE ( tz . second , Q Latin1 String( " Dark_side " ) ) ;
auto tz = GeoIP : : splitTZString ( Q StringLiteral ( " Moon/Dark_side " ) ) ;
QCOMPARE ( tz . first , Q StringLiteral ( " Moon " ) ) ;
QCOMPARE ( tz . second , Q StringLiteral ( " Dark_side " ) ) ;
// Some providers return weirdly escaped data
tz = GeoIP : : splitTZString ( Q Latin1 String( " America \\ /NewYork " ) ) ;
QCOMPARE ( tz . first , Q Latin1 String( " America " ) ) ;
QCOMPARE ( tz . second , Q Latin1 String( " NewYork " ) ) ; // That's not actually the zone name
tz = GeoIP : : splitTZString ( Q StringLiteral ( " America \\ /NewYork " ) ) ;
QCOMPARE ( tz . first , Q StringLiteral ( " America " ) ) ;
QCOMPARE ( tz . second , Q StringLiteral ( " NewYork " ) ) ; // That's not actually the zone name
// Check that bogus data fails
tz = GeoIP : : splitTZString ( QString ( ) ) ;
QCOMPARE ( tz . first , QString ( ) ) ;
tz = GeoIP : : splitTZString ( Q Latin1 String( " America.NewYork " ) ) ;
tz = GeoIP : : splitTZString ( Q StringLiteral ( " America.NewYork " ) ) ;
QCOMPARE ( tz . first , QString ( ) ) ;
// Check that three-level is split properly and space is replaced
tz = GeoIP : : splitTZString ( Q Latin1 String( " America/North Dakota/Beulah " ) ) ;
QCOMPARE ( tz . first , Q Latin1 String( " America " ) ) ;
QCOMPARE ( tz . second , Q Latin1 String( " North_Dakota/Beulah " ) ) ;
tz = GeoIP : : splitTZString ( Q StringLiteral ( " America/North Dakota/Beulah " ) ) ;
QCOMPARE ( tz . first , Q StringLiteral ( " America " ) ) ;
QCOMPARE ( tz . second , Q StringLiteral ( " North_Dakota/Beulah " ) ) ;
}
@ -221,7 +221,7 @@ synchronous_get( const char* urlstring )
void GeoIPTests : : testGet ( )
{
if ( ! QProcessEnvironment : : systemEnvironment ( ) . contains ( Q Latin1 String( " TEST_HTTP_GET " ) ) )
if ( ! QProcessEnvironment : : systemEnvironment ( ) . contains ( Q StringLiteral ( " TEST_HTTP_GET " ) ) )
{
qDebug ( ) < < " Skipping HTTP GET tests " ;
return ;
@ -232,8 +232,8 @@ void GeoIPTests::testGet()
auto default_tz = default_handler . processReply ( synchronous_get ( " https://geoip.kde.org/v1/calamares " ) ) ;
// This is bogus, because the test isn't always run by me
// QCOMPARE( default_tz.first, Q Latin1 String("Europe") );
// QCOMPARE( default_tz.second, Q Latin1 String("Amsterdam") );
// QCOMPARE( default_tz.first, Q StringLiteral ("Europe") );
// QCOMPARE( default_tz.second, Q StringLiteral ("Amsterdam") );
QVERIFY ( ! default_tz . first . isEmpty ( ) ) ;
QVERIFY ( ! default_tz . second . isEmpty ( ) ) ;
@ -242,12 +242,12 @@ void GeoIPTests::testGet()
// services don't agree on the location of where the test is run.
CHECK_GET ( JSON , QString ( ) , " https://geoip.kde.org/v1/calamares " ) // Check it's consistent
CHECK_GET ( JSON , QString ( ) , " http://freegeoip.net/json/ " ) // Original FreeGeoIP service
CHECK_GET ( JSON , Q Latin1 String( " timezone " ) , " https://ipapi.co/json " ) // Different JSON
CHECK_GET ( JSON , Q Latin1 String( " timezone " ) , " http://ip-api.com/json " )
CHECK_GET ( JSON , Q StringLiteral ( " timezone " ) , " https://ipapi.co/json " ) // Different JSON
CHECK_GET ( JSON , Q StringLiteral ( " timezone " ) , " http://ip-api.com/json " )
CHECK_GET ( JSON , Q Latin1 String( " location.time_zone " ) , " http://geoip.nekudo.com/api/ " ) // 2-level JSON
CHECK_GET ( JSON , Q StringLiteral ( " location.time_zone " ) , " http://geoip.nekudo.com/api/ " ) // 2-level JSON
CHECK_GET ( JSON , Q Latin1 String( " Location.TimeZone " ) , " https://geoip.kde.org/debug " ) // 2-level JSON
CHECK_GET ( JSON , Q StringLiteral ( " Location.TimeZone " ) , " https://geoip.kde.org/debug " ) // 2-level JSON
# ifdef HAVE_XML
CHECK_GET ( XML , QString ( ) , " http://geoip.ubuntu.com/lookup " ) // Ubiquity's XML format