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