Ejemplo n.º 1
0
  public void testTypedefClass() {
    String content =
        "class foobar;\n"
            + "\n"
            + "    typedef class other_foo_t;\n"
            + "    typedef class other_foo_t1;\n"
            + "    typedef class other_foo_t2;\n"
            + "    typedef class other_foo_t3;\n"
            + "    typedef class other_foo_t4;\n"
            + "\n"
            + "    other_foo_t	    foo_f;"
            + "\n"
            + "endclass\n";

    SVDBFile file = SVDBTestUtils.parse(content, "testClassStringFields");

    SVDBClassDecl foobar = null;
    for (ISVDBItemBase it : file.getChildren()) {
      if (SVDBItem.getName(it).equals("foobar")) {
        foobar = (SVDBClassDecl) it;
        break;
      }
    }

    SVDBTypedefStmt foobar_td = null;
    ISVDBItemBase foobar_i = null;
    ISVDBItemBase foobar_i1 = null;

    for (ISVDBItemBase it : foobar.getChildren()) {
      if (SVDBItem.getName(it).equals("other_foo_t")) {
        foobar_i = it;
      } else if (SVDBItem.getName(it).equals("other_foo_t1")) {
        foobar_i1 = it;
      }
    }

    assertNotNull("Failed to find other_foo_t", foobar_i);
    assertNotNull("Failed to find other_foo_t1", foobar_i1);
    assertEquals("other_foo_t is of wrong type", foobar_i.getType(), SVDBItemType.TypedefStmt);

    foobar_td = (SVDBTypedefStmt) foobar_i;

    assertEquals(
        "other_foo_t type-info is of wrong type",
        SVDBItemType.TypeInfoFwdDecl,
        foobar_td.getTypeInfo().getType());
  }
Ejemplo n.º 2
0
  public void testTypedef() {
    String content =
        "class foobar;\n"
            + "\n"
            + "    typedef enum {\n"
            + "        FOO,\n"
            + "        BAR\n"
            + "    } foobar_t;\n"
            + "\n"
            + "\n"
            + "    foobar_t     foo_f;"
            + "\n"
            + "endclass\n";

    SVDBFile file = SVDBTestUtils.parse(content, "testClassStringFields");

    SVDBClassDecl foobar = null;
    for (ISVDBItemBase it : file.getChildren()) {
      if (SVDBItem.getName(it).equals("foobar")) {
        foobar = (SVDBClassDecl) it;
        break;
      }
    }

    SVDBTypedefStmt foobar_td = null;
    ISVDBItemBase foobar_i = null;

    for (ISVDBItemBase it : foobar.getChildren()) {
      if (SVDBItem.getName(it).equals("foobar_t")) {
        foobar_i = it;
      }
    }

    assertNotNull("Failed to find foobar_t", foobar_i);
    assertEquals("foobar_t is of wrong type", foobar_i.getType(), SVDBItemType.TypedefStmt);

    foobar_td = (SVDBTypedefStmt) foobar_i;

    assertEquals(
        "foobar_t type-info is of wrong type",
        SVDBItemType.TypeInfoEnum,
        foobar_td.getTypeInfo().getType());

    SVDBTypeInfoEnum enum_t = (SVDBTypeInfoEnum) foobar_td.getTypeInfo();
    assertEquals(
        "foobar_t doesn't have correct number of elements", 2, enum_t.getEnumerators().size());
  }