private static int GetSeparatorIndex(char[] src, int start, int limit) { for (; start < limit; start++) { if (NamePrepTransform.IsLabelSeparator(src[start])) { return(start); } } // we have not found the separator just return length return(start); }
public void TestNamePrepConformance() { try { NamePrepTransform namePrep = NamePrepTransform.GetInstance(); if (!namePrep.IsReady) { Logln("Transliterator is not available on this environment."); return; } for (int i = 0; i < TestData.conformanceTestCases.Length; i++) { TestData.ConformanceTestCase testCase = TestData.conformanceTestCases[i]; UCharacterIterator iter = UCharacterIterator.GetInstance(testCase.input); try { StringBuffer output = namePrep.Prepare(iter, NamePrepTransform.NONE); if (testCase.output != null && output != null && !testCase.output.Equals(output.ToString())) { Errln("Did not get the expected output. Expected: " + Prettify(testCase.output) + " Got: " + Prettify(output)); } if (testCase.expected != null && !unassignedException.Equals(testCase.expected)) { Errln("Did not get the expected exception. The operation succeeded!"); } } catch (StringPrepParseException ex) { if (testCase.expected == null || !ex.Equals(testCase.expected)) { Errln("Did not get the expected exception for source: " + testCase.input + " Got: " + ex.ToString()); } } try { iter.SetToStart(); StringBuffer output = namePrep.Prepare(iter, NamePrepTransform.ALLOW_UNASSIGNED); if (testCase.output != null && output != null && !testCase.output.Equals(output.ToString())) { Errln("Did not get the expected output. Expected: " + Prettify(testCase.output) + " Got: " + Prettify(output)); } if (testCase.expected != null && !unassignedException.Equals(testCase.expected)) { Errln("Did not get the expected exception. The operation succeeded!"); } } catch (StringPrepParseException ex) { if (testCase.expected == null || !ex.Equals(testCase.expected)) { Errln("Did not get the expected exception for source: " + testCase.input + " Got: " + ex.ToString()); } } } } catch (TypeInitializationException e) { Warnln("Could not load NamePrepTransformData"); } catch (TypeLoadException ex) { Warnln("Could not load NamePrepTransform data"); } }