Search in sources :

Example 16 with Text

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();
}
Also used : IsText(org.llorllale.cactoos.matchers.IsText) Text(org.cactoos.Text) IsText(org.llorllale.cactoos.matchers.IsText) TextOf(org.cactoos.text.TextOf) HasValue(org.llorllale.cactoos.matchers.HasValue) Test(org.junit.jupiter.api.Test)

Example 17 with Text

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();
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) IsText(org.llorllale.cactoos.matchers.IsText) Text(org.cactoos.Text) IsText(org.llorllale.cactoos.matchers.IsText) AllOf(org.hamcrest.core.AllOf) Test(org.junit.jupiter.api.Test)

Example 18 with Text

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();
}
Also used : IsText(org.llorllale.cactoos.matchers.IsText) Text(org.cactoos.Text) IsText(org.llorllale.cactoos.matchers.IsText) Test(org.junit.Test)

Example 19 with Text

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();
}
Also used : Text(org.cactoos.Text) IsText(org.llorllale.cactoos.matchers.IsText) IsEqual(org.hamcrest.core.IsEqual) Test(org.junit.Test)

Example 20 with Text

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();
}
Also used : IsText(org.llorllale.cactoos.matchers.IsText) Text(org.cactoos.Text) IsText(org.llorllale.cactoos.matchers.IsText) Test(org.junit.jupiter.api.Test)

Aggregations

Text (org.cactoos.Text)20 Test (org.junit.jupiter.api.Test)15 IsText (org.llorllale.cactoos.matchers.IsText)11 TextOf (org.cactoos.text.TextOf)9 IsEqual (org.hamcrest.core.IsEqual)9 Test (org.junit.Test)5 AllOf (org.hamcrest.core.AllOf)3 IterableOf (org.cactoos.iterable.IterableOf)2 FormattedText (org.cactoos.text.FormattedText)2 JoinedText (org.cactoos.text.JoinedText)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 StringReader (java.io.StringReader)1 StandardCharsets (java.nio.charset.StandardCharsets)1 ArrayList (java.util.ArrayList)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 Logger (java.util.logging.Logger)1 InputOf (org.cactoos.io.InputOf)1