File: currencytableinittest.cpp

package info (click to toggle)
kunitconversion 5.116.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 22,212 kB
  • sloc: cpp: 7,570; xml: 42; sh: 15; makefile: 7
file content (35 lines) | stat: -rw-r--r-- 1,109 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/*
 *   SPDX-FileCopyrightText: 2021 Andreas Cord-Landwehr <cordlandwehr@kde.org>
 *
 *   SPDX-License-Identifier: LGPL-2.0-or-later
 */

#include "currencytableinittest.h"
#include <QStandardPaths>
#include <cmath>

using namespace KUnitConversion;

void CurrencyTableInitTest::testCategoryInit()
{
    QStandardPaths::setTestModeEnabled(true);
    const QString cache = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QStringLiteral("/libkunitconversion/currency.xml");

    QVERIFY(QFile::exists(QLatin1String(":/currency.xml")));
    if (QFile::exists(cache)) {
        QFile::remove(cache);
    }
    // note: copy of file updates the file's modified timestamp and thus file is seen as recently downloaded file
    QVERIFY(QFile::copy(QLatin1String(":/currency.xml"), cache));

    Converter c;
    Value input = Value(1000, Eur);
    Value v = c.convert(input, QStringLiteral("$"));
    qDebug() << "converted value to:" << v.number();
    QVERIFY(v.isValid());
    QVERIFY(!std::isnan(v.number()));
}

QTEST_MAIN(CurrencyTableInitTest)

#include "moc_currencytableinittest.cpp"