Beispiel #1
0
        public void TestStringPrepParseExceptionEquals()
        {
            StringPrepParseException sppe       = new StringPrepParseException("dummy", 0, "dummy", 0, 0);
            StringPrepParseException sppe_clone = new StringPrepParseException("dummy", 0, "dummy", 0, 0);
            StringPrepParseException sppe1      = new StringPrepParseException("dummy1", (StringPrepErrorType)1, "dummy1", 0, 0);

            // Tests when "if(!(other instanceof StringPrepParseException))" is true
            if (sppe.Equals(0))
            {
                Errln("StringPrepParseException.Equals(Object) is suppose to return false when " +
                      "passing integer '0'");
            }
            if (sppe.Equals(0.0))
            {
                Errln("StringPrepParseException.Equals(Object) is suppose to return false when " +
                      "passing float/double '0.0'");
            }
            if (sppe.Equals("0"))
            {
                Errln("StringPrepParseException.Equals(Object) is suppose to return false when " +
                      "passing string '0'");
            }

            // Tests when "if(!(other instanceof StringPrepParseException))" is true
            if (!sppe.Equals(sppe))
            {
                Errln("StringPrepParseException.Equals(Object) is suppose to return true when " +
                      "comparing to the same object");
            }
            if (!sppe.Equals(sppe_clone))
            {
                Errln("StringPrepParseException.Equals(Object) is suppose to return true when " +
                      "comparing to the same initiated object");
            }
            if (sppe.Equals(sppe1))
            {
                Errln("StringPrepParseException.Equals(Object) is suppose to return false when " +
                      "comparing to another object that isn't the same");
            }
        }
Beispiel #2
0
        private void DoTestToUnicode(String src, String expected, IDNA2003Options options, Object expectedException)
        {
            if (!IDNAReference.IsReady)
            {
                Logln("Transliterator is not available on this environment.  Skipping doTestToUnicode.");
                return;
            }

            StringBuffer       inBuf  = new StringBuffer(src);
            UCharacterIterator inIter = UCharacterIterator.GetInstance(src);

            try
            {
                StringBuffer @out = IDNAReference.ConvertToUnicode(src, options);
                if (expected != null && @out != null && [email protected]().Equals(expected))
                {
                    Errln("convertToUnicode did not return expected result with options : " + options +
                          " Expected: " + Prettify(expected) + " Got: " + Prettify(@out));
                }
                if (expectedException != null && !unassignedException.Equals(expectedException))
                {
                    Errln("convertToUnicode did not get the expected exception. The operation succeeded!");
                }
            }
            catch (StringPrepParseException ex)
            {
                if (expectedException == null || !ex.Equals(expectedException))
                {
                    Errln("convertToUnicode did not get the expected exception for source: " + Prettify(src) + " Got:  " + ex.ToString());
                }
            }
            try
            {
                StringBuffer @out = IDNAReference.ConvertToUnicode(inBuf, options);
                if (expected != null && @out != null && [email protected]().Equals(expected))
                {
                    Errln("convertToUnicode did not return expected result with options : " + options +
                          " Expected: " + Prettify(expected) + " Got: " + @out);
                }
                if (expectedException != null && !unassignedException.Equals(expectedException))
                {
                    Errln("convertToUnicode did not get the expected exception. The operation succeeded!");
                }
            }
            catch (StringPrepParseException ex)
            {
                if (expectedException == null || !ex.Equals(expectedException))
                {
                    Errln("convertToUnicode did not get the expected exception for source: " + Prettify(src) + " Got:  " + ex.ToString());
                }
            }

            try
            {
                StringBuffer @out = IDNAReference.ConvertToUnicode(inIter, options);
                if (expected != null && @out != null && [email protected]().Equals(expected))
                {
                    Errln("convertToUnicode did not return expected result with options : " + options +
                          " Expected: " + Prettify(expected) + " Got: " + Prettify(@out));
                }
                if (expectedException != null && !unassignedException.Equals(expectedException))
                {
                    Errln("Did not get the expected exception. The operation succeeded!");
                }
            }
            catch (StringPrepParseException ex)
            {
                if (expectedException == null || !ex.Equals(expectedException))
                {
                    Errln("Did not get the expected exception for source: " + Prettify(src) + " Got:  " + ex.ToString());
                }
            }
        }