[libcalamares] Add unittests for GeoIPFixed

- Ignores the data, just returns selector
main
Adriaan de Groot 5 years ago
parent d9effb4ba7
commit 672f506e72

@ -18,6 +18,7 @@
#include "GeoIPTests.h"
#include "GeoIPFixed.h"
#include "GeoIPJSON.h"
#ifdef QT_XML_LIB
#include "GeoIPXML.h"
@ -240,3 +241,35 @@ GeoIPTests::testGet()
CHECK_GET( XML, QString(), "https://geoip.kde.org/v1/ubiquity" ) // Temporary KDE service
#endif
}
void
GeoIPTests::testFixed()
{
{
GeoIPFixed f;
auto tz = f.processReply( QByteArray() );
QCOMPARE( tz.first, QStringLiteral( "Europe" ) );
QCOMPARE( tz.second, QStringLiteral( "Amsterdam" ) );
QCOMPARE( f.processReply( xml_data_ubiquity ), tz );
QCOMPARE( f.processReply( QByteArray( "derp" ) ), tz );
}
{
GeoIPFixed f( QStringLiteral( "America/Vancouver" ) );
auto tz = f.processReply( QByteArray() );
QCOMPARE( tz.first, QStringLiteral( "America" ) );
QCOMPARE( tz.second, QStringLiteral( "Vancouver" ) );
QCOMPARE( f.processReply( xml_data_ubiquity ), tz );
QCOMPARE( f.processReply( QByteArray( "derp" ) ), tz );
}
{
GeoIPFixed f( QStringLiteral( "America/North Dakota/Beulah" ) );
auto tz = f.processReply( QByteArray() );
QCOMPARE( tz.first, QStringLiteral( "America" ) );
QCOMPARE( tz.second, QStringLiteral( "North_Dakota/Beulah" ) );
QCOMPARE( f.processReply( xml_data_ubiquity ), tz );
QCOMPARE( f.processReply( QByteArray( "derp" ) ), tz );
}
}

@ -30,6 +30,7 @@ public:
private Q_SLOTS:
void initTestCase();
void testFixed();
void testJSON();
void testJSONalt();
void testJSONbad();

Loading…
Cancel
Save