Ejemplo n.º 1
0
        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();
                String message   = "Expects: " + iText.IO.Util.JavaUtil.GetStringForBytes(expecteds) + ", actual: " + iText.IO.Util.JavaUtil.GetStringForBytes
                                       (actuals) + " \\\\ " + d;
                NUnit.Framework.Assert.AreEqual(expecteds, actuals, message);
            }
        }
Ejemplo n.º 2
0
        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);
            }
        }
Ejemplo n.º 3
0
        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);
            }
        }
Ejemplo n.º 4
0
 public virtual iText.IO.Source.ByteBuffer Append(String str)
 {
     return(Append(ByteUtils.GetIsoBytes(str)));
 }
Ejemplo n.º 5
0
 public virtual T WriteString(String value)
 {
     return(WriteBytes(ByteUtils.GetIsoBytes(value)));
 }