public void TestCISPrep() { for (int i = 0; i < (TestData.conformanceTestCases.Length); i++) { TestData.ConformanceTestCase testCase = TestData.conformanceTestCases[i]; String src = testCase.input; Exception expected = testCase.expected; String expectedDest = testCase.output; try { byte[] dest = NFS4StringPrep.CISPrepare(Encoding.UTF8.GetBytes(src)); String destString = Encoding.UTF8.GetString(dest); if (!expectedDest.Equals(destString, StringComparison.OrdinalIgnoreCase)) { Errln("Did not get the expected output for nfs4_cis_prep at index " + i); } } catch (Exception e) { if (expected != null && !expected.Equals(e)) { Errln("Did not get the expected exception: " + e.ToString()); } } } }
public void TestConformance() { try { for (int i = 0; i < TestData.conformanceTestCases.Length; i++) { TestData.ConformanceTestCase testCase = TestData.conformanceTestCases[i]; if (testCase.expected != null) { //Test toASCII DoTestToASCII(testCase.input, testCase.output, IDNAReference.DEFAULT, testCase.expected); DoTestToASCII(testCase.input, testCase.output, IDNAReference.ALLOW_UNASSIGNED, testCase.expected); } //Test toUnicode //doTestToUnicode(testCase.input,testCase.output,IDNAReference.DEFAULT,testCase.expected); } } catch (TypeInitializationException ex) { Warnln("Could not load NamePrepTransform data"); } catch (TypeLoadException ex) { Warnln("Could not load NamePrepTransform data"); } }
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"); } }