mirror of
https://github.com/YGGverse/aquatic.git
synced 2026-04-01 02:05:30 +00:00
ws: update simd-json to 0.10.3
This commit is contained in:
parent
8734855c49
commit
fca6cc9fbd
6 changed files with 145 additions and 60 deletions
|
|
@ -262,12 +262,6 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn test_deserialize_info_hashes_vec() {
|
||||
let mut input: String = r#"{
|
||||
"action": "scrape",
|
||||
"info_hash": ["aaaabbbbccccddddeeee", "aaaabbbbccccddddeeee"]
|
||||
}"#
|
||||
.into();
|
||||
|
||||
let info_hashes = ScrapeRequestInfoHashes::Multiple(vec![
|
||||
info_hash_from_bytes(b"aaaabbbbccccddddeeee"),
|
||||
info_hash_from_bytes(b"aaaabbbbccccddddeeee"),
|
||||
|
|
@ -278,19 +272,21 @@ mod tests {
|
|||
info_hashes: Some(info_hashes),
|
||||
};
|
||||
|
||||
let observed: ScrapeRequest = ::simd_json::serde::from_str(&mut input).unwrap();
|
||||
let observed: ScrapeRequest = unsafe {
|
||||
let mut input: String = r#"{
|
||||
"action": "scrape",
|
||||
"info_hash": ["aaaabbbbccccddddeeee", "aaaabbbbccccddddeeee"]
|
||||
}"#
|
||||
.into();
|
||||
|
||||
::simd_json::serde::from_str(&mut input).unwrap()
|
||||
};
|
||||
|
||||
assert_eq!(expected, observed);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_deserialize_info_hashes_str() {
|
||||
let mut input: String = r#"{
|
||||
"action": "scrape",
|
||||
"info_hash": "aaaabbbbccccddddeeee"
|
||||
}"#
|
||||
.into();
|
||||
|
||||
let info_hashes =
|
||||
ScrapeRequestInfoHashes::Single(info_hash_from_bytes(b"aaaabbbbccccddddeeee"));
|
||||
|
||||
|
|
@ -299,54 +295,65 @@ mod tests {
|
|||
info_hashes: Some(info_hashes),
|
||||
};
|
||||
|
||||
let observed: ScrapeRequest = ::simd_json::serde::from_str(&mut input).unwrap();
|
||||
let observed: ScrapeRequest = unsafe {
|
||||
let mut input: String = r#"{
|
||||
"action": "scrape",
|
||||
"info_hash": "aaaabbbbccccddddeeee"
|
||||
}"#
|
||||
.into();
|
||||
|
||||
::simd_json::serde::from_str(&mut input).unwrap()
|
||||
};
|
||||
|
||||
assert_eq!(expected, observed);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_deserialize_info_hashes_null() {
|
||||
let mut input: String = r#"{
|
||||
"action": "scrape",
|
||||
"info_hash": null
|
||||
}"#
|
||||
.into();
|
||||
let observed: ScrapeRequest = unsafe {
|
||||
let mut input: String = r#"{
|
||||
"action": "scrape",
|
||||
"info_hash": null
|
||||
}"#
|
||||
.into();
|
||||
|
||||
::simd_json::serde::from_str(&mut input).unwrap()
|
||||
};
|
||||
|
||||
let expected = ScrapeRequest {
|
||||
action: ScrapeAction,
|
||||
info_hashes: None,
|
||||
};
|
||||
|
||||
let observed: ScrapeRequest = ::simd_json::serde::from_str(&mut input).unwrap();
|
||||
|
||||
assert_eq!(expected, observed);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_deserialize_info_hashes_missing() {
|
||||
let mut input: String = r#"{
|
||||
"action": "scrape"
|
||||
}"#
|
||||
.into();
|
||||
let observed: ScrapeRequest = unsafe {
|
||||
let mut input: String = r#"{
|
||||
"action": "scrape"
|
||||
}"#
|
||||
.into();
|
||||
|
||||
::simd_json::serde::from_str(&mut input).unwrap()
|
||||
};
|
||||
|
||||
let expected = ScrapeRequest {
|
||||
action: ScrapeAction,
|
||||
info_hashes: None,
|
||||
};
|
||||
|
||||
let observed: ScrapeRequest = ::simd_json::serde::from_str(&mut input).unwrap();
|
||||
|
||||
assert_eq!(expected, observed);
|
||||
}
|
||||
|
||||
#[quickcheck]
|
||||
fn quickcheck_serde_identity_info_hashes(info_hashes: ScrapeRequestInfoHashes) -> bool {
|
||||
let mut json = ::simd_json::serde::to_string(&info_hashes).unwrap();
|
||||
let deserialized: ScrapeRequestInfoHashes = unsafe {
|
||||
let mut json = ::simd_json::serde::to_string(&info_hashes).unwrap();
|
||||
|
||||
println!("{}", json);
|
||||
|
||||
let deserialized: ScrapeRequestInfoHashes =
|
||||
::simd_json::serde::from_str(&mut json).unwrap();
|
||||
::simd_json::serde::from_str(&mut json).unwrap()
|
||||
};
|
||||
|
||||
let success = info_hashes == deserialized;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue