render_test.dart
3.52 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
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
import 'package:flutter_test/flutter_test.dart';
import 'helper.dart';
import 'load_fonts.dart';
void main() {
setUpAll(loadKaTeXFonts);
group('Accent renderer', () {
const accents = {
'\\acute',
'\\grave',
'\\ddot',
'\\tilde',
'\\bar',
'\\breve',
'\\check',
'\\hat',
'\\vec',
'\\dot',
'\\mathring',
'\\widecheck',
'\\widehat',
'\\widetilde',
'\\overrightarrow',
'\\overleftarrow',
'\\Overrightarrow',
'\\overleftrightarrow',
// '\\overgroup',
// '\\overlinesegment',
'\\overleftharpoon',
'\\overrightharpoon',
};
const accentsUnder = {
'\\underleftarrow',
'\\underrightarrow',
'\\underleftrightarrow',
'\\undergroup',
// '\\underlinesegment': ,
'\\utilde',
'\\underline'
};
for (final command in [
...accents,
...accentsUnder,
'\\overline',
'\\underline'
]) {
testTexToMatchGoldenFile(
'render $command',
[for (var i = 1; i <= 6; i++) '$command{${'x' * i}}'].join(),
location: 'golden/${command.substring(1)}${command.hashCode}.png',
);
}
});
group('Text accent renderer', () {
const accents1 = {
'\\`',
'\\"',
'\\~',
'\\=',
"\\'",
'\\^',
'\\.',
};
const accents2 = {
'\\u',
'\\v',
'\\r',
'\\H',
};
testTexToMatchGoldenFile(
'render text accent set #1',
[
for (final command in accents1)
'\\text{${command}a$command{i}$command{ab}}'
].join(),
location: 'golden/text-accents-1.png',
);
testTexToMatchGoldenFile(
'render text accent set #2',
[
for (final command in accents2)
'\\text{$command a$command{i}$command{ab}}'
].join(),
location: 'golden/text-accents-2.png',
);
});
group('Unicode accent renderer', () {
const symbols = {
'ä', 'Ö',
'\u00e1', '\u0061\u0301', // á = \'{a}
'\u01df', '\u0061\u0308\u0304', // ǟ = \"\={a}
'i\u0300', 'j\u0300'
};
testTexToMatchGoldenFile(
'render unicode accent',
[for (final symbol in symbols) '$symbol\\text{$symbol}'].join(),
location: 'golden/unicode-accents.png',
);
});
testTexToMatchGoldenFile(
'Enclosure renderer',
r'\fcolorbox{blue}{yellow}{a b}\colorbox{red}{a b}\cancel{x}\bcancel{x}\xcancel{x}\sout{x}\fbox{a}',
location: 'golden/enclosure.png',
);
testTexToMatchGoldenFile(
'EqnArray renderer',
r'\begin{aligned}a&=b&c&=d\\e&=f\end{aligned}',
location: 'golden/eqnarray.png',
);
testTexToMatchGoldenFile(
'LeftRight renderer',
r'\left( \dfrac{x}{y} \middle| \dfrac{y}{z} \right> \left( x \middle| y \right> \left. \dfrac{x}{y} \right\}',
location: '../doc/img/leftright.png',
);
testTexToMatchGoldenFile(
'Matrix renderer',
r'\begin{array}{c|r:}a & b \\c & d\end{array}',
location: '../doc/img/matrix.png',
);
testTexToMatchGoldenFile(
'Nary renderer',
r'\sum_a^b{x}\int_a^b{x}\oiint_a^b{x}',
location: '../doc/img/nary.png',
);
testTexToMatchGoldenFile(
'Under/over renderer',
r'\overbrace{a+\dots+a}^{n}\underbrace{a+\dots+a}_{n}',
location: '../doc/img/underover.png',
);
testTexToMatchGoldenFile(
'Stretchy op renderer',
r'\xleftarrow{a}\xrightarrow{b}',
location: '../doc/img/stretchyop.png',
);
testTexToRender(
'Cases should not overflow #17',
r'\begin{cases}u=1z\\u=2\end{cases}',
);
}