View Javadoc
1   /*
2    * MIT License
3    * Copyright (c) 2006-2025 JMockit developers
4    * See LICENSE file for full license text.
5    */
6   package mockit.asm.types;
7   
8   import static org.junit.jupiter.api.Assertions.assertEquals;
9   import static org.junit.jupiter.api.Assertions.assertNotNull;
10  import static org.junit.jupiter.api.Assertions.assertThrows;
11  
12  import org.junit.jupiter.api.Test;
13  
14  final class MethodTypeTest {
15  
16      @Test
17      void createFromMethodDescriptor() {
18          MethodType type = MethodType.create("(Ljava/lang/String;I)V");
19          assertNotNull(type);
20      }
21  
22      @Test
23      void getInternalName() {
24          MethodType type = MethodType.create("(I)V");
25          assertEquals("(I)V", type.getInternalName());
26      }
27  
28      @Test
29      void getClassNameThrows() {
30          MethodType type = MethodType.create("(I)V");
31          assertThrows(UnsupportedOperationException.class, type::getClassName);
32      }
33  
34      @Test
35      void getSizeThrows() {
36          MethodType type = MethodType.create("(I)V");
37          assertThrows(UnsupportedOperationException.class, type::getSize);
38      }
39  
40      @Test
41      void getOpcodeThrows() {
42          MethodType type = MethodType.create("(I)V");
43          assertThrows(UnsupportedOperationException.class, () -> type.getOpcode(0));
44      }
45  }