Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Firefox/third_party/rust/mockito/src/   (Firefox Browser Version 153.0.1©)  Datei vom 27.6.2026 mit Größe 2 kB image not shown  

Quelle  diff.rs

  Sprache: Rust
 

#[cfg(feature = "color")]
use colored::*;
use similar::{Change, ChangeTag, TextDiff};

pub fn compare(expected: &str, actual: &str) -> String {
    let mut result = String::new();

    let clean_expected = expected.replace("\r\n""\n");
    let clean_actual = actual.replace("\r\n""\n");

    let mut last: Option<Change<_>> = None;
    for diff in TextDiff::from_lines(&clean_expected, &clean_actual).iter_all_changes() {
        let x = diff.value();
        match diff.tag() {
            ChangeTag::Equal => {
                result.push_str(x);
            }
            ChangeTag::Insert => {
                if let Some((y, ChangeTag::Delete)) = last.map(|d| (d.value(), d.tag())) {
                    for change in TextDiff::from_words(y, x).iter_all_changes() {
                        match change.tag() {
                            ChangeTag::Equal => {
                                let z = change.value();
                                #[cfg(feature = "color")]
                                result.push_str(&z.green().to_string());
                                #[cfg(not(feature = "color"))]
                                result.push_str(z);
                            }
                            ChangeTag::Insert => {
                                let z = change.value();
                                #[cfg(feature = "color")]
                                result.push_str(&z.white().on_green().to_string());
                                #[cfg(not(feature = "color"))]
                                result.push_str(z);
                            }
                            _ => (),
                        }
                    }
                } else {
                    #[cfg(feature = "color")]
                    result.push_str(&x.bright_green().to_string());
                    #[cfg(not(feature = "color"))]
                    result.push_str(x);
                }
            }
            ChangeTag::Delete => {
                #[cfg(feature = "color")]
                result.push_str(&x.red().to_string());
                #[cfg(not(feature = "color"))]
                result.push_str(x);
            }
        }

        last = Some(diff);
    }

    result.push('\n');

    result
}

Messung V0.5 in Prozent
C=91 H=95 G=92

¤ Dauer der Verarbeitung: 0.3 Sekunden  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.