Crate string_sequence_tester

Crate string_sequence_tester 

Source
Expand description

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));

Structs§

Line
The content of a line, with a LineModifier.
Sequence
A sequence of consecutive lines.

Enums§

LineModifier
Line modifiers.
SequenceTree
A Sequence logical tree for complex conditions.