File: t_format.cpp

package info (click to toggle)
kraft 2.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 10,112 kB
  • sloc: cpp: 28,535; sql: 1,248; perl: 396; xml: 330; python: 101; sh: 92; makefile: 10
file content (44 lines) | stat: -rw-r--r-- 1,011 bytes parent folder | download
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
36
37
38
39
40
41
42
43
44
#include <QTest>
#include <QObject>

#include "format.h"

class T_Format : public QObject {
    Q_OBJECT
private Q_SLOTS:
    void initTestCase()
    {

    }

    void t1()
    {
        double s = 1.0;
        const QString sstr = Format::localeDoubleToString(s, QLocale::c());
        QCOMPARE(sstr, QStringLiteral("1"));

        double s1 = 1.2;
        const QString sstr1 = Format::localeDoubleToString(s1, QLocale::c());
        QCOMPARE(sstr1, QStringLiteral("1.2"));

        double s2 = 1.43;
        const QString sstr2 = Format::localeDoubleToString(s2, QLocale::c());
        QCOMPARE(sstr2, QStringLiteral("1.43"));

        double s3 = 1.334543;
        const QString sstr3 = Format::localeDoubleToString(s3, QLocale::c());
        QCOMPARE(sstr3, QStringLiteral("1.335"));

        double s4 = 1.50;
        const QString sstr4 = Format::localeDoubleToString(s4, QLocale::c());
        QCOMPARE(sstr4, QStringLiteral("1.5"));

    }

private:

};

QTEST_MAIN(T_Format)
#include "t_format.moc"