public void testCycSymbol() {
    System.out.println("\n*** testCycSymbol ***");
    CycObjectFactory.resetCycSymbolCache();
    assertEquals(CycObjectFactory.RESET_SYMBOL_CACHE_SIZE, CycObjectFactory.getCycSymbolCacheSize());
    String symbolName = "WHY-ISA?";
    CycSymbol cycSymbol = CycObjectFactory.makeCycSymbol(symbolName);
    assertEquals(CycObjectFactory.RESET_SYMBOL_CACHE_SIZE + 1, CycObjectFactory.getCycSymbolCacheSize());
    assertEquals(symbolName, cycSymbol.toString());
    assertNotNull(CycObjectFactory.getCycSymbolCache(symbolName));
    CycSymbol cycSymbol2 = CycObjectFactory.getCycSymbolCache(symbolName);
    assertEquals(cycSymbol, cycSymbol2);
    CycSymbol cycSymbol3 = CycObjectFactory.makeCycSymbol(symbolName);
    assertEquals(cycSymbol, cycSymbol3);
    assertEquals(CycObjectFactory.RESET_SYMBOL_CACHE_SIZE + 1, CycObjectFactory.getCycSymbolCacheSize());
    String symbolName4 = "WHY-ISA?";
    CycSymbol cycSymbol4 = CycObjectFactory.makeCycSymbol(symbolName4);
    assertEquals(cycSymbol.toString(), cycSymbol4.toString());
    assertEquals(cycSymbol, cycSymbol4);
    try {
      testCycObjectRetrievable(cycSymbol);
    } catch (Exception ex) {
      failWithException(ex);
    }

    // compareTo
    ArrayList symbols = new ArrayList();
    symbols.add(CycObjectFactory.makeCycSymbol("isa?"));
    symbols.add(CycObjectFactory.makeCycSymbol("define-private"));
    symbols.add(CycObjectFactory.makeCycSymbol("nil"));
    Collections.sort(symbols);
    assertEquals("[DEFINE-PRIVATE, ISA?, NIL]", symbols.toString());

    // isKeyword
    CycSymbol cycSymbol5 = CycObjectFactory.makeCycSymbol("nil");
    assertFalse(cycSymbol5.isKeyword());
    CycSymbol cycSymbol6 = CycObjectFactory.makeCycSymbol(":pos");
    assertTrue(cycSymbol6.isKeyword());

    // isValidSymbolName
    assertTrue(CycSymbol.isValidSymbolName("t"));
    assertTrue(CycSymbol.isValidSymbolName("nil"));
    assertTrue(CycSymbol.isValidSymbolName("a_"));
    assertTrue(CycSymbol.isValidSymbolName("a-b"));
    assertTrue(CycSymbol.isValidSymbolName("a-b"));
    assertTrue(CycSymbol.isValidSymbolName("a-9b"));
    assertTrue(CycSymbol.isValidSymbolName("*MY-SYMBOL*"));
    assertFalse(CycSymbol.isValidSymbolName(" "));
    assertFalse(CycSymbol.isValidSymbolName("#$Brazil"));
    assertFalse(CycSymbol.isValidSymbolName("\"a-string\""));

    //packages
    CycSymbol symbol7 = new CycSymbol("CYC", "BLAH");
    CycSymbol symbol8 = new CycSymbol("|CYC|", "BLAH");
    CycSymbol symbol9 = new CycSymbol("CYC", "|BLAH|");
    CycSymbol symbol10 = new CycSymbol("|CYC|", "|BLAH|");
    assertEquals("CYC", symbol7.getPackageName());
    assertEquals("CYC", symbol8.getPackageName());
    assertEquals("CYC", symbol9.getPackageName());
    assertEquals("CYC", symbol10.getPackageName());
    assertEquals("CYC", symbol7.getPackageNamePrecise());
    assertEquals("CYC", symbol8.getPackageNamePrecise());
    assertEquals("CYC", symbol9.getPackageNamePrecise());
    assertEquals("CYC", symbol10.getPackageNamePrecise());
    assertEquals("BLAH", symbol7.getSymbolName());
    assertEquals("BLAH", symbol8.getSymbolName());
    assertEquals("BLAH", symbol9.getSymbolName());
    assertEquals("BLAH", symbol10.getSymbolName());
    assertEquals("BLAH", symbol7.getSymbolNamePrecise());
    assertEquals("BLAH", symbol8.getSymbolNamePrecise());
    assertEquals("BLAH", symbol9.getSymbolNamePrecise());
    assertEquals("BLAH", symbol10.getSymbolNamePrecise());
    assertEquals(symbol7, symbol8);
    assertEquals(symbol7, symbol9);
    assertEquals(symbol7, symbol10);
    assertEquals("BLAH", symbol7.toString());
    assertEquals("BLAH", symbol8.toString());
    assertEquals("BLAH", symbol9.toString());
    assertEquals("BLAH", symbol10.toString());
    assertEquals("CYC:BLAH", symbol7.toFullStringForced());
    assertEquals("CYC:BLAH", symbol8.toFullStringForced());
    assertEquals("CYC:BLAH", symbol9.toFullStringForced());
    assertEquals("CYC:BLAH", symbol10.toFullStringForced());
    assertEquals("CYC:BLAH", symbol7.toFullString("SL"));
    assertEquals("CYC:BLAH", symbol8.toFullString("SL"));
    assertEquals("CYC:BLAH", symbol9.toFullString("SL"));
    assertEquals("CYC:BLAH", symbol10.toFullString("SL"));
    assertEquals("BLAH", symbol10.toFullString("CYC"));
    assertFalse(symbol7.isKeyword());
    assertFalse(symbol8.isKeyword());
    assertFalse(symbol9.isKeyword());
    assertFalse(symbol10.isKeyword());

    CycSymbol symbol11 = new CycSymbol("|CYC RuLeS|", "|BLAH BiTeS|");
    CycSymbol symbol12 = new CycSymbol("CYC RuLeS", "BLAH BiTeS");
    assertEquals("CYC RuLeS", symbol11.getPackageName());
    assertEquals("CYC RuLeS", symbol12.getPackageName());
    assertEquals("|CYC RuLeS|", symbol11.getPackageNamePrecise());
    assertEquals("|CYC RuLeS|", symbol12.getPackageNamePrecise());
    assertEquals("BLAH BiTeS", symbol11.getSymbolName());
    assertEquals("BLAH BiTeS", symbol12.getSymbolName());
    assertEquals("|BLAH BiTeS|", symbol11.getSymbolNamePrecise());
    assertEquals("|BLAH BiTeS|", symbol12.getSymbolNamePrecise());
    assertEquals(symbol11, symbol12);
    assertEquals("|BLAH BiTeS|", symbol11.toString());
    assertEquals("|BLAH BiTeS|", symbol12.toString());
    assertEquals("|CYC RuLeS|:|BLAH BiTeS|", symbol11.toFullStringForced());
    assertEquals("|CYC RuLeS|:|BLAH BiTeS|", symbol12.toFullStringForced());
    assertEquals("|CYC RuLeS|:|BLAH BiTeS|", symbol11.toFullString("SL"));
    assertEquals("|CYC RuLeS|:|BLAH BiTeS|", symbol12.toFullString("SL"));
    assertEquals("|BLAH BiTeS|", symbol12.toFullString("CYC RuLeS"));
    assertFalse(symbol11.isKeyword());
    assertFalse(symbol12.isKeyword());

    CycSymbol symbol13 = new CycSymbol("KEYWORD", "BLAH");
    CycSymbol symbol14 = new CycSymbol("|KEYWORD|", "BLAH");
    CycSymbol symbol15 = new CycSymbol("", ":BLAH");
    CycSymbol symbol16 = new CycSymbol(null, ":BLAH");
    assertEquals("KEYWORD", symbol13.getPackageName());
    assertEquals("KEYWORD", symbol14.getPackageName());
    assertEquals("KEYWORD", symbol15.getPackageName());
    assertEquals("KEYWORD", symbol16.getPackageName());
    assertEquals("KEYWORD", symbol13.getPackageNamePrecise());
    assertEquals("KEYWORD", symbol14.getPackageNamePrecise());
    assertEquals("KEYWORD", symbol15.getPackageNamePrecise());
    assertEquals("KEYWORD", symbol16.getPackageNamePrecise());
    assertEquals("BLAH", symbol13.getSymbolName());
    assertEquals("BLAH", symbol14.getSymbolName());
    assertEquals("BLAH", symbol15.getSymbolName());
    assertEquals("BLAH", symbol16.getSymbolName());
    assertEquals("BLAH", symbol13.getSymbolNamePrecise());
    assertEquals("BLAH", symbol14.getSymbolNamePrecise());
    assertEquals("BLAH", symbol15.getSymbolNamePrecise());
    assertEquals("BLAH", symbol16.getSymbolNamePrecise());
    assertEquals(symbol13, symbol14);
    assertEquals(symbol13, symbol15);
    assertEquals(symbol13, symbol16);
    assertEquals(":BLAH", symbol13.toString());
    assertEquals(":BLAH", symbol14.toString());
    assertEquals(":BLAH", symbol15.toString());
    assertEquals(":BLAH", symbol16.toString());
    assertEquals("KEYWORD:BLAH", symbol13.toFullStringForced());
    assertEquals("KEYWORD:BLAH", symbol14.toFullStringForced());
    assertEquals("KEYWORD:BLAH", symbol15.toFullStringForced());
    assertEquals("KEYWORD:BLAH", symbol16.toFullStringForced());
    assertEquals(":BLAH", symbol13.toFullString("SL"));
    assertEquals(":BLAH", symbol14.toFullString("SL"));
    assertEquals(":BLAH", symbol15.toFullString("SL"));
    assertEquals(":BLAH", symbol16.toFullString("SL"));
    assertEquals(":BLAH", symbol16.toFullString("KEYWORD"));
    assertTrue(symbol13.isKeyword());
    assertTrue(symbol14.isKeyword());
    assertTrue(symbol15.isKeyword());
    assertTrue(symbol16.isKeyword());

    // toXML, toXMLString, unmarshall
    XMLStringWriter xmlStringWriter = new XMLStringWriter();
    try {
      cycSymbol6.toXML(xmlStringWriter, 0, false);
      assertEquals("<symbol>:POS</symbol>\n", xmlStringWriter.toString());
      assertEquals("<symbol>:POS</symbol>\n", cycSymbol6.toXMLString());
      String cycSymbolXMLString = cycSymbol6.toXMLString();
      Object object = CycObjectFactory.unmarshall(cycSymbolXMLString);
      assertTrue(object instanceof CycSymbol);
      assertEquals(cycSymbol6, (CycSymbol) object);
    } catch (Exception e) {
      failWithException(e);
    }

    System.out.println("*** testCycSymbol OK ***");
  }