⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 iclstrtest.java

📁 SRI international 发布的OAA框架软件
💻 JAVA
字号:
package com.sri.oaa2.test.icl;

import junit.framework.TestCase;
import junit.framework.Assert;
import com.sri.oaa2.icl.IclStr;

/**
 * Author: Chris Brigham (cbrigham)
 * Date: Jun 29, 2004
 * Time: 9:04:54 AM
 * Description: TestCase for IclStr class that tests escaping of single and double quotes
 *              using toQuotedString(), toUnquotedString() and equals(IclStr).
 */
public class IclStrTest extends TestCase {

    String[] strings = {
        "oneword",
        "spaced words",
        "'quotedword'",
        "unquoted 'quoted' other",
        "'unbalanced' single'",
        "'two' 'singles'",
        "''",
        "'",
        "\"doublequote\"",
        "word \"doublequote\" unbalance\""
    };

    String[] quotedstrings = {
        "oneword",
        "'spaced words'",
        "'quotedword'",
        "'unquoted ''quoted'' other'",
        "'unbalanced' single'",
        "'two' 'singles'",
        "''",
        "''''",
        "'\"doublequote\"'",
        "'word \"doublequote\" unbalance\"'"
    };

    String[] unquotedstrings = {
        "oneword",
        "spaced words",
        "quotedword",
        "unquoted 'quoted' other",
        "'unbalanced' single'",
        "'two' 'singles'",
        "",
        "'",
        "\"doublequote\"",
        "word \"doublequote\" unbalance\""
    };

    public IclStrTest(String testname){
        super(testname);
    }

    public void testToQuotedString(){
        IclStr iclstr;
        for(int i=0; i<strings.length; i++){
            iclstr = new IclStr(strings[i]);
            Assert.assertTrue("String was not quoted properly", quotedstrings[i].equals(iclstr.toQuotedString()));
        }
    }

    public void testToUnquotedString(){
        IclStr iclstr;
        for(int i=0; i<strings.length; i++){
            iclstr = new IclStr(strings[i]);
            Assert.assertTrue("Unquoted string does not match input string", unquotedstrings[i].equals(iclstr.toUnquotedString()));
        }
    }

    public void testEquals(){
        IclStr iclstr1 = new IclStr("iclstr test");
        IclStr iclstr2 = new IclStr("'iclstr test'");

        Assert.assertTrue(!iclstr1.equals(null));
        Assert.assertTrue(iclstr1.equals(iclstr1));
        Assert.assertTrue(iclstr1.equals(iclstr2));
        Assert.assertTrue(!iclstr1.equals(new IclStr("blah")));
    }



}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -