From b1921cced9c392d2c8afc4565005448489a5d16b Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 8 Jan 2019 11:30:49 +0100 Subject: [PATCH] [locale] Add tests for some of the data classes --- src/modules/locale/CMakeLists.txt | 11 +++++++ src/modules/locale/Tests.cpp | 53 +++++++++++++++++++++++++++++++ src/modules/locale/Tests.h | 39 +++++++++++++++++++++++ 3 files changed, 103 insertions(+) create mode 100644 src/modules/locale/Tests.cpp create mode 100644 src/modules/locale/Tests.h diff --git a/src/modules/locale/CMakeLists.txt b/src/modules/locale/CMakeLists.txt index 24259d797..e6da9db73 100644 --- a/src/modules/locale/CMakeLists.txt +++ b/src/modules/locale/CMakeLists.txt @@ -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 ) diff --git a/src/modules/locale/Tests.cpp b/src/modules/locale/Tests.cpp new file mode 100644 index 000000000..32a10e250 --- /dev/null +++ b/src/modules/locale/Tests.cpp @@ -0,0 +1,53 @@ +/* === This file is part of Calamares - === + * + * Copyright 2019, Adriaan de Groot + * + * 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 . + */ + + +#include "Tests.h" +#include "LocaleConfiguration.h" + +#include + +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" ); +} diff --git a/src/modules/locale/Tests.h b/src/modules/locale/Tests.h new file mode 100644 index 000000000..acb3ab309 --- /dev/null +++ b/src/modules/locale/Tests.h @@ -0,0 +1,39 @@ +/* === This file is part of Calamares - === + * + * Copyright 2019, Adriaan de Groot + * + * 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 . + */ + + +#ifndef TESTS_H +#define TESTS_H + +#include + +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