Skip to content

Commit

Permalink
Merge pull request #309 from Mingun/tests
Browse files Browse the repository at this point in the history
Additional basic tests for serde deserializer
  • Loading branch information
tafia committed Aug 24, 2021
2 parents aa6ec2d + b3c1595 commit 516f1ea
Show file tree
Hide file tree
Showing 7 changed files with 411 additions and 80 deletions.
6 changes: 6 additions & 0 deletions Changelog.md
Expand Up @@ -10,6 +10,12 @@

## Unreleased

- test: add tests for malformed inputs for serde deserializer
- fix: allow to deserialize `unit`s from any data in attribute values and text nodes
- refactor: unify errors when EOF encountered during serde deserialization
- test: ensure that after deserializing all XML was consumed
- feat: add `Deserializer::from_str` and `Deserializer::from_bytes`

## 0.23.0-alpha3

- fix: use element name (with namespace) when unflattening (serialize feature)
Expand Down
10 changes: 2 additions & 8 deletions src/de/escape.rs
Expand Up @@ -12,7 +12,7 @@ use std::borrow::Cow;
/// Escaping the value is actually not always necessary, for instance
/// when converting to float, we don't expect any escapable character
/// anyway
#[derive(Clone)]
#[derive(Clone, Debug)]
pub(crate) struct EscapedDeserializer {
decoder: Decoder,
/// Possible escaped value of text/CDATA or attribute value
Expand Down Expand Up @@ -145,13 +145,7 @@ impl<'de> serde::Deserializer<'de> for EscapedDeserializer {
where
V: Visitor<'de>,
{
if self.escaped_value.is_empty() {
visitor.visit_unit()
} else {
Err(DeError::InvalidUnit(
"Expecting unit, got non empty attribute".into(),
))
}
visitor.visit_unit()
}

fn deserialize_option<V>(self, visitor: V) -> Result<V::Value, Self::Error>
Expand Down

0 comments on commit 516f1ea

Please sign in to comment.