@@ -67,24 +67,34 @@ public virtual void ValidObjectsTest() {
67
67
int maxStringLength = pdfA1Checker . GetMaxStringLength ( ) ;
68
68
int maxArrayCapacity = MAX_ARRAY_CAPACITY ;
69
69
int maxDictionaryCapacity = MAX_DICTIONARY_CAPACITY ;
70
- NUnit . Framework . Assert . AreEqual ( maxStringLength , 65535 ) ;
70
+ long maxIntegerValue = pdfA1Checker . GetMaxIntegerValue ( ) ;
71
+ long minIntegerValue = pdfA1Checker . GetMinIntegerValue ( ) ;
72
+ double maxRealValue = pdfA1Checker . GetMaxRealValue ( ) ;
73
+ NUnit . Framework . Assert . AreEqual ( 65535 , maxStringLength ) ;
71
74
PdfString longString = PdfACheckerTestUtils . GetLongString ( maxStringLength ) ;
72
75
PdfArray longArray = PdfACheckerTestUtils . GetLongArray ( maxArrayCapacity ) ;
73
76
PdfDictionary longDictionary = PdfACheckerTestUtils . GetLongDictionary ( maxDictionaryCapacity ) ;
74
- PdfObject [ ] longObjects = new PdfObject [ ] { longString , longArray , longDictionary } ;
77
+ NUnit . Framework . Assert . AreEqual ( 2147483647 , maxIntegerValue ) ;
78
+ NUnit . Framework . Assert . AreEqual ( - 2147483648 , minIntegerValue ) ;
79
+ NUnit . Framework . Assert . AreEqual ( 32767 , maxRealValue , 0.001 ) ;
80
+ PdfNumber largeInteger = new PdfNumber ( maxIntegerValue ) ;
81
+ PdfNumber negativeInteger = new PdfNumber ( minIntegerValue ) ;
82
+ PdfNumber largeReal = new PdfNumber ( maxRealValue - 0.001 ) ;
83
+ PdfObject [ ] largeObjects = new PdfObject [ ] { longString , longArray , longDictionary , largeInteger , negativeInteger
84
+ , largeReal } ;
75
85
// No exceptions should not be thrown as all values match the
76
86
// limitations provided in specification
77
- foreach ( PdfObject longObject in longObjects ) {
78
- pdfA1Checker . CheckPdfObject ( longObject ) ;
79
- CheckInArray ( longObject ) ;
80
- CheckInDictionary ( longObject ) ;
81
- CheckInComplexStructure ( longObject ) ;
82
- CheckInContentStream ( longObject ) ;
83
- CheckInArrayInContentStream ( longObject ) ;
84
- CheckInDictionaryInContentStream ( longObject ) ;
85
- CheckInFormXObject ( longObject ) ;
86
- CheckInTilingPattern ( longObject ) ;
87
- CheckInType3Font ( longObject ) ;
87
+ foreach ( PdfObject largeObject in largeObjects ) {
88
+ pdfA1Checker . CheckPdfObject ( largeObject ) ;
89
+ CheckInArray ( largeObject ) ;
90
+ CheckInDictionary ( largeObject ) ;
91
+ CheckInComplexStructure ( largeObject ) ;
92
+ CheckInContentStream ( largeObject ) ;
93
+ CheckInArrayInContentStream ( largeObject ) ;
94
+ CheckInDictionaryInContentStream ( largeObject ) ;
95
+ CheckInFormXObject ( largeObject ) ;
96
+ CheckInTilingPattern ( largeObject ) ;
97
+ CheckInType3Font ( largeObject ) ;
88
98
}
89
99
}
90
100
@@ -108,6 +118,38 @@ public virtual void IndependentLongStringTest() {
108
118
;
109
119
}
110
120
121
+ [ NUnit . Framework . Test ]
122
+ public virtual void IndependentLargeIntegerTest ( ) {
123
+ NUnit . Framework . Assert . That ( ( ) => {
124
+ PdfNumber largeNumber = new PdfNumber ( pdfA1Checker . GetMaxIntegerValue ( ) + 1L ) ;
125
+ // An exception should be thrown as provided integer is larger then
126
+ // it is allowed per specification
127
+ pdfA1Checker . CheckPdfObject ( largeNumber ) ;
128
+ }
129
+ , NUnit . Framework . Throws . InstanceOf < PdfAConformanceException > ( ) . With . Message . EqualTo ( PdfAConformanceException . INTEGER_NUMBER_IS_OUT_OF_RANGE ) )
130
+ ;
131
+ }
132
+
133
+ [ NUnit . Framework . Test ]
134
+ public virtual void IndependentLargeNegativeIntegerTest ( ) {
135
+ NUnit . Framework . Assert . That ( ( ) => {
136
+ PdfNumber largeNumber = new PdfNumber ( pdfA1Checker . GetMinIntegerValue ( ) - 1L ) ;
137
+ // An exception should be thrown as provided integer is smaller then
138
+ // it is allowed per specification
139
+ pdfA1Checker . CheckPdfObject ( largeNumber ) ;
140
+ }
141
+ , NUnit . Framework . Throws . InstanceOf < PdfAConformanceException > ( ) . With . Message . EqualTo ( PdfAConformanceException . INTEGER_NUMBER_IS_OUT_OF_RANGE ) )
142
+ ;
143
+ }
144
+
145
+ [ NUnit . Framework . Test ]
146
+ public virtual void IndependentLargeRealTest ( ) {
147
+ PdfNumber largeNumber = new PdfNumber ( pdfA1Checker . GetMaxRealValue ( ) + 1.0 ) ;
148
+ // TODO DEVSIX-4182
149
+ // An exception is not thrown as any number greater then 32767 is considered as Integer
150
+ pdfA1Checker . CheckPdfObject ( largeNumber ) ;
151
+ }
152
+
111
153
[ NUnit . Framework . Test ]
112
154
public virtual void IndependentLongArrayTest ( ) {
113
155
NUnit . Framework . Assert . That ( ( ) => {
@@ -180,6 +222,38 @@ public virtual void LongStringInContentStreamTest() {
180
222
;
181
223
}
182
224
225
+ [ NUnit . Framework . Test ]
226
+ public virtual void LargeIntegerInContentStreamTest ( ) {
227
+ NUnit . Framework . Assert . That ( ( ) => {
228
+ PdfNumber largeNumber = new PdfNumber ( pdfA1Checker . GetMaxIntegerValue ( ) + 1L ) ;
229
+ // An exception should be thrown as provided integer is larger then
230
+ // it is allowed per specification
231
+ CheckInContentStream ( largeNumber ) ;
232
+ }
233
+ , NUnit . Framework . Throws . InstanceOf < PdfAConformanceException > ( ) . With . Message . EqualTo ( PdfAConformanceException . INTEGER_NUMBER_IS_OUT_OF_RANGE ) )
234
+ ;
235
+ }
236
+
237
+ [ NUnit . Framework . Test ]
238
+ public virtual void LargeNegativeIntegerInContentStreamTest ( ) {
239
+ NUnit . Framework . Assert . That ( ( ) => {
240
+ PdfNumber largeNumber = new PdfNumber ( pdfA1Checker . GetMinIntegerValue ( ) - 1L ) ;
241
+ // An exception should be thrown as provided integer is smaller then
242
+ // it is allowed per specification
243
+ CheckInContentStream ( largeNumber ) ;
244
+ }
245
+ , NUnit . Framework . Throws . InstanceOf < PdfAConformanceException > ( ) . With . Message . EqualTo ( PdfAConformanceException . INTEGER_NUMBER_IS_OUT_OF_RANGE ) )
246
+ ;
247
+ }
248
+
249
+ [ NUnit . Framework . Test ]
250
+ public virtual void LargeRealInContentStreamTest ( ) {
251
+ PdfNumber largeNumber = new PdfNumber ( pdfA1Checker . GetMaxRealValue ( ) + 1.0 ) ;
252
+ // TODO DEVSIX-4182
253
+ // An exception is not thrown as any number greater then 32767 is considered as Integer
254
+ CheckInContentStream ( largeNumber ) ;
255
+ }
256
+
183
257
[ NUnit . Framework . Test ]
184
258
public virtual void LongArrayInContentStreamTest ( ) {
185
259
NUnit . Framework . Assert . That ( ( ) => {
@@ -334,7 +408,7 @@ public virtual void LongStringInType3FontTest() {
334
408
private PdfString BuildLongString ( ) {
335
409
int maxAllowedLength = pdfA1Checker . GetMaxStringLength ( ) ;
336
410
int testLength = maxAllowedLength + 1 ;
337
- NUnit . Framework . Assert . AreEqual ( testLength , 65536 ) ;
411
+ NUnit . Framework . Assert . AreEqual ( 65536 , testLength ) ;
338
412
return PdfACheckerTestUtils . GetLongString ( testLength ) ;
339
413
}
340
414
0 commit comments