PageRenderTime 20ms CodeModel.GetById 12ms app.highlight 4ms RepoModel.GetById 2ms app.codeStats 0ms

/cpp/src/test/java/com/google/test/metric/cpp/dom/VariableTest.java

http://testability-explorer.googlecode.com/
Java | 43 lines | 22 code | 6 blank | 15 comment | 0 complexity | a81913536d9dfef3765c257bac976e7a MD5 | raw file
 1/*
 2 * Copyright 2008 Google Inc.
 3 *
 4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 5 * use this file except in compliance with the License. You may obtain a copy of
 6 * the License at
 7 *
 8 * http://www.apache.org/licenses/LICENSE-2.0
 9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 * License for the specific language governing permissions and limitations under
14 * the License.
15 */
16package com.google.test.metric.cpp.dom;
17
18import com.google.test.metric.cpp.Parser;
19
20import junit.framework.TestCase;
21
22public class VariableTest extends TestCase {
23
24  private TranslationUnit parse(String source) throws Exception {
25    return new Parser().parse(source);
26  }
27
28  public void testSimple() {
29    Variable v = new Variable("foo::bar::a");
30    assertEquals("a", v.getName());
31    assertEquals("foo::bar::a", v.getQualifiedName());
32  }
33
34  public void testVariableWithContext() throws Exception {
35    TranslationUnit unit = parse("namespace A { namespace B { int a; }}");
36    Namespace namespaceA = unit.getChild(0);
37    Namespace namespaceB = namespaceA.getChild(0);
38    VariableDeclaration variableA = namespaceB.getChild(0);
39    Variable v = new Variable("C::a", variableA);
40    assertEquals("a", v.getName());
41    assertEquals("A::B::C::a", v.getQualifiedName());
42  }
43}