public virtual void WriteStringTest() { String str = "SomeString"; byte[] content = ByteUtils.GetIsoBytes(str); NUnit.Framework.Assert.AreEqual(str.GetBytes(), content); }
public virtual void WriteNameTest() { String str = "SomeName"; byte[] content = ByteUtils.GetIsoBytes((byte)'/', str); NUnit.Framework.Assert.AreEqual(("/" + str).GetBytes(), content); }
public virtual void WritePdfStringTest() { String str = "Some PdfString"; byte[] content = ByteUtils.GetIsoBytes((byte)'(', str, (byte)')'); NUnit.Framework.Assert.AreEqual(("(" + str + ")").GetBytes(), content); }
public virtual void WriteStringTest() { String str = "SomeString"; byte[] content = ByteUtils.GetIsoBytes(str); NUnit.Framework.Assert.AreEqual(str.GetBytes(iText.IO.Util.EncodingUtil.ISO_8859_1), content); }
public virtual void WriteNanHighPrecisionTest() { double d = double.NaN; byte[] actuals = ByteUtils.GetIsoBytes(d, null, true); byte[] expecteds = DecimalFormatUtil.FormatNumber(0, "0.##").GetBytes(iText.IO.Util.EncodingUtil.ISO_8859_1 ); String message = "Expects: " + iText.IO.Util.JavaUtil.GetStringForBytes(expecteds) + ", actual: " + iText.IO.Util.JavaUtil.GetStringForBytes (actuals) + " \\\\ " + d; NUnit.Framework.Assert.AreEqual(expecteds, actuals, message); }
public virtual T WriteDouble(double value, bool highPrecision) { try { ByteUtils.GetIsoBytes(value, numBuffer.Reset(), highPrecision); Write(numBuffer.GetInternalBuffer(), numBuffer.Capacity() - numBuffer.Size(), numBuffer.Size()); return(this as T); } catch (IOException e) { throw new IOException(IOException.CannotWriteFloatNumber, e); } }
public virtual T WriteInteger(int value) { try { ByteUtils.GetIsoBytes(value, numBuffer.Reset()); Write(numBuffer.GetInternalBuffer(), numBuffer.Capacity() - numBuffer.Size(), numBuffer.Size()); return(this as T); } catch (IOException e) { throw new IOException(IOException.CannotWriteIntNumber, e); } }
public virtual void WriteNumber3Test() { Random rnd = new Random(); for (int i = 0; i < 100000; i++) { double d = rnd.NextDouble(); if (d < 32700) { d *= 100000; } d = Round(d, 0); byte[] actuals = ByteUtils.GetIsoBytes(d); byte[] expecteds = DecimalFormatUtil.FormatNumber(d, "0").GetBytes(iText.IO.Util.EncodingUtil.ISO_8859_1); String message = "Expects: " + iText.IO.Util.JavaUtil.GetStringForBytes(expecteds) + ", actual: " + iText.IO.Util.JavaUtil.GetStringForBytes (actuals) + " \\\\ " + d; NUnit.Framework.Assert.AreEqual(expecteds, actuals, message); } }
public virtual void WriteNumber2Test() { Random rnd = new Random(); for (int i = 0; i < 100000; i++) { double d = (double)rnd.Next(1000000) / 1000000; d = Round(d, 5); if (Math.Abs(d) < 0.000015) { continue; } byte[] actuals = ByteUtils.GetIsoBytes(d); byte[] expecteds = DecimalFormatUtil.FormatNumber(d, "0.#####").GetBytes(); String message = "Expects: " + iText.IO.Util.JavaUtil.GetStringForBytes(expecteds) + ", actual: " + iText.IO.Util.JavaUtil.GetStringForBytes (actuals) + " \\\\ " + d; NUnit.Framework.Assert.AreEqual(expecteds, actuals, message); } }
public virtual void WriteNumber1Test() { Random rnd = new Random(); for (int i = 0; i < 100000; i++) { double d = (double)rnd.Next(2120000000) / 100000; d = Round(d, 2); if (d < 1.02) { i--; continue; } byte[] actuals = ByteUtils.GetIsoBytes(d); byte[] expecteds = DecimalFormatUtil.FormatNumber(d, "0.##").GetBytes(iText.IO.Util.EncodingUtil.ISO_8859_1 ); String message = "Expects: " + iText.IO.Util.JavaUtil.GetStringForBytes(expecteds) + ", actual: " + iText.IO.Util.JavaUtil.GetStringForBytes (actuals) + " \\\\ " + d; NUnit.Framework.Assert.AreEqual(expecteds, actuals, message); } }
public virtual iText.IO.Source.ByteBuffer Append(String str) { return(Append(ByteUtils.GetIsoBytes(str))); }
public virtual T WriteString(String value) { return(WriteBytes(ByteUtils.GetIsoBytes(value))); }