/
ft_localedata.cpp
96 lines (86 loc) · 3.09 KB
/
ft_localedata.cpp
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/***************************************************************************
**
** Copyright (C) 2010, 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (directui@nokia.com)
**
** This file is part of libmeegotouch.
**
** If you have questions regarding the use of this file, please contact
** Nokia at directui@nokia.com.
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation
** and appearing in the file LICENSE.LGPL included in the packaging
** of this file.
**
****************************************************************************/
#include "ft_localedata.h"
using ML10N::MLocale;
void Ft_LocaleData::initTestCase()
{
MLocale::setDataPath(qApp->applicationDirPath());
}
void Ft_LocaleData::cleanup()
{
}
/*
* Test whether standard number formatting of ICU can be overridden
* for a certain language by loading a special resource file.
*
* The path to the resource file loaded here is of the form
*
* <prefix>/icudt<version><flag>/<basename>.res
*
* <prefix> is set above in initTestCase() by MLocale::setDataPath("."),
* i.e. this test application looks for the file starting from the current
* directory.
*
* <version> indicates the icu version, for libicu42 this is 42
*
* <flag> is 'l' for Little Endian, ASCII, 'b' for Big Endian, ASCII,
* 'e' for Big Endian, EBCDIC.
*
* <basename> is the name of the locale this resource file is intended for.
* For the test below we use "fi_FI" as the locale name.
*
* Therefore, the full path name of the file loaded by the test below is
* ./icudt42l/fi_FI.res (for libicu42).
*
* fi_FI.res is generated from a the plain text file fi_FI.txt using
* the "genrb" tool (See the rules in the ft_localedata.pro file).
*
* For more details see http://userguide.icu-project.org/icudata
*/
void Ft_LocaleData::testNumberData_data()
{
QTest::addColumn<QString>("locale_name");
QTest::addColumn<double>("value");
QTest::addColumn<QString>("result");
// for en_US_POSIX locale, we don’t override anything, i.e.
// the expected result below is what ICU does by default:
QTest::newRow("en_US_POSIX")
<< QString("en_US_POSIX")
<< (double) 1234567.123456789
<< QString("1234567.123457");
// For fi_FI locale, we override the formatting of a double number using the
// the file ./icudt42l/fi_FI.res as explained above.
// Therefore we expect a weird result below, the point here
// is only to check whether we can override the default if this should
// be necessary:
QTest::newRow("fi_FI")
<< QString("fi_FI")
<< (double) 1234567.123456789
<< QString("1 234 567--123");
}
void Ft_LocaleData::testNumberData()
{
QFETCH(QString, locale_name);
QFETCH(double, value);
QFETCH(QString, result);
MLocale locale(locale_name);
QVERIFY(locale.isValid());
QCOMPARE(locale.formatNumber(value), result);
}
QTEST_GUILESS_MAIN(Ft_LocaleData);