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

http://testability-explorer.googlecode.com/ · Java · 39 lines · 27 code · 8 blank · 4 comment · 0 complexity · 24ae5e0a0ddbcb8cc01ce7f86dd07f87 MD5 · raw file

  1. // Copyright 2009 Google Inc. All Rights Reserved.
  2. package com.google.test.metric.report;
  3. import junit.framework.TestCase;
  4. /**
  5. * @author alexeagle@google.com (Alex Eagle)
  6. */
  7. public class RemovePackageFormatterTest extends TestCase {
  8. RemovePackageFormatter formatter = new RemovePackageFormatter();
  9. public void testShortFormatting() throws Exception {
  10. String shortened = formatter.format("int com.google.longpackagename.Foo.thing()");
  11. assertEquals("int thing()", shortened);
  12. }
  13. public void testShortFormattingWithParameters() throws Exception {
  14. String shortened = formatter.format("t.n.e(p.e, a.b)");
  15. assertEquals("e(e, b)", shortened);
  16. }
  17. public void testInnerClassMethodNamesShortFormatting() throws Exception {
  18. String shortened = formatter.format("String com.google.Outer$HasInner.computeString()");
  19. assertEquals("String computeString()", shortened);
  20. }
  21. public void testInnerClassConstructorMethod() throws Exception {
  22. String shortened = formatter.format("com.google.test.metric.example.ExpensiveConstructor."
  23. + "StaticWorkInTheConstructor$StaticHolder()");
  24. assertEquals("StaticWorkInTheConstructor$StaticHolder()", shortened);
  25. }
  26. public void testTypeNameShortening() throws Exception {
  27. String shortened = formatter.format("com.google.test.metric.example.ExpensiveConstructor."
  28. + "StaticWorkInTheConstructor$StaticHolder");
  29. assertEquals("StaticWorkInTheConstructor$StaticHolder", shortened);
  30. }
  31. }