Search in sources :

Example 11 with Text

use of org.cactoos.Text in project cactoos by yegor256.

the class BytesOfTest method asBytes.

@Test
void asBytes() throws Exception {
    final Text text = new TextOf("Hello!");
    new Assertion<>("Can't convert text into bytes", new BytesOf(new InputOf(text)).asBytes(), new IsEqual<>(new BytesOf(text.asString()).asBytes())).affirm();
}
Also used : Text(org.cactoos.Text) IsText(org.llorllale.cactoos.matchers.IsText) TextOf(org.cactoos.text.TextOf) InputOf(org.cactoos.io.InputOf) IsEqual(org.hamcrest.core.IsEqual) Test(org.junit.jupiter.api.Test)

Example 12 with Text

use of org.cactoos.Text in project cactoos by yegor256.

the class UncheckedTextTest method equalsToTheSameTextObject.

@Test
void equalsToTheSameTextObject() {
    final Text text = new TextOf("anything");
    new Assertion<>("Must match text representing the same value", new UncheckedText(text), new IsEqual<>(text)).affirm();
}
Also used : Text(org.cactoos.Text) IsEqual(org.hamcrest.core.IsEqual) Test(org.junit.jupiter.api.Test)

Example 13 with Text

use of org.cactoos.Text in project cactoos by yegor256.

the class SplitTest method splitTextWithTextRegexAndLimit.

@Test
void splitTextWithTextRegexAndLimit() throws Exception {
    final Text txt = new TextOf("Split!# #OOP");
    new Assertion<>("Must split text with text regex and limit", new Split(txt, "\\W+", 1), new IsEqual<>(new IterableOf<>(txt))).affirm();
}
Also used : Text(org.cactoos.Text) IsEqual(org.hamcrest.core.IsEqual) Test(org.junit.jupiter.api.Test)

Example 14 with Text

use of org.cactoos.Text in project cactoos by yegor256.

the class StickyTest method equalsItself.

@Test
void equalsItself() {
    final Text random = new Randomized();
    final Text sticky = new Sticky(random);
    new Assertion<>("must be the same as itself", sticky, new AllOf<Text>(new IsEqual<>(sticky), new IsNot<>(new IsEqual<>(random)))).affirm();
}
Also used : Text(org.cactoos.Text) IsText(org.llorllale.cactoos.matchers.IsText) AllOf(org.hamcrest.core.AllOf) IsEqual(org.hamcrest.core.IsEqual) Test(org.junit.jupiter.api.Test)

Example 15 with Text

use of org.cactoos.Text in project cactoos by yegor256.

the class StickyTest method cachesResult.

@Test
void cachesResult() {
    final Text sticky = new Sticky(new Randomized());
    new Assertion<>("must be the same", sticky, new IsText(sticky)).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