[locale] Add tests for some of the data classes

This commit is contained in:
Adriaan de Groot 2019-01-08 11:30:49 +01:00
parent 50e6f0fcbf
commit b1921cced9
3 changed files with 103 additions and 0 deletions

View file

@ -59,6 +59,17 @@ if( ECM_FOUND AND BUILD_TESTING )
${YAMLCPP_LIBRARY}
)
set_target_properties( geoiptest PROPERTIES AUTOMOC TRUE )
ecm_add_test(
Tests.cpp
LocaleConfiguration.cpp
TEST_NAME
localetest
LINK_LIBRARIES
calamares
Qt5::Test
)
set_target_properties( localetest PROPERTIES AUTOMOC TRUE )
endif()
if( BUILD_TESTING )

View file

@ -0,0 +1,53 @@
/* === This file is part of Calamares - <http://github.com/calamares> ===
*
* Copyright 2019, Adriaan de Groot <groot@kde.org>
*
* Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Calamares is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
*/
#include "Tests.h"
#include "LocaleConfiguration.h"
#include <QtTest/QtTest>
QTEST_GUILESS_MAIN( LocaleTests )
LocaleTests::LocaleTests()
{
}
LocaleTests::~LocaleTests()
{
}
void LocaleTests::initTestCase()
{
}
void LocaleTests::testEmptyLocaleConfiguration()
{
LocaleConfiguration lc;
QVERIFY( lc.isEmpty() );
QCOMPARE( lc.toBcp47(), QString() );
}
void LocaleTests::testDefaultLocaleConfiguration()
{
LocaleConfiguration lc( "en_US.UTF-8" );
QVERIFY( !lc.isEmpty() );
QCOMPARE( lc.toBcp47(), "en_US" );
}

View file

@ -0,0 +1,39 @@
/* === This file is part of Calamares - <http://github.com/calamares> ===
*
* Copyright 2019, Adriaan de Groot <groot@kde.org>
*
* Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Calamares is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef TESTS_H
#define TESTS_H
#include <QObject>
class LocaleTests : public QObject
{
Q_OBJECT
public:
LocaleTests();
~LocaleTests() override;
private Q_SLOTS:
void initTestCase();
// Check the sample config file is processed correctly
void testEmptyLocaleConfiguration();
void testDefaultLocaleConfiguration();
};
#endif