Skip to content

Commit b09d20e

Browse files
Mingundralley
authored andcommitted
Remove tests that is already tested in serde-de, struct_::non_closed
1 parent 76f9d2a commit b09d20e

File tree

2 files changed

+59
-32
lines changed

2 files changed

+59
-32
lines changed

tests/serde-de.rs

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -742,6 +742,65 @@ macro_rules! maplike_errors {
742742
}
743743
}
744744
}
745+
746+
mod incomplete_tag {
747+
use super::*;
748+
use quick_xml::errors::{Error, SyntaxError};
749+
750+
#[test]
751+
fn attributes() {
752+
let err = from_str::<$attributes>(
753+
// Comment for prevent unnecessary formatting - we use the same style in all tests
754+
r#"<root float="42" string="answer""#,
755+
)
756+
.unwrap_err();
757+
match err {
758+
// TODO: add error position to errors and check it here
759+
// Related: https://github.com/tafia/quick-xml/issues/625
760+
DeError::InvalidXml(Error::Syntax(SyntaxError::UnclosedTag)) => (),
761+
_ => panic!(
762+
"Expected `Err(InvalidXml(Syntax(UnclosedTag)))`, but got `{:?}`",
763+
err
764+
),
765+
}
766+
}
767+
768+
#[test]
769+
fn elements_root() {
770+
let err = from_str::<$mixed>(
771+
// Comment for prevent unnecessary formatting - we use the same style in all tests
772+
r#"<root float="42"><string>answer</string><root"#,
773+
)
774+
.unwrap_err();
775+
match err {
776+
// TODO: add error position to errors and check it here
777+
// Related: https://github.com/tafia/quick-xml/issues/625
778+
DeError::InvalidXml(Error::Syntax(SyntaxError::UnclosedTag)) => (),
779+
_ => panic!(
780+
"Expected `Err(InvalidXml(Syntax(UnclosedTag)))`, but got `{:?}`",
781+
err
782+
),
783+
}
784+
}
785+
786+
#[test]
787+
fn elements_child() {
788+
let err = from_str::<$mixed>(
789+
// Comment for prevent unnecessary formatting - we use the same style in all tests
790+
r#"<root float="42"><string>answer</string"#,
791+
)
792+
.unwrap_err();
793+
match err {
794+
// TODO: add error position to errors and check it here
795+
// Related: https://github.com/tafia/quick-xml/issues/625
796+
DeError::InvalidXml(Error::Syntax(SyntaxError::UnclosedTag)) => (),
797+
_ => panic!(
798+
"Expected `Err(InvalidXml(Syntax(UnclosedTag)))`, but got `{:?}`",
799+
err
800+
),
801+
}
802+
}
803+
}
745804
};
746805
}
747806

tests/serde-migrated.rs

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,6 @@ use serde::{Deserialize, Serialize};
66

77
use pretty_assertions::assert_eq;
88

9-
#[derive(PartialEq, Debug, Serialize, Deserialize)]
10-
struct Simple {
11-
a: (),
12-
b: usize,
13-
c: String,
14-
d: Option<String>,
15-
}
16-
179
#[track_caller]
1810
fn test_parse_ok<'a, T: std::fmt::Debug>(errors: &[(&'a str, T)])
1911
where
@@ -38,16 +30,6 @@ where
3830
}
3931
}
4032

41-
#[track_caller]
42-
fn test_parse_err<'a, T>(errors: &[&'a str])
43-
where
44-
T: PartialEq + Debug + ser::Serialize + for<'de> de::Deserialize<'de>,
45-
{
46-
for &s in errors {
47-
assert!(from_str::<T>(s).is_err());
48-
}
49-
}
50-
5133
#[test]
5234
fn test_namespaces() {
5335
#[derive(PartialEq, Serialize, Deserialize, Debug)]
@@ -91,17 +73,3 @@ fn test_forwarded_namespace() {
9173
},
9274
)]);
9375
}
94-
95-
#[test]
96-
fn test_parse_unfinished() {
97-
test_parse_err::<Simple>(&["<Simple>
98-
<c>abc</c>
99-
<a/>
100-
<b>2</b>
101-
<d/>"]);
102-
}
103-
104-
#[test]
105-
fn test_things_qc_found() {
106-
test_parse_err::<u32>(&["<\u{0}:/"]);
107-
}

0 commit comments

Comments
 (0)