Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove ignored tests which produces warnings since serde 1.0.215 #833

Merged
merged 1 commit into from
Nov 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
182 changes: 28 additions & 154 deletions tests/serde-de-seq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2792,83 +2792,20 @@ mod variable_name {
}
}

/// Tests are ignored, but exists to show a problem.
/// May be it will be solved in the future
mod choice_and_choice {
use super::*;
use pretty_assertions::assert_eq;

#[derive(Debug, PartialEq, Deserialize)]
struct Pair {
#[serde(rename = "$value")]
item: [Choice; 3],
// Actually, we cannot rename both fields to `$value`, which is now
// required to indicate, that field accepts elements with any name
#[serde(rename = "$value")]
element: [Choice2; 2],
}

#[test]
#[ignore = "There is no way to associate XML elements with `item` or `element` without extra knowledge from type"]
fn splitted() {
let data: Pair = from_str(
r#"
<root>
<first/>
<second/>
<one/>
<two/>
<three/>
</root>
"#,
)
.unwrap();

assert_eq!(
data,
Pair {
item: [Choice::One, Choice::Two, Choice::Other("three".into())],
element: [Choice2::First, Choice2::Second],
}
);
}

#[test]
#[ignore = "There is no way to associate XML elements with `item` or `element` without extra knowledge from type"]
fn overlapped() {
let data = from_str::<Pair>(
r#"
<root>
<one/>
<first/>
<two/>
<second/>
<three/>
</root>
"#,
);

#[cfg(feature = "overlapped-lists")]
assert_eq!(
data.unwrap(),
Pair {
item: [Choice::One, Choice::Two, Choice::Other("three".into())],
element: [Choice2::First, Choice2::Second],
}
);

#[cfg(not(feature = "overlapped-lists"))]
match data {
Err(DeError::Custom(e)) => {
assert_eq!(e, "invalid length 1, expected an array of length 3")
}
e => panic!(
r#"Expected `Err(Custom("invalid length 1, expected an array of length 3"))`, but got `{:?}`"#,
e
),
}
}
}
// choice_and_choice struct like
//
// #[derive(Deserialize)]
// struct Pair {
// #[serde(rename = "$value")]
// item: [Choice; 2],
//
// #[serde(rename = "$value")]
// element: [Choice2; 3],
// }
//
// cannot be implemented because both fields should be renamed to the
// same name $value. Derived implementation will never try to deserialize
// `element`
}

/// Deserialization of primitives slightly differs from deserialization
Expand Down Expand Up @@ -3932,83 +3869,20 @@ mod variable_name {
}
}

/// Tests are ignored, but exists to show a problem.
/// May be it will be solved in the future
mod choice_and_choice {
use super::*;
use pretty_assertions::assert_eq;

#[derive(Debug, PartialEq, Deserialize)]
struct Pair {
#[serde(rename = "$value")]
item: Vec<Choice>,
// Actually, we cannot rename both fields to `$value`, which is now
// required to indicate, that field accepts elements with any name
#[serde(rename = "$value")]
element: Vec<Choice2>,
}

#[test]
#[ignore = "There is no way to associate XML elements with `item` or `element` without extra knowledge from type"]
fn splitted() {
let data: Pair = from_str(
r#"
<root>
<first/>
<second/>
<one/>
<two/>
<three/>
</root>
"#,
)
.unwrap();

assert_eq!(
data,
Pair {
item: vec![Choice::One, Choice::Two, Choice::Other("three".into())],
element: vec![Choice2::First, Choice2::Second],
}
);
}

#[test]
#[ignore = "There is no way to associate XML elements with `item` or `element` without extra knowledge from type"]
fn overlapped() {
let data = from_str::<Pair>(
r#"
<root>
<one/>
<first/>
<two/>
<second/>
<three/>
</root>
"#,
);

#[cfg(feature = "overlapped-lists")]
assert_eq!(
data.unwrap(),
Pair {
item: vec![Choice::One, Choice::Two, Choice::Other("three".into())],
element: vec![Choice2::First, Choice2::Second],
}
);

#[cfg(not(feature = "overlapped-lists"))]
match data {
Err(DeError::Custom(e)) => {
assert_eq!(e, "invalid length 1, expected an array of length 3")
}
e => panic!(
r#"Expected `Err(Custom("invalid length 1, expected an array of length 3"))`, but got `{:?}`"#,
e
),
}
}
}
// choice_and_choice struct like
//
// #[derive(Deserialize)]
// struct Pair {
// #[serde(rename = "$value")]
// item: Vec<Choice>,
//
// #[serde(rename = "$value")]
// element: Vec<Choice2>,
// }
//
// cannot be implemented because both fields should be renamed to the
// same name $value. Derived implementation will never try to deserialize
// `element`
}

/// Deserialization of primitives slightly differs from deserialization
Expand Down