Search in sources :

Example 6 with Text

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

the class BytesOfTest method asBytesFromIterable.

@Test
void asBytesFromIterable() throws Exception {
    final Text text = new TextOf("Good bye");
    new Assertion<>("Must convert iterable into bytes", new BytesOf(new IterableOfBytes(text)).asBytes(), new IsEqual<>(new BytesOf(text).asBytes())).affirm();
}
Also used : Text(org.cactoos.Text) IsText(org.llorllale.cactoos.matchers.IsText) TextOf(org.cactoos.text.TextOf) IterableOfBytes(org.cactoos.iterable.IterableOfBytes) IsEqual(org.hamcrest.core.IsEqual) Test(org.junit.jupiter.api.Test)

Example 7 with Text

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

the class BytesOfTest method asBytesFromIterator.

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

Example 8 with Text

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

the class SplitTest method splitTextWithStringRegexAndLimit.

@Test
void splitTextWithStringRegexAndLimit() throws Exception {
    final Text txt = new TextOf("Cact!4Primitives");
    new Assertion<>("Must split text with string regex and limit", new Split(txt, "4", 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 9 with Text

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

the class ComparableTextTest method equalsOfDifferentText.

@Test
public void equalsOfDifferentText() {
    final Text text = new ComparableText(new TextOf("my value"));
    new Assertion<>("Is equal to the completely different object", text, new IsNot<>(new IsEqual<>("The string is ignored"))).affirm();
    new Assertion<>("Is equal to the completely different text", text, new IsNot<>(new IsText("The text is ignored"))).affirm();
    new Assertion<>("Is equal to the different ComparableText", text, new IsNot<>(new IsEqual<>(new ComparableText(new TextOf("A different text"))))).affirm();
    new Assertion<>("The string is equal to the different ComparableText", text, new IsNot<>(new IsText(new ComparableText(new TextOf("A different value"))))).affirm();
}
Also used : IsNot(org.hamcrest.core.IsNot) IsText(org.llorllale.cactoos.matchers.IsText) Text(org.cactoos.Text) IsText(org.llorllale.cactoos.matchers.IsText) Test(org.junit.Test)

Example 10 with Text

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

the class LoggingInputTest method logReadFromLargeTextFile.

@Test
@SuppressWarnings("unchecked")
void logReadFromLargeTextFile() throws Exception {
    final Logger logger = new FakeLogger();
    new LengthOf(new LoggingInput(new ResourceOf("org/cactoos/large-text.txt"), "text file", logger)).value();
    new Assertion<>("Must log 74536 bytes read from text file", new TextOf(logger.toString()), new AllOf<>(new IsNot<Text>(new HasString("Read 16384 byte(s) from text file")), new HasString("Read 74536 byte(s) from text file in"), new HasString("Closed input stream from text file"))).affirm();
}
Also used : HasString(org.llorllale.cactoos.matchers.HasString) LengthOf(org.cactoos.scalar.LengthOf) TextOf(org.cactoos.text.TextOf) Text(org.cactoos.Text) Logger(java.util.logging.Logger) AllOf(org.hamcrest.core.AllOf) 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