diff --git a/tests/errors.rs b/tests/errors.rs
index ac39e1d..0b1cdbe 100644
--- a/tests/errors.rs
+++ b/tests/errors.rs
@@ -1,60 +1,38 @@
-// TODO: Extract all the OPML strings out and put them into their own files.
+use std::fs::read_to_string as read;
use opml::*;
#[test]
#[should_panic]
fn test_invalid_xml() {
- OPML::new(r#"{not xml :)"#).unwrap();
+ let sample = read("tests/samples/invalid_xml.opml").unwrap();
+ OPML::new(sample.as_str()).unwrap();
}
#[test]
#[should_panic(expected = "Unsupported OPML version detected: 1.0")]
fn test_invalid_opml_version_1_0() {
- OPML::new(
- r#"
-
-
-
-
-
-"#,
- )
- .unwrap();
+ let sample = read("tests/samples/invalid_opml_version_1_0.opml").unwrap();
+ OPML::new(sample.as_str()).unwrap();
}
#[test]
#[should_panic(expected = "Unsupported OPML version detected: 1.1")]
fn test_invalid_opml_version_1_1() {
- OPML::new(
- r#"
-
-
-
-
-
-"#,
- )
- .unwrap();
+ let sample = read("tests/samples/invalid_opml_version_1_1.opml").unwrap();
+ OPML::new(sample.as_str()).unwrap();
}
#[test]
#[should_panic(expected = "Unsupported OPML version detected: invalid")]
fn test_invalid_opml_version() {
- OPML::new(
- r#"
-
-
-
-
-
-"#,
- )
- .unwrap();
+ let sample = read("tests/samples/invalid_opml_version.opml").unwrap();
+ OPML::new(sample.as_str()).unwrap();
}
#[test]
#[should_panic(expected = "OPML body has no outlines.")]
fn test_invalid_opml_no_outlines() {
- OPML::new(r#"
+
+
+
diff --git a/tests/samples/invalid_opml_version_1_0.opml b/tests/samples/invalid_opml_version_1_0.opml
new file mode 100644
index 0000000..94b663d
--- /dev/null
+++ b/tests/samples/invalid_opml_version_1_0.opml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
diff --git a/tests/samples/invalid_opml_version_1_1.opml b/tests/samples/invalid_opml_version_1_1.opml
new file mode 100644
index 0000000..fc5748d
--- /dev/null
+++ b/tests/samples/invalid_opml_version_1_1.opml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
diff --git a/tests/samples/invalid_xml.opml b/tests/samples/invalid_xml.opml
new file mode 100644
index 0000000..dcd8672
--- /dev/null
+++ b/tests/samples/invalid_xml.opml
@@ -0,0 +1 @@
+{not xml :)
diff --git a/tests/samples/minimum_valid_opml.opml b/tests/samples/minimum_valid_opml.opml
new file mode 100644
index 0000000..56d3530
--- /dev/null
+++ b/tests/samples/minimum_valid_opml.opml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
diff --git a/tests/samples/valid_opml_with_everything.opml b/tests/samples/valid_opml_with_everything.opml
new file mode 100644
index 0000000..aed3d69
--- /dev/null
+++ b/tests/samples/valid_opml_with_everything.opml
@@ -0,0 +1,46 @@
+
+
+ Title
+ Date Created
+ Date Modified
+ Owner Name
+ Owner Email
+ Owner ID
+ http://dev.opml.org/spec2.html
+ 0,1
+ 0
+ 1
+ 2
+ 3
+ 4
+
+
+
+
+
+
+
diff --git a/tests/valid.rs b/tests/valid.rs
index 7610c7d..d8f2497 100644
--- a/tests/valid.rs
+++ b/tests/valid.rs
@@ -1,20 +1,11 @@
-// TODO: Extract all the OPML strings out and put them into their own files.
+use std::fs::read_to_string as read;
use opml::*;
#[test]
fn test_minimum_valid_opml() {
assert_eq!(
- OPML::new(
- r#"
-
-
-
-
-
-"#
- )
- .unwrap(),
+ OPML::new(&read("tests/samples/minimum_valid_opml.opml").unwrap()).unwrap(),
OPML {
version: "2.0".to_string(),
head: Head {
@@ -57,58 +48,8 @@ fn test_minimum_valid_opml() {
#[test]
fn test_valid_opml_with_everything() {
assert_eq!(
- OPML::new(
- r#"
-
-
- Title
- Date Created
- Date Modified
- Owner Name
- Owner Email
- Owner ID
- http://dev.opml.org/spec2.html
- 0,1
- 0
- 1
- 2
- 3
- 4
-
-
-
-
-
-
-"#
- )
- .unwrap(),
+ OPML::new(&read("tests/samples/valid_opml_with_everything.opml").unwrap())
+ .unwrap(),
OPML {
version: "2.0".to_string(),
head: Head {