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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
/*************************************************************************
** MapLineTest.cpp **
** **
** This file is part of dvisvgm -- the DVI to SVG converter **
** Copyright (C) 2005-2012 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program 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. **
** **
** This program 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 this program; if not, see <http://www.gnu.org/licenses/>. **
*************************************************************************/
#include <gtest/gtest.h>
#include <sstream>
#include "FileFinder.h"
#include "MapLine.h"
#include "Subfont.h"
using namespace std;
class MapLineTest : public ::testing::Test
{
protected:
void SetUp () {
FileFinder::init("MapLineTest", "MapLineTest", false);
}
void TearDown () {
FileFinder::finish();
}
};
TEST_F(MapLineTest, psline1) {
istringstream iss("texname0 TEXNAME0 <texname.pfb <encname.enc");
MapLine mapline(iss);
EXPECT_EQ(mapline.texname(), "texname0");
EXPECT_EQ(mapline.psname(), "TEXNAME0");
EXPECT_EQ(mapline.fontfname(), "texname.pfb");
EXPECT_EQ(mapline.encname(), "encname");
EXPECT_DOUBLE_EQ(mapline.slant(), 0);
EXPECT_DOUBLE_EQ(mapline.extend(), 1);
EXPECT_DOUBLE_EQ(mapline.bold(), 0);
}
TEST_F(MapLineTest, psline2) {
istringstream iss("texname0 TEXNAME0 \".123 SlantFont .456 ExtendFont\" <encname.enc <[texname.ttf");
MapLine mapline(iss);
EXPECT_EQ(mapline.texname(), "texname0");
EXPECT_EQ(mapline.psname(), "TEXNAME0");
EXPECT_EQ(mapline.fontfname(), "texname.ttf");
EXPECT_EQ(mapline.encname(), "encname");
EXPECT_DOUBLE_EQ(mapline.slant(), 0.123);
EXPECT_DOUBLE_EQ(mapline.extend(), 0.456);
EXPECT_DOUBLE_EQ(mapline.bold(), 0);
}
TEST_F(MapLineTest, psline3) {
istringstream iss("texname0 TEXNAME0 <encname.enc \".123 SlantFont IgnoreMe .456 ExtendFont\" <texname.ttf");
MapLine mapline(iss);
EXPECT_EQ(mapline.texname(), "texname0");
EXPECT_EQ(mapline.psname(), "TEXNAME0");
EXPECT_EQ(mapline.fontfname(), "texname.ttf");
EXPECT_EQ(mapline.encname(), "encname");
EXPECT_DOUBLE_EQ(mapline.slant(), 0.123);
EXPECT_DOUBLE_EQ(mapline.extend(), 0.456);
EXPECT_DOUBLE_EQ(mapline.bold(), 0);
}
TEST_F(MapLineTest, pdfline1) {
istringstream iss("texname");
MapLine mapline(iss);
EXPECT_EQ(mapline.texname(), "texname");
EXPECT_EQ(mapline.psname(), "");
EXPECT_EQ(mapline.encname(), "");
EXPECT_EQ(mapline.fontfname(), "");
}
TEST_F(MapLineTest, pdfline2) {
istringstream iss("gbk unicode simsun.ttc");
MapLine mapline(iss);
EXPECT_EQ(mapline.texname(), "gbk");
EXPECT_EQ(mapline.psname(), "");
EXPECT_EQ(mapline.encname(), "unicode");
EXPECT_EQ(mapline.fontfname(), "simsun.ttc");
EXPECT_EQ(mapline.fontindex(), 0);
EXPECT_TRUE(mapline.sfd() == 0);
EXPECT_EQ(mapline.fontindex(), 0);
EXPECT_DOUBLE_EQ(mapline.slant(), 0);
EXPECT_DOUBLE_EQ(mapline.extend(), 1);
}
TEST_F(MapLineTest, pdfline3) {
istringstream iss("gbk@UGBK@10 unicode simsun.ttc -v 50 -r -s .123 -b 1 -e 0.456");
MapLine mapline(iss);
EXPECT_EQ(mapline.texname(), "gbk10");
EXPECT_EQ(mapline.psname(), "");
EXPECT_EQ(mapline.encname(), "unicode");
EXPECT_EQ(mapline.fontfname(), "simsun.ttc");
ASSERT_TRUE(mapline.sfd() != 0);
EXPECT_EQ(mapline.sfd()->name(), "UGBK");
EXPECT_EQ(mapline.fontindex(), 0);
EXPECT_DOUBLE_EQ(mapline.slant(), 0.123);
EXPECT_DOUBLE_EQ(mapline.extend(), 0.456);
EXPECT_DOUBLE_EQ(mapline.bold(), 1);
}
TEST_F(MapLineTest, pdfline4) {
istringstream iss("gbk@UGBK@ default :1:!simsun.ttc/UCS,Bold -e.345");
MapLine mapline(iss);
EXPECT_EQ(mapline.texname(), "gbk");
EXPECT_EQ(mapline.psname(), "");
EXPECT_EQ(mapline.encname(), ""); // encodings "default" and "none" are replaced with ""
EXPECT_EQ(mapline.fontfname(), "simsun.ttc");
ASSERT_TRUE(mapline.sfd() != 0);
EXPECT_EQ(mapline.sfd()->name(), "UGBK");
EXPECT_EQ(mapline.fontindex(), 1);
EXPECT_DOUBLE_EQ(mapline.slant(), 0);
EXPECT_DOUBLE_EQ(mapline.extend(), 0.345);
}
|