fromstringtest.java

来自「SRI international 发布的OAA框架软件」· Java 代码 · 共 71 行

JAVA
71
字号
/* 
 * Local Variables:
 * c-basic-offset:2
 * tab-width:2
 * indent-tabs-mode:nil
 * End:
 */
package com.sri.oaa2.test.icl;

import com.sri.oaa2.icl.*;

import junit.framework.TestCase;

/**
 * @author agno
 *
 */
public class FromStringTest extends TestCase 
{
  static String[] strings = {
    "a",
    "1",
    "1.0",
    "V",
    "_",
    "hello(there)",
    "{hello}",
    "[hello]",
    "'spaces spaces'",
    "a + b",
    "a :- b",
    ":-(a,b)",
    "{hello,there}",
    "[hello, there]",
    "{g1, 5, _9}",
    "'blah''blah'",
    "hello([there,blah, blah],'blah''blah',{1.5, another(struct,[nested])})",
    "icldataq(\"blah blah\")",
    "<(_6025,43)",
    "[a|V]"
  }
  ;

  public FromStringTest(String arg0)
  {
    super(arg0);
  }

  public void testFromString() 
  {
    for(int i = 0; i < strings.length; ++i) {
      try {
        IclTerm t = IclTerm.fromString(strings[i]);
        TestCase.assertTrue(t != null);
        System.out.println(t.toString());
      }
      catch(Exception e) {
        System.out.println("Bad String " + strings[i] + " " + e.toString());
        e.printStackTrace();
        TestCase.assertTrue(false);
      }
    }
  }
  
  public void testNullString()
  {
    IclTerm t = IclTerm.fromString(true, "");
    TestCase.assertTrue(t == null);
  }
}

⌨️ 快捷键说明

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