Package com.google.test.metric.cpp.dom

Examples of com.google.test.metric.cpp.dom.TranslationUnit


  public void addClass(ClassInfo classInfo) {
    classes.put(classInfo.getName(), classInfo);
  }

  void parse(InputStream in) throws Exception {
    TranslationUnit unit = new Parser().parse(in);
    ClassInfoBuilder builder = new ClassInfoBuilder(this);
    unit.accept(builder);
  }
View Full Code Here


    ClassInfoBuilder builder = new ClassInfoBuilder(this);
    unit.accept(builder);
  }

  public void parse(String in) throws Exception {
    TranslationUnit unit = new Parser().parse(in);
    ClassInfoBuilder builder = new ClassInfoBuilder(this);
    unit.accept(builder);
  }
View Full Code Here

  private TranslationUnit parse(String source) throws Exception {
    return new Parser().parse(source);
  }

  public void testEmptyFunction() throws Exception {
    TranslationUnit unit = parse(
        "void foo() {                  " +
        "}"
    );
    FunctionDefinition functionFoo = unit.getChild(0);
    functionFoo.accept(analyzer);
    assertEquals(1, analyzer.getScore());
  }
View Full Code Here

    functionFoo.accept(analyzer);
    assertEquals(1, analyzer.getScore());
  }

  public void testSimpleFunction() throws Exception {
    TranslationUnit unit = parse(
        "void foo() {                  " +
        "  int i = 0;                  " +
        "  i += 1;                     " +
        "}                             "
    );
    FunctionDefinition functionFoo = unit.getChild(0);
    functionFoo.accept(analyzer);
    assertEquals(1, analyzer.getScore());
  }
View Full Code Here

    functionFoo.accept(analyzer);
    assertEquals(1, analyzer.getScore());
  }

  public void testIfFunction() throws Exception {
    TranslationUnit unit = parse(
        "void foo() {                  " +
        "  int a = 0;                  " +
        "  if (a < 0) {                " +
        "    a++;                      " +
        "  } else {                    " +
        "    a--;                      " +
        "  }                           " +
        "}                             "
    );
    FunctionDefinition functionFoo = unit.getChild(0);
    functionFoo.accept(analyzer);
    assertEquals(2, analyzer.getScore());
  }
View Full Code Here

    functionFoo.accept(analyzer);
    assertEquals(2, analyzer.getScore());
  }

  public void testIfFunctionNoElse() throws Exception {
    TranslationUnit unit = parse(
        "void foo() {                  " +
        "  int a = 0;                  " +
        "  if (a < 0) {                " +
        "    a++;                      " +
        "  }                           " +
        "}                             "
    );
    FunctionDefinition functionFoo = unit.getChild(0);
    functionFoo.accept(analyzer);
    assertEquals(2, analyzer.getScore());
  }
View Full Code Here

    functionFoo.accept(analyzer);
    assertEquals(2, analyzer.getScore());
  }

  public void testEmptySwitch() throws Exception {
    TranslationUnit unit = parse(
        "void foo() {                  " +
        "  int a = 0;                  " +
        "  switch(a) {                 " +
        "  case 0:                     " +
        "    a = 0;                    " +
        "  }                           " +
        "}                             "
    );
    FunctionDefinition functionFoo = unit.getChild(0);
    functionFoo.accept(analyzer);
    assertEquals(2, analyzer.getScore());
  }
View Full Code Here

    functionFoo.accept(analyzer);
    assertEquals(2, analyzer.getScore());
  }

  public void testLongerSwitch() throws Exception {
    TranslationUnit unit = parse(
        "void foo() {                  " +
        "  int a = 0;                  " +
        "  switch(a) {                 " +
        "  case 0:                     " +
        "    a = 0;                    " +
        "    break;                    " +
        "  case 1:                     " +
        "    a = 1;                    " +
        "    break;                    " +
        "  }                           " +
        "}                             "
    );
    FunctionDefinition functionFoo = unit.getChild(0);
    functionFoo.accept(analyzer);
    assertEquals(3, analyzer.getScore());
  }
View Full Code Here

    functionFoo.accept(analyzer);
    assertEquals(3, analyzer.getScore());
  }

  public void testSwitchWithDefault() throws Exception {
    TranslationUnit unit = parse(
        "void foo() {                  " +
        "  int a = 0;                  " +
        "  switch(a) {                 " +
        "  case 0:                     " +
        "    a = 0;                    " +
        "    break;                    " +
        "  default:                    " +
        "    a = 3;                    " +
        "  }                           " +
        "}                             "
    );
    FunctionDefinition functionFoo = unit.getChild(0);
    functionFoo.accept(analyzer);
    assertEquals(2, analyzer.getScore());
  }
View Full Code Here

    functionFoo.accept(analyzer);
    assertEquals(2, analyzer.getScore());
  }

  public void testLoopFunction() throws Exception {
    TranslationUnit unit = parse(
        "int foo() {                   " +
        "  int a = 0;                  " +
        "  while(true) {               " +
        "    ++a;                      " +
        "  }                           " +
        "  return a;                   " +
        "}                             "
    );
    FunctionDefinition functionFoo = unit.getChild(0);
    functionFoo.accept(analyzer);
    assertEquals(2, analyzer.getScore());
  }
View Full Code Here

TOP

Related Classes of com.google.test.metric.cpp.dom.TranslationUnit

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.