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

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


    finished();
  }

  @Override
  public void beginReturnStatement(int line) {
    Node node = new ReturnStatement(line);
    parent.addChild(node);
    pushBuilder(new StatementBuilder(node));
  }
View Full Code Here


  public void testSimpleFunction() throws Exception {
    TranslationUnit unit = parse("int foo() { int a = 0; a = a + 1;\n return a; }");
    FunctionDefinition functionFoo = unit.getChild(0);
    assertEquals("foo", functionFoo.getName());
    ReturnStatement returnStatement = functionFoo.getChild(2);
    assertNotNull(returnStatement);
    assertEquals(2, returnStatement.getLineNumber());
  }
View Full Code Here

  public void testFunctionWithParameters() throws Exception {
    TranslationUnit unit = parse("int foo(int a, int b) { return a + b; }");
    FunctionDefinition functionFoo = unit.getChild(0);
    assertEquals("foo", functionFoo.getName());
    ReturnStatement returnStatement = functionFoo.getChild(0);
    assertNotNull(returnStatement);
    List<ParameterInfo> parameters = functionFoo.getParameters();
    assertEquals(2, parameters.size());
    ParameterInfo parameterA = parameters.get(0);
    assertEquals("a", parameterA.getName());
View Full Code Here

  }

  public void testTernaryOperator() throws Exception {
    TranslationUnit unit = parse("int foo(int a, int b) { return a ? 0 : b; }");
    FunctionDefinition functionFoo = unit.getChild(0);
    ReturnStatement returnStatement = functionFoo.getChild(0);
    TernaryOperation ternaryOperation = returnStatement.getExpression(0);
    assertNotNull(ternaryOperation);
  }
View Full Code Here

    TranslationUnit unit = parse(
        "int foo(int a) { return a; }             " +
        "int bar(int b) { return foo(foo(b)); }   ");
    FunctionDefinition functionBar = unit.getChild(1);
    assertEquals("bar", functionBar.getName());
    ReturnStatement returnStatement = functionBar.getChild(0);
    FunctionInvocation callFoo = returnStatement.getExpression(0);
    assertEquals("foo", callFoo.getName());
    NodeList parameters = callFoo.getParameters();
    FunctionInvocation callFooAgain = parameters.get(0);
    assertEquals("foo", callFooAgain.getName());
    assertEquals(0, callFooAgain.getChildren().size());
View Full Code Here

TOP

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

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.