PageRenderTime 20ms CodeModel.GetById 12ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

/testability-explorer/src/test/java/com/google/test/metric/report/SourceElementFormattingTest.java

http://testability-explorer.googlecode.com/
Java | 55 lines | 31 code | 6 blank | 18 comment | 0 complexity | d8f13cfa4dd4a9564656b904d5763353 MD5 | raw file
 1/*
 2 * Copyright 2009 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.report;
17
18import com.google.test.metric.FieldInfo;
19import com.google.test.metric.JavaType;
20import com.google.test.metric.LocalField;
21import com.google.test.metric.MethodCost;
22import com.google.test.metric.Type;
23import com.google.test.metric.Variable;
24
25import junit.framework.TestCase;
26
27/**
28 * @author alexeagle@google.com (Alex Eagle)
29 */
30public class SourceElementFormattingTest extends TestCase {
31
32  public void testMethodFormatting() throws Exception {
33    MethodCost cost = new MethodCost("", "void translation_unit()", 1, false, false, false);
34    assertEquals("void translation_unit()", cost.getDescription());
35  }
36
37  public void testVariableFormatting() throws Exception {
38    Type type = JavaType.fromJava("com.google.test.metric.example.MutableGlobalState." +
39        "FinalGlobalExample$Gadget");
40    FieldInfo field = new FieldInfo(null, "finalInstance", type, false, false, false);
41    LocalField localField = new LocalField(new Variable(
42        "com.google.test.metric.example.MutableGlobalState.FinalGlobalExample$" +
43            "FinalGlobal.finalInstance",
44        type, false, false), field);
45    assertEquals("FinalGlobalExample$Gadget finalInstance", localField.getDescription());
46  }
47
48  public void testDotsInMethodParameters() throws Exception {
49    MethodCost cost = new MethodCost(
50        "",
51        "com.google.test.metric.cpp.dom.TranslationUnit parse2(java.lang.String, java.lang.String)",
52        12, false, false, false);
53    assertEquals("TranslationUnit parse2(String, String)", cost.getDescription());
54  }
55}