use of org.cactoos.Text in project cactoos by yegor256.
the class FlattenedTest method flattens.
@Test
void flattens() {
final Text txt = new TextOf("txt");
final Scalar<Text> sclr = new Constant<>(txt);
new Assertion<>("must flatten", new Flattened<>(new ScalarOf<>(() -> sclr)), new HasValue<>(new IsText(txt))).affirm();
}
use of org.cactoos.Text in project cactoos by yegor256.
the class AbbreviatedTest method abbreviatesTextThatChanges.
@Test
@SuppressWarnings("unchecked")
void abbreviatesTextThatChanges() {
final AtomicInteger counter = new AtomicInteger(0);
final Text txt = new TextOf(() -> {
final String result;
if (counter.getAndIncrement() == 0) {
result = "The quick brown fox jumps";
} else {
result = "The lazy black dog";
}
return result;
});
new Assertion<>("Must abbreviate a text that changes", new Abbreviated(txt, 15), new AllOf<>(new IsText("The quick br..."), new IsText("The lazy bla..."))).affirm();
}
use of org.cactoos.Text in project cactoos by yegor256.
the class ComparableTextTest method equalsToItself.
@Test
public void equalsToItself() {
final Text text = new TextOf("text");
new Assertion<>("Does not equal to itself", text, new IsText(text)).affirm();
}
use of org.cactoos.Text in project cactoos by yegor256.
the class ComparableTextTest method equalsAndHashCodeOfComparableOfTheSameText.
@Test
public void equalsAndHashCodeOfComparableOfTheSameText() {
final Text text = new TextOf("my text");
final Text actual = new ComparableText(text);
final Text expected = new ComparableText(text);
new Assertion<>("Does not equal to a comparable text made from the same Text", actual, new IsEqual<>(expected)).affirm();
new Assertion<>("Hash codes of the equal objects are not equal", actual.hashCode(), new IsEqual<>(expected.hashCode())).affirm();
}
use of org.cactoos.Text in project cactoos by yegor256.
the class FlattenedTest method flattens.
@Test
void flattens() {
final Text txt = new TextOf("txt");
new Assertion<>("must flatten", new Flattened(new ScalarOf<>(() -> txt)), new IsText(txt)).affirm();
}
Aggregations