Skip to content

Commit

Permalink
feature/legacy support (#93)
Browse files Browse the repository at this point in the history
feature toggle for backtrace
  • Loading branch information
rustysec authored and punkstarman committed Feb 1, 2019
1 parent c10f773 commit b854e1a
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 1 deletion.
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)
}
}
}

0 comments on commit b854e1a

Please sign in to comment.