-
Notifications
You must be signed in to change notification settings - Fork 104
Expand file tree
/
Copy pathconverter_test.cpp
More file actions
56 lines (47 loc) · 1.7 KB
/
Copy pathconverter_test.cpp
File metadata and controls
56 lines (47 loc) · 1.7 KB
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
/******************************************************************************
* MODULE : converter_test.cpp
* DESCRIPTION: Properties of characters and strings
* COPYRIGHT : (C) 2019 Darcy Shen
*******************************************************************************
* This software falls under the GNU general public license version 3 or later.
* It comes WITHOUT ANY WARRANTY WHATSOEVER. For details, see the file LICENSE
* in the root directory or <http://www.gnu.org/licenses/gpl-3.0.html>.
******************************************************************************/
#include <QtTest/QtTest>
#include "base.hpp"
#include "converter.hpp"
#include "convert.hpp"
#include "file.hpp"
class TestConverter : public QObject {
Q_OBJECT
private slots:
void init () { init_lolly (); };
void test_utf8_to_cork ();
void test_cork_to_utf8 ();
void test_verbatim_to_tree_auto ();
};
void
TestConverter::test_utf8_to_cork () {
qcompare (utf8_to_cork ("中"), "<#4E2D>");
qcompare (utf8_to_cork ("“"), "\x10");
qcompare (utf8_to_cork ("”"), "\x11");
}
void
TestConverter::test_cork_to_utf8 () {
qcompare (cork_to_utf8 ("<#4E2D>"), "中");
qcompare (cork_to_utf8 ("\x10"), "“");
qcompare (cork_to_utf8 ("\x11"), "”");
}
void
TestConverter::test_verbatim_to_tree_auto () {
// 单个中文字符
tree t1 = verbatim_to_tree ("中", false, "auto");
qcompare (as_string (t1), "<#4E2D>");
// 多行中文字符以及特殊标点符号
tree t2 = verbatim_to_tree ("你好\n世界!", false, "auto");
qcompare (N (t2), 2);
qcompare (as_string (t2[0]), "<#4F60><#597D>");
qcompare (as_string (t2[1]), "<#4E16><#754C>!");
}
QTEST_MAIN (TestConverter)
#include "converter_test.moc"