PageRenderTime 40ms CodeModel.GetById 21ms RepoModel.GetById 1ms app.codeStats 0ms

/testability-explorer/src/test/java/com/google/test/metric/asm/SignatureParserTest.java

http://testability-explorer.googlecode.com/
Java | 55 lines | 29 code | 11 blank | 15 comment | 0 complexity | 52fc55caab5943f2cbbb6a56cbf5df98 MD5 | raw file
Possible License(s): Apache-2.0
  1. /*
  2. * Copyright 2007 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.asm;
  17. import static com.google.test.metric.asm.SignatureParser.parse;
  18. import java.util.List;
  19. import junit.framework.TestCase;
  20. import com.google.test.metric.JavaType;
  21. import com.google.test.metric.Type;
  22. public class SignatureParserTest extends TestCase {
  23. public void testParsePrimitive() throws Exception {
  24. assertSame(JavaType.LONG, parse("()J").getReturnType());
  25. }
  26. public void testParseObject() throws Exception {
  27. assertEquals(JavaType.fromClass(String.class),
  28. parse("()Ljava/lang/String;").getReturnType());
  29. }
  30. public void testParseArray() throws Exception {
  31. assertEquals(JavaType.fromClass(String[].class), parse(
  32. "()[Ljava/lang/String;").getReturnType());
  33. }
  34. public void testParseDoubleArray() throws Exception {
  35. assertEquals(JavaType.fromClass(String[][].class), parse(
  36. "()[[Ljava/lang/String;").getReturnType());
  37. }
  38. public void testParseArgsDoubleArray() throws Exception {
  39. List<Type> parameters = parse("([[Ljava/lang/String;J)V")
  40. .getParameters();
  41. assertEquals(JavaType.fromClass(String[][].class), parameters.get(0));
  42. assertEquals(JavaType.LONG, parameters.get(1));
  43. }
  44. }