Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
ajewellamz committed Oct 15, 2024
1 parent 9c866b5 commit 6172d3b
Showing 1 changed file with 28 additions and 9 deletions.
37 changes: 28 additions & 9 deletions rust-runtime/aws-smithy-types/src/blob.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,21 @@ impl AsRef<[u8]> for Blob {
}
}

impl Into<Vec<u8>> for Blob {
fn into(self) -> Vec<u8> {
self.into_inner()
impl From<Vec<u8>> for Blob {
fn from(value: Vec<u8>) -> Self {
Blob::new(value)
}
}

impl Into<Blob> for Vec<u8> {
fn into(self) -> Blob {
Blob::new(self)
impl From<Blob> for Vec<u8> {
fn from(value: Blob) -> Self {
value.into_inner()
}
}

impl Into<Blob> for &[u8] {
fn into(self) -> Blob {
Blob::new(self)
impl From<&[u8]> for Blob {
fn from(value: &[u8]) -> Self {
Blob::new(value)
}
}

Expand Down Expand Up @@ -121,6 +121,25 @@ mod serde_deserialize {
}

#[cfg(test)]
mod test {
use crate::Blob;

#[test]
fn blob_conversion() {
let my_bytes: &[u8] = &[1u8, 2u8, 3u8];
let my_vec = vec![1u8, 2u8, 3u8];
let orig_vec = my_vec.clone();

let blob1: Blob = my_bytes.into();
let vec1: Vec<u8> = blob1.into();
assert_eq!(orig_vec, vec1);

let blob2: Blob = my_vec.into();
let vec2: Vec<u8> = blob2.into();
assert_eq!(orig_vec, vec2);
}
}

#[cfg(all(
aws_sdk_unstable,
feature = "serde-serialize",
Expand Down

0 comments on commit 6172d3b

Please sign in to comment.