test: passing env and JString

This commit is contained in:
əlemi 2024-09-24 03:26:37 +02:00
parent 1389f71c97
commit a3918afaaf
Signed by: alemi
GPG key ID: A4895B84D311642C
2 changed files with 11 additions and 0 deletions

View file

@ -14,6 +14,7 @@ public class Main {
static native String concat(String a, String b);
static native String[] to_vec(String a, String b, String c);
static native boolean maybe(String optional);
static native String raw();
@Test
public void argumentsByValue() {
@ -48,4 +49,9 @@ public class Main {
assertEquals(Main.maybe("aa"), true);
}
@Test
public void passEnv() {
assertEquals(Main.raw(), "hello world!");
}
}

View file

@ -19,3 +19,8 @@ fn to_vec(a: String, b: String, c: String) -> Vec<String> {
fn maybe(idk: Option<String>) -> bool {
idk.is_some()
}
#[jni(package = "toolbox", class = "Main")]
fn raw<'local>(env: &mut jni::JNIEnv<'local>) -> Result<jni::objects::JString<'local>, jni::errors::Error> {
env.new_string("hello world!")
}