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

feature/legacy support #93

Merged
merged 9 commits into from
Feb 1, 2019
Merged
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ rust:
- beta
- nightly
cache: cargo
before_cache:
- cargo clean -p serde-xml-rs
- rm -f target/debug/deps/libserde_xml_rs*.rlib
env:
global:
- RUST_BACKTRACE=1
Expand Down
7 changes: 6 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,14 @@ version = "0.3.0"
log = "0.4"
serde = "1.0"
xml-rs = "0.8.0"
error-chain = "0.10.0"
error-chain = { version = "0.10.0", default-features = false }

[dev-dependencies]
serde_derive = "1.0"
simple_logger = "1.0.1"
docmatic = "0.1.2"

[features]
default = ["with-backtrace"]
with-backtrace = ["error-chain/default"]
legacy-support = ["error-chain/example_generated"]
52 changes: 52 additions & 0 deletions tests/failures.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#[macro_use]
extern crate serde_derive;
extern crate serde_xml_rs;

#[macro_use]
extern crate log;
extern crate simple_logger;

use serde_xml_rs::from_str;

#[derive(Debug, Deserialize, PartialEq)]
struct Item {
name: String,
source: String,
}

#[test]
fn simple_struct_from_attributes_should_fail() {
let _ = simple_logger::init();

let s = r##"
<item name="hello" source="world.rs />
"##;

let item: Result<Item, _> = from_str(s);
match item {
Ok(_) => assert!(false),
Err(e) => {
info!("simple_struct_from_attributes_should_fail(): {}", e);
assert!(true)
}
}
}

#[test]
fn multiple_roots_attributes_should_fail() {
let _ = simple_logger::init();

let s = r##"
<item name="hello" source="world.rs" />
<item name="hello source="world.rs" />
"##;

let item: Result<Vec<Item>, _> = from_str(s);
match item {
Ok(_) => assert!(false),
Err(e) => {
info!("multiple_roots_attributes_should_fail(): {}", e);
assert!(true)
}
}
}