string_sequence_tester

Crates.iostring_sequence_tester
lib.rsstring_sequence_tester
version0.1.0
created_at2025-10-05 10:10:27.921958+00
updated_at2025-10-05 10:10:27.921958+00
descriptionLibrary for testing line sequences, primarily for proc-macro expansions.
homepage
repositoryhttps://github.com/asperan/string-sequence-tester
max_upload_size
id1868860
size29,093
Alex Speranza (asperan)

documentation

README

string_sequence_tester

This crate defines a simple structure for testing the content of a string and checking whether it contains one or more sequences of consecutive lines.

This can be useful for testing proc-macro expansions (which is the usecase that started the development of this crate).

A Sequence is a collection of consecutive Lines that mus be checked against the lines of a text; to check a Sequence presence in a text, a SequenceTree must be used.

A SequenceTree allows performing checks with both only one Sequence and with multiple, logically linked Sequences. The SequenceTree variants show which logic operators can be applied to Sequences.

Examples

extern crate string_sequence_tester;
use string_sequence_tester::{SequenceTree,Sequence,Line,LineModifier};

let TEST_LINES: Vec<String> = concat!(
"First line\n",
"Second line\n",
"Third line\n",
"Fourth line\n",
"Fifth line\n",
"Sixth line\n",
"Seventh line\n",
"Eighth line\n",
"Ninth line\n",
"Tenth line\n",
"Eleventh line\n",
).lines().map(|it| it.to_owned()).collect();

let sequence_tree = SequenceTree::Sequence(
    Sequence::new(vec![
        Line::verbatim("First line"),
        Line::trimmed("Second line"),
    ])
);

assert!(sequence_tree.accept(&TEST_LINES));
Commit count: 0

cargo fmt