Skip to content

Commit

Permalink
Calling deserialize_bytes() on an incompatible array should fail. (#45)
Browse files Browse the repository at this point in the history
  • Loading branch information
bhalleycf authored Mar 6, 2023
1 parent d80ab33 commit 620cb3d
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<serde_bytes::ByteBuf>(value).unwrap_err();
// The number 256 cannot convert to a u8
let value = (100, 256, 100).serialize(&SERIALIZER).unwrap();
from_value::<serde_bytes::ByteBuf>(value).unwrap_err();
}

#[wasm_bindgen_test]
fn options() {
test_via_into(Some(0_u32), 0_u32);
Expand Down

0 comments on commit 620cb3d

Please sign in to comment.