MCPcopy Create free account
hub / github.com/astonbitecode/j4rs / test_int_array_to_rust

Function test_int_array_to_rust

rust/src/api/mod.rs:2323–2340  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2321
2322 #[test]
2323 fn test_int_array_to_rust() -> errors::Result<()> {
2324 let jvm = create_tests_jvm()?;
2325 let rust_value: Vec<i32> = vec![-100_000, -1_000_000, 1_000_000];
2326 let ia: Vec<_> = rust_value
2327 .iter()
2328 .map(|x| {
2329 InvocationArg::try_from(x)
2330 .unwrap()
2331 .into_primitive()
2332 .unwrap()
2333 })
2334 .collect();
2335 let java_instance = jvm.create_java_array(PRIMITIVE_INT, &ia)?;
2336 let rust_value_from_java: Vec<i32> = jvm.to_rust(java_instance)?;
2337 assert_eq!(rust_value_from_java, rust_value);
2338
2339 Ok(())
2340 }
2341
2342 #[test]
2343 fn test_long_array_to_rust() -> errors::Result<()> {

Callers

nothing calls this directly

Calls 6

create_tests_jvmFunction · 0.85
collectMethod · 0.80
mapMethod · 0.80
into_primitiveMethod · 0.80
create_java_arrayMethod · 0.80
to_rustMethod · 0.45

Tested by

no test coverage detected