webpage_quality_analyzer 1.0.2

High-performance webpage quality analyzer with 115 comprehensive metrics - Rust library with WASM, C++, and Python bindings
Documentation
//! Centralized test fixtures and HTML constants
//!
//! This module provides standardized HTML test fixtures to eliminate
//! duplication across test files and examples.

/// Basic HTML structure with common elements
pub const BASIC_HTML: &str = r#"<!DOCTYPE html>
<html>
<head>
    <title>Test Page</title>
    <meta name="description" content="A simple test page">
</head>
<body>
    <h1>Test Page</h1>
    <p>This is a test page content.</p>
    <a href="https://example.com">External link</a>
    <img src="test.jpg" alt="Test image">
</body>
</html>"#;

/// Minimal HTML for simple tests
pub const MINIMAL_HTML: &str = r#"<!DOCTYPE html>
<html>
<head><title>Minimal</title></head>
<body><p>Minimal content</p></body>
</html>"#;

/// Malformed HTML for error testing
pub const MALFORMED_HTML: &str =
    r#"<html><head><title>Test</head><body><p>Missing closing tags and malformed structure"#;

/// Comprehensive HTML with multiple elements
pub const COMPREHENSIVE_HTML: &str = r#"<!DOCTYPE html>
<html>
<head>
    <title>Test Page</title>
    <meta name="description" content="A simple test page">
</head>
<body>
    <h1>Test Page</h1>
    <p>This is a test page content.</p>
    <a href="https://example.com">External link</a>
    <img src="test.jpg" alt="Test image">
    <form>
        <label for="test">Test field</label>
        <input type="text" id="test" name="test">
        <button type="submit">Submit</button>
    </form>
</body>
</html>"#;

/// HTML with structured headings
pub const STRUCTURED_HTML: &str = r#"<!DOCTYPE html>
<html>
<head><title>Structured Content</title></head>
<body>
    <h1>Main Title</h1>
    <h2>Section 1</h2>
    <p>Content for section 1.</p>
    <h2>Section 2</h2>
    <p>Content for section 2.</p>
    <h3>Subsection 2.1</h3>
    <p>Subsection content.</p>
</body>
</html>"#;

/// HTML with media elements
pub const MEDIA_HTML: &str = r#"<!DOCTYPE html>
<html>
<head><title>Media Test</title></head>
<body>
    <h1>Media Content</h1>
    <img src="image1.jpg" alt="First image">
    <img src="image2.jpg" alt="Second image">
    <video src="video.mp4">Video content</video>
    <audio src="audio.mp3">Audio content</audio>
</body>
</html>"#;

/// Large HTML document for performance testing
pub const LARGE_HTML: &str = r#"<!DOCTYPE html>
<html>
<head><title>Large Document</title></head>
<body>
    <h1>Large Content</h1>
    <div class="content">
        <p>This is a large document with many paragraphs for testing performance.</p>
        <p>Each paragraph contains sufficient text to test word counting and analysis.</p>
        <p>The document includes multiple sections and various elements.</p>
        <p>Content continues with more paragraphs to reach adequate size.</p>
        <p>Performance testing requires substantial content volume.</p>
        <p>Additional paragraphs ensure comprehensive analysis coverage.</p>
        <p>The large document tests system behavior under load.</p>
        <p>Multiple paragraphs provide realistic content scenarios.</p>
        <p>Extensive content helps validate algorithm efficiency.</p>
        <p>Final paragraphs complete the large document structure.</p>
    </div>
</body>
</html>"#;

/// Simple blog post HTML for profile testing
pub const BLOG_HTML: &str = r#"<html>
<head><title>My Blog Post</title></head>
<body>
    <h1>Blog Post</h1>
    <p>Personal thoughts and experiences.</p>
</body>
</html>"#;

/// Product page HTML for e-commerce testing
pub const PRODUCT_HTML: &str = r#"<html>
<head><title>Amazing Product</title></head>
<body>
    <h1>Product Name</h1>
    <p>Product description with features and benefits.</p>
</body>
</html>"#;

/// News article HTML for news profile testing
pub const NEWS_HTML: &str = r#"<html>
<head><title>Breaking News</title></head>
<body>
    <h1>News Headline</h1>
    <p>Latest news update with factual information.</p>
</body>
</html>"#;

/// Sample article with proper structure
pub const SAMPLE_ARTICLE_HTML: &str = r#"<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Sample Article</title>
    <meta name="description" content="A well-structured article about web development.">
</head>
<body>
    <h1>Web Development Best Practices</h1>
    <p>This article covers essential best practices for modern web development.</p>
    
    <h2>HTML Structure</h2>
    <p>Proper HTML structure is crucial for accessibility and SEO. Always use semantic elements.</p>
    
    <h2>Performance Optimization</h2>
    <p>Optimize your website for fast loading times by minimizing resources and using modern techniques.</p>
    
    <ul>
        <li>Minimize HTTP requests</li>
        <li>Optimize images</li>
        <li>Use compression</li>
    </ul>
    
    <p>Following these practices will improve user experience and search engine rankings.</p>
</body>
</html>"#;

/// Unicode and emoji test content
pub const UNICODE_HTML: &str = r#"<!DOCTYPE html>
<html lang="ja">
<head><title>Unicode Test - こんにちは</title></head>
<body>
    <h1>Unicode Content 🌍</h1>
    <p>This page contains unicode: こんにちは世界 🚀 éñüíóáç ñáéíóú</p>
    <p>Emoji content: 😀 🎉 🌟 💫 ⭐</p>
</body>
</html>"#;

/// Empty elements for edge case testing
pub const EMPTY_ELEMENTS_HTML: &str = r#"<!DOCTYPE html>
<html>
<head><title>Empty Elements</title></head>
<body>
    <h1></h1>
    <p></p>
    <div></div>
    <span></span>
    <a href=""></a>
    <img src="" alt="">
</body>
</html>"#;
#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_html_constants_are_valid() {
        // Basic validation that constants contain expected elements
        assert!(BASIC_HTML.contains("<title>Test Page</title>"));
        assert!(BASIC_HTML.contains("<h1>Test Page</h1>"));
        assert!(MINIMAL_HTML.contains("<title>Minimal</title>"));
        assert!(COMPREHENSIVE_HTML.contains("<form>"));
    }

    #[test]
    fn test_basic_html_structure() {
        // Test that our constants have proper HTML structure
        assert!(BASIC_HTML.starts_with("<!DOCTYPE html>"));
        assert!(BASIC_HTML.contains("</html>"));

        assert!(MINIMAL_HTML.starts_with("<!DOCTYPE html>"));
        assert!(MINIMAL_HTML.contains("</html>"));

        assert!(COMPREHENSIVE_HTML.starts_with("<!DOCTYPE html>"));
        assert!(COMPREHENSIVE_HTML.contains("</html>"));
    }
}