Ejemplo n.º 1
0
        public virtual void ConvertFloatMinimumToPdfTest()
        {
            float expected = 1.4E-45f;
            float actual   = SvgCssUtils.ConvertPtsToPx(float.Epsilon);

            NUnit.Framework.Assert.AreEqual(expected, actual, 0f);
        }
Ejemplo n.º 2
0
        public virtual void ConvertLongerFloatToStringTest()
        {
            String expected = "0.1234567";
            String actual   = SvgCssUtils.ConvertFloatToString(0.1234567f);

            NUnit.Framework.Assert.AreEqual(expected, actual);
        }
Ejemplo n.º 3
0
        public virtual void ConvertFloatMaximumToPdfTest()
        {
            float expected = float.PositiveInfinity;
            float actual   = SvgCssUtils.ConvertPtsToPx(float.MaxValue);

            NUnit.Framework.Assert.AreEqual(expected, actual, 0f);
        }
Ejemplo n.º 4
0
 public virtual void NormalConvertPtsToPxTest()
 {
     float[] input    = new float[] { -1f, 0f, 1f };
     float[] expected = new float[] { -1.3333334f, 0f, 1.3333334f };
     for (int i = 0; i < input.Length; i++)
     {
         float actual = SvgCssUtils.ConvertPtsToPx(input[i]);
         NUnit.Framework.Assert.AreEqual(expected[i], actual, 0f);
     }
 }
Ejemplo n.º 5
0
        public virtual void CompareIsStyleSheetLinkResult()
        {
            iText.StyledXmlParser.Jsoup.Nodes.Element element = new iText.StyledXmlParser.Jsoup.Nodes.Element(iText.StyledXmlParser.Jsoup.Parser.Tag
                                                                                                              .ValueOf("link"), "");
            element.Attr(CommonAttributeConstants.REL, CommonAttributeConstants.STYLESHEET);
            JsoupElementNode elementNode = new JsoupElementNode(element);
            bool             expected    = CssUtils.IsStyleSheetLink(elementNode);
            bool             actual      = SvgCssUtils.IsStyleSheetLink(elementNode);

            NUnit.Framework.Assert.AreEqual(actual, expected);
        }
Ejemplo n.º 6
0
        public virtual void NewLineSplitValueTest()
        {
            String         input    = "1\n2\n3\n4";
            IList <String> expected = new List <String>();

            expected.Add("1");
            expected.Add("2");
            expected.Add("3");
            expected.Add("4");
            IList <String> actual = SvgCssUtils.SplitValueList(input);

            NUnit.Framework.Assert.AreEqual(expected, actual);
        }
Ejemplo n.º 7
0
        public virtual void CommaSplitValueTest()
        {
            String         input    = "a,b,c,d";
            IList <String> expected = new List <String>();

            expected.Add("a");
            expected.Add("b");
            expected.Add("c");
            expected.Add("d");
            IList <String> actual = SvgCssUtils.SplitValueList(input);

            NUnit.Framework.Assert.AreEqual(expected, actual);
        }
Ejemplo n.º 8
0
        public virtual void MixedCommaWhitespaceSplitValueTest()
        {
            String         input    = "1,2 a,b";
            IList <String> expected = new List <String>();

            expected.Add("1");
            expected.Add("2");
            expected.Add("a");
            expected.Add("b");
            IList <String> actual = SvgCssUtils.SplitValueList(input);

            NUnit.Framework.Assert.AreEqual(expected, actual);
        }
Ejemplo n.º 9
0
        public virtual void LeadingAndTrailingWhiteSpaceTest()
        {
            String         input    = "          -140.465,-116.438 -163.725,-103.028 -259.805,-47.618         ";
            IList <String> expected = new List <String>();

            expected.Add("-140.465");
            expected.Add("-116.438");
            expected.Add("-163.725");
            expected.Add("-103.028");
            expected.Add("-259.805");
            expected.Add("-47.618");
            IList <String> actual = SvgCssUtils.SplitValueList(input);

            NUnit.Framework.Assert.AreEqual(expected, actual);
        }
Ejemplo n.º 10
0
 /// <summary>Converts relative coordinates to absolute ones.</summary>
 /// <remarks>
 /// Converts relative coordinates to absolute ones. Assumes that relative coordinates are represented by
 /// an array of coordinates with length proportional to the length of current coordinates array,
 /// so that current coordinates array is applied in segments to the relative coordinates array
 /// </remarks>
 /// <param name="relativeCoordinates">the initial set of coordinates</param>
 /// <param name="currentCoordinates">an array representing the point relative to which the relativeCoordinates are defined
 ///     </param>
 /// <returns>a String array of absolute coordinates, with the same length as the input array</returns>
 public static String[] MakeRelativeOperatorCoordinatesAbsolute(String[] relativeCoordinates, double[] currentCoordinates
                                                                )
 {
     if (relativeCoordinates.Length % currentCoordinates.Length != 0)
     {
         throw new ArgumentException(SvgExceptionMessageConstant.COORDINATE_ARRAY_LENGTH_MUST_BY_DIVISIBLE_BY_CURRENT_COORDINATES_ARRAY_LENGTH
                                     );
     }
     String[] absoluteOperators = new String[relativeCoordinates.Length];
     for (int i = 0; i < relativeCoordinates.Length;)
     {
         for (int j = 0; j < currentCoordinates.Length; j++, i++)
         {
             double relativeDouble = Double.Parse(relativeCoordinates[i], System.Globalization.CultureInfo.InvariantCulture
                                                  );
             relativeDouble      += currentCoordinates[j];
             absoluteOperators[i] = SvgCssUtils.ConvertDoubleToString(relativeDouble);
         }
     }
     return(absoluteOperators);
 }
Ejemplo n.º 11
0
        /// <summary>This method extracts the values from a transformation.</summary>
        /// <param name="transformation">the transformation</param>
        /// <returns>values of the transformation</returns>
        private static IList <String> GetValuesFromTransformationString(String transformation)
        {
            String numbers = transformation.JSubstring(transformation.IndexOf('(') + 1, transformation.IndexOf(')'));

            return(SvgCssUtils.SplitValueList(numbers));
        }
Ejemplo n.º 12
0
        public virtual void EmptySplitValueTest()
        {
            IList <String> actual = SvgCssUtils.SplitValueList("");

            NUnit.Framework.Assert.IsTrue(actual.IsEmpty());
        }