From 620cb3d3c36e59479753949b05aa93c29554cc3c Mon Sep 17 00:00:00 2001 From: Bob Halley <104104227+bhalleycf@users.noreply.github.com> Date: Mon, 6 Mar 2023 12:17:00 -0800 Subject: [PATCH] Calling deserialize_bytes() on an incompatible array should fail. (#45) --- tests/common/mod.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/common/mod.rs b/tests/common/mod.rs index c648853..434a343 100644 --- a/tests/common/mod.rs +++ b/tests/common/mod.rs @@ -493,6 +493,18 @@ fn bytes_as_array() { assert_eq!(deserialized.as_ref(), src); } +#[wasm_bindgen_test] +fn bytes_from_mixed_array() { + // The string "xyz" cannot convert to a u8 + let value = (100, "xyz".to_string(), true) + .serialize(&SERIALIZER) + .unwrap(); + from_value::(value).unwrap_err(); + // The number 256 cannot convert to a u8 + let value = (100, 256, 100).serialize(&SERIALIZER).unwrap(); + from_value::(value).unwrap_err(); +} + #[wasm_bindgen_test] fn options() { test_via_into(Some(0_u32), 0_u32);