Exemplo n.º 1
0
        protected string FormatComparison(double v0, string compare, double v1,
                                          string initFormat,
                                          string expressionString)
        {
            if (initFormat == null)
            {
                initFormat = NumberFormat;
            }

            return(FormatUtils.FormatComparison(initFormat, v0, v1, compare,
                                                expressionString));
        }
Exemplo n.º 2
0
        public void FormatComparisonTest()
        {
            CultureInfo origCulture = Thread.CurrentThread.CurrentCulture;

            try
            {
                Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;

                string expression;

                expression = FormatUtils.FormatComparison("N0", 1.4, 2.3, "<", "{0} {1} {2}");
                Assert.AreEqual("1 < 2", expression);

                expression = FormatUtils.FormatComparison("N0", 0.8, 1.1, "<", "{0} {1} {2}");
                Assert.AreEqual("0.8 < 1.1", expression);

                expression = FormatUtils.FormatComparison("N0", 0.3, 0.6, "<", "{0} {1} {2}");
                Assert.AreEqual("0.3 < 0.6", expression);

                expression = FormatUtils.FormatComparison("N0", Math.E, Math.PI, "<",
                                                          "{0} {1} {2}");
                Assert.AreEqual("2.7 < 3.1", expression);

                expression = FormatUtils.FormatComparison("N0", Math.PI, 355.0 / 113.0, "<",
                                                          "{0} {1} {2}");
                Assert.AreEqual("3.1415927 < 3.1415929", expression);

                expression = FormatUtils.FormatComparison("N0", 4.998, 5, "<", "{0} {1} {2}");
                Assert.AreEqual("4.998 < 5.000", expression);

                expression = FormatUtils.FormatComparison("N0", 3.93, 3.95, "<", "{0} {1} {2}");
                Assert.AreEqual("3.93 < 3.95", expression);

                expression = FormatUtils.FormatComparison("N0", 3.95, 3.94, ">", "{0} {1} {2}");
                Assert.AreEqual("3.95 > 3.94", expression);

                expression = FormatUtils.FormatComparison("N0", 3.99, 3.94, ">", "{0} {1} {2}");
                Assert.AreEqual("4.0 > 3.9", expression);

                expression = FormatUtils.FormatComparison("E0", 3.33e-50, 3.34e-50, "<",
                                                          "{0} {1} {2}");
                Assert.AreEqual("3.33E-050 < 3.34E-050", expression);

                expression = FormatUtils.FormatComparison("N0", 0.0314, 0.5, "<", "{0} {1} {2}");
                Assert.AreEqual("0.03 < 0.5", expression);

                expression = FormatUtils.FormatComparison("N0", 0.00294, 0.5, "<", "{0} {1} {2}");
                Assert.AreEqual("0.003 < 0.5", expression);

                expression = FormatUtils.FormatComparison("N0", 0.0003294, 0.5, "<", "{0} {1} {2}");
                Assert.AreEqual("0.0003 < 0.5", expression);

                expression = FormatUtils.FormatComparison("N0", 0.00003294, 0.5, "<",
                                                          "{0} {1} {2}");
                Assert.AreEqual("3.3E-5 < 0.5", expression);

                // https://issuetracker01.dev.esri-de.com/browse/TOP-3936:
                expression = FormatUtils.FormatComparison("N0", 1228.5, 1250.0, "<", "{0} {1} {2}");
                Assert.AreEqual("1,229 < 1,250", expression);

                expression = FormatUtils.FormatComparison("N0", double.NegativeInfinity, 0.1, "<",
                                                          "{0} {1} {2}");
                Assert.AreEqual("-Infinity < 0.1", expression);

                expression = FormatUtils.FormatComparison("N0", 3000.0, double.PositiveInfinity,
                                                          "<",
                                                          "{0} {1} {2}");
                Assert.AreEqual("3,000 < Infinity", expression);

                // TODO: Revise
                expression = FormatUtils.FormatComparison("N0", double.NaN, 0.1, "<",
                                                          "{0} {1} {2}");
                Assert.AreEqual("NaN < 0.1", expression);
            }
            finally
            {
                Thread.CurrentThread.CurrentCulture = origCulture;
            }
        }