Skip to content

Commit

Permalink
Removed tests, that became duplicates of new tests:
Browse files Browse the repository at this point in the history
- serialize_bool                - duplicate of `without_root::false_` and `without_root::true_`
- serialize_struct              - duplicate of `without_root::struct_`
- serialize_struct_value_number - duplicate of `without_root::value`
- serialize_struct_value_string - excess test, duplicate of previous
- serialize_enum                - duplicate of `without_root::enum_::externally_tagged::newtype`
- serialize_a_list              - non working test that replaced by `without_root::seq`

- test_empty  - duplicate of `without_root::empty_struct`
- test_nested - duplicate of `without_root::nested_struct`

Still 114 failures
  • Loading branch information
Mingun authored and Joseph Gilby committed Nov 5, 2022
1 parent dc66d69 commit 5d4e031
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 186 deletions.
5 changes: 0 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -179,11 +179,6 @@ name = "encodings"
required-features = ["encoding"]
path = "tests/encodings.rs"

[[test]]
name = "serde_attrs"
required-features = ["serialize"]
path = "tests/serde_attrs.rs"

[[test]]
name = "serde_roundtrip"
required-features = ["serialize"]
Expand Down
108 changes: 2 additions & 106 deletions tests/serde-se.rs
Original file line number Diff line number Diff line change
@@ -1,115 +1,11 @@
use quick_xml::se::{to_string, Serializer};
use quick_xml::se::Serializer;
use quick_xml::utils::Bytes;
use quick_xml::writer::Writer;
use quick_xml::DeError;

use pretty_assertions::assert_eq;

use serde::{serde_if_integer128, Serialize, Serializer as SerSerializer};
use serde::{serde_if_integer128, Serialize};
use std::collections::BTreeMap;

#[test]
fn serialize_bool() {
let inputs = [(true, "true"), (false, "false")];

for (src, should_be) in &inputs {
let mut buffer = Vec::new();
let mut ser = Serializer::new(&mut buffer);
ser.serialize_bool(*src).unwrap();

assert_eq!(String::from_utf8(buffer).unwrap(), *should_be);
}
}

#[test]
fn serialize_struct() {
#[derive(Serialize)]
struct Person {
name: String,
age: u32,
}

let bob = Person {
name: "Bob".to_string(),
age: 42,
};

let mut buffer = Vec::new();
let mut ser = Serializer::new(&mut buffer);
bob.serialize(&mut ser).unwrap();

assert_eq!(
String::from_utf8(buffer).unwrap(),
"<Person name=\"Bob\" age=\"42\"/>"
);
}

#[test]
fn serialize_struct_value_number() {
#[derive(Serialize)]
struct Person {
name: String,
#[serde(rename = "$text")]
age: u32,
}

let bob = Person {
name: "Bob".to_string(),
age: 42,
};
assert_eq!(to_string(&bob).unwrap(), "<Person name=\"Bob\">42</Person>");
}

#[test]
fn serialize_struct_value_string() {
#[derive(Serialize)]
struct Person {
name: String,
#[serde(rename = "$text")]
age: String,
}

let bob = Person {
name: "Bob".to_string(),
age: "42".to_string(),
};
assert_eq!(to_string(&bob).unwrap(), "<Person name=\"Bob\">42</Person>");
}

#[test]
fn serialize_enum() {
#[derive(Serialize)]
#[allow(dead_code)]
enum Node {
Boolean(bool),
Number(f64),
String(String),
}

let mut buffer = Vec::new();
let mut ser = Serializer::new(&mut buffer);
let node = Node::Boolean(true);
node.serialize(&mut ser).unwrap();

assert_eq!(
String::from_utf8(buffer).unwrap(),
"<Boolean>true</Boolean>"
);
}

#[test]
#[ignore]
fn serialize_a_list() {
let inputs = vec![1, 2, 3, 4];

let mut buffer = Vec::new();
let mut ser = Serializer::new(&mut buffer);
inputs.serialize(&mut ser).unwrap();

println!("{}", String::from_utf8(buffer).unwrap());
panic!();
}

#[derive(Serialize)]
struct Unit;

Expand Down
75 changes: 0 additions & 75 deletions tests/serde_attrs.rs

This file was deleted.

0 comments on commit 5d4e031

Please sign in to comment.