Skip to content

asperan/string-sequence-tester

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages