private PdfString BuildLongString() { int maxAllowedLength = pdfA1Checker.GetMaxStringLength(); int testLength = maxAllowedLength + 1; NUnit.Framework.Assert.AreEqual(65536, testLength); return(PdfACheckerTestUtils.GetLongString(testLength)); }
public virtual void IndependentLongStringTest() { NUnit.Framework.Assert.That(() => { int maxAllowedLength = pdfA2Checker.GetMaxStringLength(); int testLength = maxAllowedLength + 1; NUnit.Framework.Assert.AreEqual(testLength, 32768); PdfString longString = PdfACheckerTestUtils.GetLongString(testLength); // An exception should be thrown as provided String is longer then // it is allowed per specification pdfA2Checker.CheckPdfObject(longString); } , NUnit.Framework.Throws.InstanceOf <PdfAConformanceException>().With.Message.EqualTo(PdfAConformanceException.PDF_STRING_IS_TOO_LONG)) ; }
public virtual void LongStringInContentStreamTest() { NUnit.Framework.Assert.That(() => { pdfA2Checker.SetFullCheckMode(true); int maxAllowedLength = pdfA2Checker.GetMaxStringLength(); int testLength = maxAllowedLength + 1; NUnit.Framework.Assert.AreEqual(testLength, 32768); PdfString longString = PdfACheckerTestUtils.GetLongString(testLength); String newContentString = PdfACheckerTestUtils.GetStreamWithValue(longString); byte[] newContent = newContentString.GetBytes(System.Text.Encoding.UTF8); PdfStream stream = new PdfStream(newContent); // An exception should be thrown as content stream has a string which // is longer then it is allowed per specification pdfA2Checker.CheckContentStream(stream); } , NUnit.Framework.Throws.InstanceOf <PdfAConformanceException>().With.Message.EqualTo(PdfAConformanceException.PDF_STRING_IS_TOO_LONG)) ; }
public virtual void ValidObjectsTest() { int maxNameLength = pdfA1Checker.GetMaxNameLength(); int maxStringLength = pdfA1Checker.GetMaxStringLength(); int maxArrayCapacity = MAX_ARRAY_CAPACITY; int maxDictionaryCapacity = MAX_DICTIONARY_CAPACITY; long maxIntegerValue = pdfA1Checker.GetMaxIntegerValue(); long minIntegerValue = pdfA1Checker.GetMinIntegerValue(); double maxRealValue = pdfA1Checker.GetMaxRealValue(); NUnit.Framework.Assert.AreEqual(65535, maxStringLength); NUnit.Framework.Assert.AreEqual(127, maxNameLength); PdfString longString = PdfACheckerTestUtils.GetLongString(maxStringLength); PdfName longName = PdfACheckerTestUtils.GetLongName(maxNameLength); PdfArray longArray = PdfACheckerTestUtils.GetLongArray(maxArrayCapacity); PdfDictionary longDictionary = PdfACheckerTestUtils.GetLongDictionary(maxDictionaryCapacity); NUnit.Framework.Assert.AreEqual(2147483647, maxIntegerValue); NUnit.Framework.Assert.AreEqual(-2147483648, minIntegerValue); NUnit.Framework.Assert.AreEqual(32767, maxRealValue, 0.001); PdfNumber largeInteger = new PdfNumber(maxIntegerValue); PdfNumber negativeInteger = new PdfNumber(minIntegerValue); PdfNumber largeReal = new PdfNumber(maxRealValue - 0.001); PdfObject[] largeObjects = new PdfObject[] { longName, longString, longArray, longDictionary, largeInteger , negativeInteger, largeReal }; // No exceptions should not be thrown as all values match the // limitations provided in specification foreach (PdfObject largeObject in largeObjects) { pdfA1Checker.CheckPdfObject(largeObject); CheckInArray(largeObject); CheckInDictionary(largeObject); CheckInComplexStructure(largeObject); CheckInContentStream(largeObject); CheckInArrayInContentStream(largeObject); CheckInDictionaryInContentStream(largeObject); CheckInFormXObject(largeObject); CheckInTilingPattern(largeObject); CheckInType3Font(largeObject); } }