Package com.ibm.icu.text

Examples of com.ibm.icu.text.StringPrep


            //Test toUnicode
            //doTestToUnicode(testCase.input,testCase.output,IDNA.DEFAULT,testCase.expected);
        }
    }
    public void TestNamePrepConformance() throws Exception{
        StringPrep namePrep = StringPrep.getInstance(StringPrep.RFC3491_NAMEPREP);
        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,StringPrep.DEFAULT);
                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,StringPrep.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)){
View Full Code Here


    private  NFS4StringPrep (){
        ClassLoader loader = NFS4StringPrep.class.getClassLoader();
        try{
            InputStream  nfscsiFile = loader.getResourceAsStream("com/ibm/icu/dev/data/testdata/nfscsi.spp");
            nfscsi = new StringPrep(nfscsiFile);
            nfscsiFile.close();
           
            InputStream  nfscssFile = loader.getResourceAsStream("com/ibm/icu/dev/data/testdata/nfscss.spp");
            nfscss = new StringPrep(nfscssFile);
            nfscssFile.close();
           
            InputStream  nfscisFile = loader.getResourceAsStream("com/ibm/icu/dev/data/testdata/nfscis.spp");
            nfscis = new StringPrep(nfscisFile);
            nfscisFile.close();
           
            InputStream  nfsmxpFile = loader.getResourceAsStream("com/ibm/icu/dev/data/testdata/nfsmxp.spp");
            nfsmxp = new StringPrep(nfsmxpFile);
            nfsmxpFile.close();
           
            InputStream  nfsmxsFile = loader.getResourceAsStream("com/ibm/icu/dev/data/testdata/nfsmxs.spp");
            nfsmxs = new StringPrep(nfsmxsFile);
            nfsmxsFile.close();
        }catch(IOException e){
            throw new MissingResourceException(e.toString(),"","");
        }
    }
View Full Code Here

        return -1;
    }
   
    public void TestProfiles() {
        String profileName = null;
        StringPrep sprep = null;
        String result = null;
        String src = null;
        String expected = null;
       
        for (int i = 0; i < testCases.length; i++) {
            for (int j = 0; j < testCases[i].length; j++) {
                if (j == 0) {
                    profileName = testCases[i][j];
                   
                    sprep = StringPrep.getInstance(getOptionFromProfileName(profileName));
                } else {
                    src = testCases[i][j];
                    expected = testCases[i][++j];
                    try {
                        result = sprep.prepare(src, StringPrep.ALLOW_UNASSIGNED);
                        if (src.startsWith("FAIL")) {
                            errln("Failed: Expected error for Test[" + i +"] Profile: " + profileName);
                        } else if (!result.equals(expected)) {
                            errln("Failed: Test[" + i + "] Result string does not match expected string for StringPrep test for profile: " + profileName);
                        }
View Full Code Here

TOP

Related Classes of com.ibm.icu.text.StringPrep

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.