f-office-docx 0.2.4

DOCX model and Word's layout rules.
Documentation
//! Tests of the edits of a test's XML text, which fail when the text that they change is not
//! there.

use super::Replaced as _;

#[test]
fn replaces_the_one_anchor_or_each_anchor() {
    assert_eq!("<a/><b/>".replaced("<b/>", "<c/>"), "<a/><c/>");
    assert_eq!("<b/><a/><b/>".replaced_all("<b/>", "<c/>"), "<c/><a/><c/>");
}

#[test]
#[should_panic(expected = "the XML holds \"<c/>\" 0 times, not once")]
fn refuses_to_replace_an_anchor_that_is_not_there() {
    let _ = "<a/><b/>".replaced("<c/>", "<d/>");
}

#[test]
#[should_panic(expected = "the XML holds \"<b/>\" 2 times, not once")]
fn refuses_to_replace_one_of_two_anchors() {
    let _ = "<b/><a/><b/>".replaced("<b/>", "<c/>");
}

#[test]
#[should_panic(expected = "the XML does not hold \"<c/>\"")]
fn refuses_to_replace_each_of_no_anchors() {
    let _ = "<a/><b/>".replaced_all("<c/>", "<d/>");
}