refactor: remove test redundancy, reduce API surface
- Remove duplicate xml_escape tests from sitemap.rs and feed.rs (already tested in escape.rs) - Make html_escape_into private (only used internally)
This commit is contained in:
@@ -12,7 +12,7 @@ pub fn html_escape(s: &str) -> String {
|
|||||||
/// Escape HTML characters into an existing string.
|
/// Escape HTML characters into an existing string.
|
||||||
///
|
///
|
||||||
/// This is more efficient when building output incrementally.
|
/// This is more efficient when building output incrementally.
|
||||||
pub fn html_escape_into(out: &mut String, s: &str) {
|
fn html_escape_into(out: &mut String, s: &str) {
|
||||||
for c in s.chars() {
|
for c in s.chars() {
|
||||||
match c {
|
match c {
|
||||||
'&' => out.push_str("&"),
|
'&' => out.push_str("&"),
|
||||||
|
|||||||
11
src/feed.rs
11
src/feed.rs
@@ -80,14 +80,3 @@ pub fn generate_atom_feed(
|
|||||||
entries,
|
entries,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod tests {
|
|
||||||
use super::*;
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_xml_escape() {
|
|
||||||
assert_eq!(xml_escape("Hello & World"), "Hello & World");
|
|
||||||
assert_eq!(xml_escape("<tag>"), "<tag>");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -93,14 +93,6 @@ fn build_sitemap_xml(entries: &[SitemapEntry]) -> String {
|
|||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_xml_escape() {
|
|
||||||
assert_eq!(xml_escape("Hello & World"), "Hello & World");
|
|
||||||
assert_eq!(xml_escape("<tag>"), "<tag>");
|
|
||||||
assert_eq!(xml_escape("\"quoted\""), ""quoted"");
|
|
||||||
assert_eq!(xml_escape("it's"), "it's");
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_build_sitemap_xml_single_entry() {
|
fn test_build_sitemap_xml_single_entry() {
|
||||||
let entries = vec![SitemapEntry {
|
let entries = vec![SitemapEntry {
|
||||||
|
|||||||
Reference in New Issue
Block a user