internal void Fail(String text, int index, int offset, Type exc) { try { UChar.OffsetByCodePoints(text, index, offset); Errln("unexpected success " + Str(text, index, offset, 0, text.Length)); } catch (Exception e) { //if (!exc.isInstance(e)) bool isAssignableFrom = #if FEATURE_TYPEEXTENSIONS_GETTYPEINFO exc.GetTypeInfo().IsAssignableFrom(e.GetType()); #else exc.IsAssignableFrom(e.GetType()); #endif if (!isAssignableFrom) { Errln("bad exception " + Str(text, 0, text.Length, index, offset) + e.GetType().Name); } } }
internal void Test(String s, int start, int count, int index, int offset, int expected, bool flip) { char[] chars = s.ToCharArray(); String strng = s.Substring(start, count); // ICU4N: (start + count) - start == count int val1 = UChar.OffsetByCodePoints(chars, start, count, index, offset); int val2 = UChar.OffsetByCodePoints(strng, index - start, offset) + start; if (val1 != expected) { TestFmwk.Errln("char[] " + Str(s, start, count, index, offset) + "(" + val1 + ") != " + expected); } else if (val2 != expected) { TestFmwk.Errln("String " + Str(s, start, count, index, offset) + "(" + val2 + ") != " + expected); } else if (TestFmwk.IsVerbose()) { TestFmwk.Logln(Str(s, start, count, index, offset) + " == " + expected); } if (flip) { val1 = UChar.OffsetByCodePoints(chars, start, count, expected, -offset); val2 = UChar.OffsetByCodePoints(strng, expected - start, -offset) + start; if (val1 != index) { TestFmwk.Errln("char[] " + Str(s, start, count, expected, -offset) + "(" + val1 + ") != " + index); } else if (val2 != index) { TestFmwk.Errln("String " + Str(s, start, count, expected, -offset) + "(" + val2 + ") != " + index); } else if (TestFmwk.IsVerbose()) { TestFmwk.Logln(Str(s, start, count, expected, -offset) + " == " + index); } } }
internal void Fail(String text, int index, int offset, Type exc) { try { UChar.OffsetByCodePoints(text, index, offset); Errln("unexpected success " + Str(text, index, offset, 0, text.Length)); } catch (Exception e) { //if (!exc.isInstance(e)) if (!exc.IsAssignableFrom(e.GetType())) { Errln("bad exception " + Str(text, 0, text.Length, index, offset) + e.GetType().Name); } } }
internal void Fail(char[] text, int start, int count, int index, int offset, Type exc) { try { UChar.OffsetByCodePoints(text, start, count, index, offset); Errln("unexpected success " + Str(new String(text), start, count, index, offset)); } catch (Exception e) { //if (!exc.isInstance(e)) if (!exc.IsAssignableFrom(e.GetType())) { Errln("bad exception " + Str(new String(text), start, count, index, offset) + e.GetType().Name); } } }