[locale] Extend tests with negative results
This commit is contained in:
parent
0c1453ff18
commit
76e37402b3
@ -51,8 +51,34 @@ GeoIPTests::testJSON()
|
|||||||
|
|
||||||
QCOMPARE( tz.first, QLatin1String( "Europe" ) );
|
QCOMPARE( tz.first, QLatin1String( "Europe" ) );
|
||||||
QCOMPARE( tz.second, QLatin1String( "Amsterdam" ) );
|
QCOMPARE( tz.second, QLatin1String( "Amsterdam" ) );
|
||||||
|
|
||||||
|
// JSON is quite tolerant
|
||||||
|
tz = handler.processReply( "time_zone: \"Europe/Brussels\"" );
|
||||||
|
QCOMPARE( tz.second, QLatin1String( "Brussels" ) );
|
||||||
|
|
||||||
|
tz = handler.processReply( "time_zone: America/New_York\n" );
|
||||||
|
QCOMPARE( tz.first, "America" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
GeoIPTests::testJSONbad()
|
||||||
|
{
|
||||||
|
static const char data[] = "time_zone: 1";
|
||||||
|
|
||||||
|
FreeGeoIP handler;
|
||||||
|
auto tz = handler.processReply( data );
|
||||||
|
|
||||||
|
tz = handler.processReply( data );
|
||||||
|
QCOMPARE( tz.first, QString() );
|
||||||
|
|
||||||
|
tz = handler.processReply( "" );
|
||||||
|
QCOMPARE( tz.first, QString() );
|
||||||
|
|
||||||
|
tz = handler.processReply( "<html><body>404 Forbidden</body></html>" );
|
||||||
|
QCOMPARE( tz.first, QString() );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
GeoIPTests::testXML()
|
GeoIPTests::testXML()
|
||||||
{
|
{
|
||||||
@ -96,3 +122,19 @@ GeoIPTests::testXML2()
|
|||||||
QCOMPARE( tz.second, QLatin1String( "North Dakota/Beulah" ) );
|
QCOMPARE( tz.second, QLatin1String( "North Dakota/Beulah" ) );
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
GeoIPTests::testXMLbad()
|
||||||
|
{
|
||||||
|
#ifdef HAVE_XML
|
||||||
|
XMLGeoIP handler;
|
||||||
|
auto tz = handler.processReply( "{time_zone: \"Europe/Paris\"}" );
|
||||||
|
QCOMPARE( tz.first, QString() );
|
||||||
|
|
||||||
|
tz = handler.processReply( "<Response></Response>" );
|
||||||
|
QCOMPARE( tz.first, QString() );
|
||||||
|
|
||||||
|
tz = handler.processReply( "fnord<html/>" );
|
||||||
|
QCOMPARE( tz.first, QString() );
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
@ -31,8 +31,10 @@ public:
|
|||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void initTestCase();
|
void initTestCase();
|
||||||
void testJSON();
|
void testJSON();
|
||||||
|
void testJSONbad();
|
||||||
void testXML();
|
void testXML();
|
||||||
void testXML2();
|
void testXML2();
|
||||||
|
void testXMLbad();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user