| 1 |
|
| 2 |
|
| 3 |
use libxml::parser::Parser; |
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
er |
| 8 |
gh |
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
#[test] |
| 15 |
fn clones_do_not_block_mutation() { |
| 16 |
let parser = Parser::default(); |
| 17 |
let doc = parser.parse_file("tests/resources/file01.xml").unwrap(); |
| 18 |
let root = doc.get_root_element().unwrap(); |
| 19 |
|
| 20 |
|
| 21 |
let mut first_a = root.get_first_element_child().unwrap(); |
| 22 |
let first_b = root.get_first_element_child().unwrap(); |
| 23 |
|
| 24 |
assert_eq!(first_a.get_attribute("attribute"), Some(String::from("value"))); |
| 25 |
assert_eq!(first_b.get_attribute("attribute"), Some(String::from("value"))); |
| 26 |
|
| 27 |
|
| 28 |
assert!(first_a.set_attribute("attribute", "newa").is_ok()); |
| 29 |
|
| 30 |
|
| 31 |
assert_eq!(first_a.get_attribute("attribute"), Some(String::from("newa"))); |
| 32 |
assert_eq!(first_b.get_attribute("attribute"), Some(String::from("newa"))); |
| 33 |
} |
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
#[test] |
| 39 |
#[allow(deprecated)] |
| 40 |
fn set_node_rc_guard_is_a_noop() { |
| 41 |
use libxml::tree::set_node_rc_guard; |
| 42 |
|
| 43 |
let parser = Parser::default(); |
| 44 |
let doc = parser.parse_file("tests/resources/file01.xml").unwrap(); |
| 45 |
let mut node = doc |
| 46 |
.get_root_element() |
| 47 |
.unwrap() |
| 48 |
.get_first_element_child() |
| 49 |
.unwrap(); |
| 50 |
let _alias = node.clone(); |
| 51 |
|
| 52 |
set_node_rc_guard(1); |
| 53 |
assert!(node.set_attribute("k", "v").is_ok()); |
| 54 |
} |