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

Examples of com.google.test.metric.cpp.dom.FunctionDefinition.accept()


    TranslationUnit unit = parse(
        "void foo() {                  " +
        "}"
    );
    FunctionDefinition functionFoo = unit.getChild(0);
    functionFoo.accept(analyzer);
    assertEquals(1, analyzer.getScore());
  }

  public void testSimpleFunction() throws Exception {
    TranslationUnit unit = parse(
View Full Code Here


        "  int i = 0;                  " +
        "  i += 1;                     " +
        "}                             "
    );
    FunctionDefinition functionFoo = unit.getChild(0);
    functionFoo.accept(analyzer);
    assertEquals(1, analyzer.getScore());
  }

  public void testIfFunction() throws Exception {
    TranslationUnit unit = parse(
View Full Code Here

        "    a--;                      " +
        "  }                           " +
        "}                             "
    );
    FunctionDefinition functionFoo = unit.getChild(0);
    functionFoo.accept(analyzer);
    assertEquals(2, analyzer.getScore());
  }

  public void testIfFunctionNoElse() throws Exception {
    TranslationUnit unit = parse(
View Full Code Here

        "    a++;                      " +
        "  }                           " +
        "}                             "
    );
    FunctionDefinition functionFoo = unit.getChild(0);
    functionFoo.accept(analyzer);
    assertEquals(2, analyzer.getScore());
  }

  public void testEmptySwitch() throws Exception {
    TranslationUnit unit = parse(
View Full Code Here

        "    a = 0;                    " +
        "  }                           " +
        "}                             "
    );
    FunctionDefinition functionFoo = unit.getChild(0);
    functionFoo.accept(analyzer);
    assertEquals(2, analyzer.getScore());
  }

  public void testLongerSwitch() throws Exception {
    TranslationUnit unit = parse(
View Full Code Here

        "    break;                    " +
        "  }                           " +
        "}                             "
    );
    FunctionDefinition functionFoo = unit.getChild(0);
    functionFoo.accept(analyzer);
    assertEquals(3, analyzer.getScore());
  }

  public void testSwitchWithDefault() throws Exception {
    TranslationUnit unit = parse(
View Full Code Here

        "    a = 3;                    " +
        "  }                           " +
        "}                             "
    );
    FunctionDefinition functionFoo = unit.getChild(0);
    functionFoo.accept(analyzer);
    assertEquals(2, analyzer.getScore());
  }

  public void testLoopFunction() throws Exception {
    TranslationUnit unit = parse(
View Full Code Here

        "  }                           " +
        "  return a;                   " +
        "}                             "
    );
    FunctionDefinition functionFoo = unit.getChild(0);
    functionFoo.accept(analyzer);
    assertEquals(2, analyzer.getScore());
  }

  public void testTernaryOperator() throws Exception {
    TranslationUnit unit = parse(
View Full Code Here

        "int foo(int a, int b) {       " +
        "  return a > 0 ? b : 1;       " +
        "}                             "
    );
    FunctionDefinition functionFoo = unit.getChild(0);
    functionFoo.accept(analyzer);
    assertEquals(2, analyzer.getScore());
  }

  public void testNestedTernaryOperator() throws Exception {
    TranslationUnit unit = parse(
View Full Code Here

        "int foo(int a, int b) {                  " +
        "  return a > 0 ? (b < 0 ? -1 : 0) : 1;   " +
        "}                                        "
    );
    FunctionDefinition functionFoo = unit.getChild(0);
    functionFoo.accept(analyzer);
    assertEquals(3, analyzer.getScore());
  }
}
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.