fest-assert-2.x icon indicating copy to clipboard operation
fest-assert-2.x copied to clipboard

Add StringAssert.containsSequence

Open bric3 opened this issue 12 years ago • 3 comments

In the same idea as issue 120 https://github.com/alexruiz/fest-assert-2.x/issues/120

It would nice to be able to test that different portions of a string appears in order (whatever is between them). So at each eaten verified "subsequence", the assertion will verify only to the rest of the non verified String. It could be useful to verify a portion of an XML node for example.

bric3 avatar Feb 19 '13 14:02 bric3

If I understand you correctly the assertion below would succeed ...

String book = "{ 'title':'A Game of Thrones', 'author':'George Martin'}";
assertThat(book).containsSequence("{", "title", "A Game of Thrones", "}");

... while this one would fail as "author" comes after "A Game of Thrones" :

assertThat(book).containsSequence("{", "author", "A Game of Thrones", "}");

I think this can be a nice addition to String assertions, thanks for the idea.

joel-costigliola avatar Feb 19 '13 17:02 joel-costigliola

Precisely what I meant :)

Hackergarteny idea I think ;)

bric3 avatar Feb 19 '13 17:02 bric3

For your information, this issue has been fixed in AssertJ a fork of Fest Assert 2.0M10.

joel-costigliola avatar Apr 15 '13 08:04 joel-costigliola