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

Function test_float_array_to_rust

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

Source from the content-addressed store, hash-verified

2361
2362 #[test]
2363 fn test_float_array_to_rust() -> errors::Result<()> {
2364 let jvm = create_tests_jvm()?;
2365 let rust_value: Vec<f32> = vec![3_f32, 7.5_f32, -1000.5_f32];
2366 let ia: Vec<_> = rust_value
2367 .iter()
2368 .map(|x| {
2369 InvocationArg::try_from(x)
2370 .unwrap()
2371 .into_primitive()
2372 .unwrap()
2373 })
2374 .collect();
2375 let java_instance = jvm.create_java_array(PRIMITIVE_FLOAT, &ia)?;
2376 let rust_value_from_java: Vec<f32> = jvm.to_rust(java_instance)?;
2377 assert_eq!(rust_value_from_java, rust_value);
2378
2379 Ok(())
2380 }
2381
2382 #[test]
2383 fn test_double_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