/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. */
  16. package com.google.test.metric.report;
  17. import com.google.test.metric.FieldInfo;
  18. import com.google.test.metric.JavaType;
  19. import com.google.test.metric.LocalField;
  20. import com.google.test.metric.MethodCost;
  21. import com.google.test.metric.Type;
  22. import com.google.test.metric.Variable;
  23. import junit.framework.TestCase;
  24. /**
  25. * @author alexeagle@google.com (Alex Eagle)
  26. */
  27. public class SourceElementFormattingTest extends TestCase {
  28. public void testMethodFormatting() throws Exception {
  29. MethodCost cost = new MethodCost("", "void translation_unit()", 1, false, false, false);
  30. assertEquals("void translation_unit()", cost.getDescription());
  31. }
  32. public void testVariableFormatting() throws Exception {
  33. Type type = JavaType.fromJava("com.google.test.metric.example.MutableGlobalState." +
  34. "FinalGlobalExample$Gadget");
  35. FieldInfo field = new FieldInfo(null, "finalInstance", type, false, false, false);
  36. LocalField localField = new LocalField(new Variable(
  37. "com.google.test.metric.example.MutableGlobalState.FinalGlobalExample$" +
  38. "FinalGlobal.finalInstance",
  39. type, false, false), field);
  40. assertEquals("FinalGlobalExample$Gadget finalInstance", localField.getDescription());
  41. }
  42. public void testDotsInMethodParameters() throws Exception {
  43. MethodCost cost = new MethodCost(
  44. "",
  45. "com.google.test.metric.cpp.dom.TranslationUnit parse2(java.lang.String, java.lang.String)",
  46. 12, false, false, false);
  47. assertEquals("TranslationUnit parse2(String, String)", cost.getDescription());
  48. }
  49. }