Skip to content

Commit

Permalink
Fix tests using new package name.
Browse files Browse the repository at this point in the history
  • Loading branch information
daemontus committed May 15, 2024
1 parent dce3ce7 commit 217e9c6
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 31 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ If your project modifies multiple xml documents at the same time, this library m
## Example

```rust
use xml_doc::{Document, Element};
use biodivine_xml_doc::{Document, Element};

let XML = r#"<?xml version="1.0"?>
<package xmlns:dc="http://purl.org/dc/elements/1.1/">
Expand Down
4 changes: 2 additions & 2 deletions src/document.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ impl Node {
/// Useful to use inside `filter_map`.
///
/// ```rust
/// use xml_doc::{Document, Element};
/// use biodivine_xml_doc::{Document, Element};
///
/// let mut doc = Document::parse_str(r#"<?xml version="1.0" encoding="UTF-8"?>
/// <config>
Expand Down Expand Up @@ -86,7 +86,7 @@ impl Node {
///
/// # Examples
/// ```rust
/// use xml_doc::Document;
/// use biodivine_xml_doc::Document;
///
/// let mut doc = Document::parse_str(r#"<?xml version="1.0" encoding="UTF-8"?>
/// <package>
Expand Down
22 changes: 11 additions & 11 deletions src/element.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub(crate) struct ElementData {
/// # Examples
///
/// ```
/// use xml_doc::{Document, Element, Node};
/// use biodivine_xml_doc::{Document, Element, Node};
///
/// let mut doc = Document::new();
///
Expand Down Expand Up @@ -126,7 +126,7 @@ impl ElementBuilder {
///
/// Find children nodes with attribute
/// ```
/// use xml_doc::{Document, Element};
/// use biodivine_xml_doc::{Document, Element};
///
/// let doc = Document::parse_str(r#"<?xml version="1.0"?>
/// <data>
Expand Down Expand Up @@ -163,7 +163,7 @@ impl Element {
///
/// # Example
/// ```
/// use xml_doc::{Document, Element, Node};
/// use biodivine_xml_doc::{Document, Element, Node};
///
/// let mut doc = Document::new();
///
Expand Down Expand Up @@ -330,7 +330,7 @@ impl Element {
///
/// The attribute names may have namespace prefix. To strip the prefix and only its name, call [`Element::separate_prefix_name`].
/// ```
/// use xml_doc::{Document, Element};
/// use biodivine_xml_doc::{Document, Element};
///
/// let mut doc = Document::new();
/// let element = Element::build("name")
Expand Down Expand Up @@ -444,7 +444,7 @@ impl Element {
/// See [Self::closest_prefix] for the definitions of which prefix will be used.
///
/// ```rust
/// use xml_doc::Document;
/// use biodivine_xml_doc::Document;
///
/// let mut doc = Document::parse_str(r#"<?xml version="1.0" encoding="UTF-8"?>
/// <parent xmlns="http://ns1" xmlns:ns1="http://ns1" xmlns:ns2="http://ns2">
Expand Down Expand Up @@ -606,7 +606,7 @@ impl Element {
/// specified namespace (identified by a `namespace_url`).
///
/// ```rust
/// use xml_doc::Document;
/// use biodivine_xml_doc::Document;
///
/// let mut doc = Document::parse_str(r#"<?xml version="1.0" encoding="UTF-8"?>
/// <parent xmlns:ns1="http://ns1" xmlns:ns2="http://ns2">
Expand Down Expand Up @@ -645,7 +645,7 @@ impl Element {
/// specified namespace (identified by a `namespace_url`).
///
/// ```rust
/// use xml_doc::Document;
/// use biodivine_xml_doc::Document;
///
/// let mut doc = Document::parse_str(r#"<?xml version="1.0" encoding="UTF-8"?>
/// <parent xmlns="http://ns1" xmlns:ns1="http://ns1" xmlns:ns2="http://ns2">
Expand Down Expand Up @@ -690,7 +690,7 @@ impl Element {
/// The default prefix is represented as an empty string slice.
///
/// ```rust
/// use xml_doc::Document;
/// use biodivine_xml_doc::Document;
///
/// let mut doc = Document::parse_str(r#"<?xml version="1.0" encoding="UTF-8"?>
/// <parent xmlns="http://ns1" xmlns:ns1="http://ns1" xmlns:ns2="http://ns1">
Expand Down Expand Up @@ -752,7 +752,7 @@ impl Element {
///
/// ```rust
/// use std::collections::HashMap;
/// use xml_doc::Document;
/// use biodivine_xml_doc::Document;
///
/// let mut doc = Document::parse_str(r#"<?xml version="1.0" encoding="UTF-8"?>
/// <parent xmlns="http://ns1" xmlns:ns1="http://ns1" xmlns:ns2="http://ns1">
Expand Down Expand Up @@ -801,7 +801,7 @@ impl Element {
///
/// ```rust
/// use std::collections::HashMap;
/// use xml_doc::Document;
/// use biodivine_xml_doc::Document;
///
/// let mut doc = Document::parse_str(r#"<?xml version="1.0" encoding="UTF-8"?>
/// <parent xmlns="http://ns1" xmlns:ns1="http://ns1" xmlns:ns2="http://ns1">
Expand Down Expand Up @@ -890,7 +890,7 @@ impl Element {
/// namespace which prevents you from having "no namespace" on this element.
///
/// ```rust
/// use xml_doc::Document;
/// use biodivine_xml_doc::Document;
///
/// let mut doc = Document::parse_str(r#"<?xml version="1.0" encoding="UTF-8"?>
/// <parent xmlns="http://ns1" xmlns:ns1="http://ns1" xmlns:ns2="http://ns2">
Expand Down
11 changes: 6 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@
//!
//! # Example
//! ```
//! use xml_doc::{Document, Element, Node};
//! use biodivine_xml_doc::{Document, Element, Node};
//!
//! const data: &'static str = r#"<?xml version="1.0" encoding="utf-8"?>
//! const DATA: &'static str = r#"<?xml version="1.0" encoding="utf-8"?>
//! <metadata>
//! <title>The Felloship of the Ring</title>
//! <author>J. R. R. Tolkien</author>
//! <date>1954</date>
//! </metadata>
//! "#;
//!
//! let mut doc = Document::parse_str(data).unwrap();
//! let mut doc = Document::parse_str(DATA).unwrap();
//! let metadata = doc.root_element().unwrap();
//!
//! // Add a new element
Expand All @@ -37,7 +37,7 @@
//! Below example goes through the root element's children and removes all nodes that isn't `<conf>...</conf>`
//! ```no_run
//! use std::path::Path;
//! use xml_doc::{Document, Node};
//! use biodivine_xml_doc::{Document, Node};
//!
//! let xml_file = Path::new("config.xml");
//! let mut doc = Document::parse_file(&xml_file).unwrap();
Expand All @@ -57,7 +57,8 @@
//! for i in to_remove.iter().rev() {
//! root.remove_child(&mut doc, *i);
//! }
//! doc.write_file(&xml_file);
//! doc.write_file(&xml_file)
//! .expect("Writing failed.");
//! ```
//!
mod document;
Expand Down
17 changes: 7 additions & 10 deletions tests/test_documents.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use biodivine_xml_doc::{Document, Element, Node, ReadOptions};
use itertools::Itertools;
use std::collections::HashMap;
use std::fmt;
use std::fmt::Write;
use std::path::Path;
use std::str::FromStr;
use xml_doc::{Document, Element, Node, ReadOptions};

#[derive(Clone)]
struct TStr(pub String);
Expand Down Expand Up @@ -146,11 +146,10 @@ fn test_write(doc: &Document) -> TStr {
println!("{:?}", &written_xml);
let new_doc = Document::from_str(&written_xml).unwrap();
let result = TStr(to_yaml(&new_doc));
assert!(
expected == result,
assert_eq!(
expected, result,
"\n===expected==={:?}\n===result==={:?}\nWRITING\n",
expected,
result,
expected, result
);
expected
}
Expand Down Expand Up @@ -193,12 +192,10 @@ where
}
};

assert!(
expected == result,
assert_eq!(
expected, result,
"\noptions: {:?}\n===expected==={:?}===result==={:?}\nREADING\n",
read_options,
expected,
result,
read_options, expected, result
);
}
// Test write
Expand Down
2 changes: 1 addition & 1 deletion tests/test_parse.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use xml_doc::{Document, Error, Node, ReadOptions};
use biodivine_xml_doc::{Document, Error, Node, ReadOptions};

#[test]
fn test_normalize_attr() {
Expand Down
2 changes: 1 addition & 1 deletion tests/test_write.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use xml_doc::{Document, Element, Node};
use biodivine_xml_doc::{Document, Element, Node};

#[test]
fn test_escape() {
Expand Down

0 comments on commit 217e9c6

Please sign in to comment.