string_sequence_tester/
lib.rs

1//! This crate defines a simple structure for testing the content of a string and checking whether
2//! it contains one or more sequences of consecutive lines.
3//!
4//! This can be useful for testing proc-macro expansions (which is the usecase that started the
5//! development of this crate).
6//!
7//! A [Sequence] is a collection of consecutive [Line]s that mus be checked against the lines of a
8//! text; to check a [Sequence] presence in a text, a [SequenceTree] must be used.
9//!
10//! A [SequenceTree] allows performing checks with both only one [Sequence] and with multiple,
11//! logically linked [Sequence]s. The [SequenceTree] variants show which logic operators can be
12//! applied to [Sequence]s.
13//!
14//! # Examples
15//! ```rust
16//! extern crate string_sequence_tester;
17//! use string_sequence_tester::{SequenceTree,Sequence,Line,LineModifier};
18//!
19//! let TEST_LINES: Vec<String> = concat!(
20//! "First line\n",
21//! "Second line\n",
22//! "Third line\n",
23//! "Fourth line\n",
24//! "Fifth line\n",
25//! "Sixth line\n",
26//! "Seventh line\n",
27//! "Eighth line\n",
28//! "Ninth line\n",
29//! "Tenth line\n",
30//! "Eleventh line\n",
31//! ).lines().map(|it| it.to_owned()).collect();
32//!
33//! let sequence_tree = SequenceTree::Sequence(
34//!     Sequence::new(vec![
35//!         Line::verbatim("First line"),
36//!         Line::trimmed("Second line"),
37//!     ])
38//! );
39//!
40//! assert!(sequence_tree.accept(&TEST_LINES));
41//! ```
42#![deny(missing_docs)]
43mod line;
44mod sequence;
45mod sequence_tree;
46
47pub use line::{Line, LineModifier};
48pub use sequence::Sequence;
49pub use sequence_tree::SequenceTree;