blob: 32251f9a560b0ea3512a9787001d43d64016d4e1 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
package org.glavo.javah;
import org.junit.jupiter.api.Test;
import org.objectweb.asm.Type;
import java.util.LinkedHashMap;
import java.util.Map;
import static org.junit.jupiter.api.Assertions.*;
public class NativeMethodTests {
@Test
void testFactoryMethod() {
Map<String, Type> qualified = new LinkedHashMap<>() {
{
put("method0", Type.getType("()I"));
put("method1", Type.getType("(Ljava/lang/String;)I"));
}
};
Map<String, Type> wrongs = new LinkedHashMap<>() {
{
put("method0", Type.getType(String.class));
put("method1", Type.getType("()"));
put("method2", Type.getType("L;"));
}
};
qualified.forEach((name, type) -> assertDoesNotThrow(() -> NativeMethod.of(name, type)));
wrongs.forEach((name, type) -> assertThrows(IllegalArgumentException.class, () -> NativeMethod.of(name, type)));
}
}
|