@@ -22,7 +22,11 @@ public void DecodesWikipediaExample()
22
22
23
23
var result = filter . Decode ( bytes , dictionary , 0 ) ;
24
24
25
- var text = Encoding . ASCII . GetString ( result . ToArray ( ) ) ;
25
+ #if ! NET
26
+ string text = Encoding . ASCII . GetString ( result . ToArray ( ) ) ;
27
+ #else
28
+ string text = Encoding . ASCII . GetString ( result . Span ) ;
29
+ #endif
26
30
27
31
Assert . Equal ( "Man is distinguished, not only by his reason, but by this singular passion from other animals, which is a lust of the mind, " +
28
32
"that by a perseverance of delight in the continued and indefatigable generation of knowledge, " +
@@ -37,7 +41,11 @@ public void ReplacesZWithEmptyBytes()
37
41
38
42
var result = filter . Decode ( bytes , dictionary , 1 ) ;
39
43
40
- var text = Encoding . ASCII . GetString ( result . ToArray ( ) ) ;
44
+ #if ! NET
45
+ string text = Encoding . ASCII . GetString ( result . ToArray ( ) ) ;
46
+ #else
47
+ string text = Encoding . ASCII . GetString ( result . Span ) ;
48
+ #endif
41
49
42
50
Assert . Equal ( "Man \0 \0 \0 \0 is d" , text ) ;
43
51
}
@@ -104,8 +112,12 @@ public void DecodesEncodedPdfContent()
104
112
105
113
var result = filter . Decode ( Encoding . ASCII . GetBytes ( input ) , dictionary , 0 ) ;
106
114
107
- var text = Encoding . ASCII . GetString ( result . ToArray ( ) ) ;
108
-
115
+ #if ! NET
116
+ string text = Encoding . ASCII . GetString ( result . ToArray ( ) ) ;
117
+ #else
118
+ string text = Encoding . ASCII . GetString ( result . Span ) ;
119
+ #endif
120
+
109
121
Assert . Equal ( PdfContent . Replace ( "\r \n " , "\n " ) , text ) ;
110
122
}
111
123
@@ -124,11 +136,57 @@ public void DecodesEncodedPdfContentMissingEndOfDataSymbol()
124
136
125
137
var result = filter . Decode ( Encoding . ASCII . GetBytes ( input ) , dictionary , 0 ) ;
126
138
127
- var text = Encoding . ASCII . GetString ( result . ToArray ( ) ) ;
139
+ #if ! NET
140
+ string text = Encoding . ASCII . GetString ( result . ToArray ( ) ) ;
141
+ #else
142
+ string text = Encoding . ASCII . GetString ( result . Span ) ;
143
+ #endif
128
144
129
145
Assert . Equal ( PdfContent . Replace ( "\r \n " , "\n " ) , text ) ;
130
146
}
131
147
148
+ [ Fact ]
149
+ public void DecodeParallel ( )
150
+ {
151
+ Parallel . For ( 0 , 100_000 , i =>
152
+ {
153
+ if ( i % 2 == 0 )
154
+ {
155
+ var bytes = Encoding . ASCII . GetBytes ( "9jqo^zBlbD-" ) ;
156
+
157
+ var result = filter . Decode ( bytes , dictionary , 1 ) ;
158
+
159
+ #if ! NET
160
+ string text = Encoding . ASCII . GetString ( result . ToArray ( ) ) ;
161
+ #else
162
+ string text = Encoding . ASCII . GetString ( result . Span ) ;
163
+ #endif
164
+
165
+ Assert . Equal ( "Man \0 \0 \0 \0 is d" , text ) ;
166
+ }
167
+ else
168
+ {
169
+ const string input =
170
+ @"0d&.mDdmGg4?O`>9P&*SFD)dS2E2gC4pl@QEb/Zr$8N_r$:7]!01IZ=0eskNAdU47<+?7h+B3Ol2_m!C+?)#1+B1
171
+ `9>:<KhASu!rA7]9oF*)G6@;U'.@ps6t@V$[&ART*lARTXoCj@HP2DlU*/0HBI+B1r?0H_r%1a#ac$<nof.3LB""+=MAS+D58'ATD3qCj@.
172
+ F@;@;70ea^uAKYi.Eb-A7E+*6f+EV:*DBN1?0ek+_+B1r?<%9""=ASu!rA7]9oF*)G6@;U'<.3MT)$8<SS1,pCU6jd-H;e7
173
+ C#1,U1&Ft""Og2'=;YEa`c,ASu!rA8,po+Dk\3BQ%F&+CT;%+CQ]A1,'h!Ft""Oh2'=;UBl%3eCh4`'DBMbD7O]H>0H_br.:""&q8d[6p/M
174
+ T()<(%'A;f?Ma+CT;%+E_a:A0>K&EZek1D/aN,F)u&6DBNA*A0>f4BOu4*+EM76E,9eK+B3(_<%9""p.!0AMEb031ATMF#F<G%,DIIR2+Cno
175
+ &@3B9%+CT.1.3LK*+=KNS6V0ilAoD^,@<=+N>p**=$</Jt-rY&$AKYo'+EV:.+Cf>,E,oN2F(oQ1+D#G#De*R""B-;&&FD,T'F!+n3AKY4b
176
+ F*22=@:F%a+=SF4C'moi+=Li?EZeh0FD)e-@<>p#@;]TuBl.9kATKCFGA(],AKYo5BOu4*+CT;%+C#7pF_Pr+@VfTuDf0B:+=SF4C'moi+=
177
+ Li?EZek1DKKT1F`2DD/TboKAKY](@:s.m/h%oBC'mC/$>""*cF*)G6@;Q?_DIdZpC&~>" ;
132
178
179
+ var result = filter . Decode ( Encoding . ASCII . GetBytes ( input ) , dictionary , 0 ) ;
180
+
181
+ #if ! NET
182
+ string text = Encoding . ASCII . GetString ( result . ToArray ( ) ) ;
183
+ #else
184
+ string text = Encoding . ASCII . GetString ( result . Span ) ;
185
+ #endif
186
+
187
+ Assert . Equal ( PdfContent . Replace ( "\r \n " , "\n " ) , text ) ;
188
+ }
189
+ } ) ;
190
+ }
133
191
}
134
192
}
0 commit comments