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();
}
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();
}
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();
}
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();
}
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();
}
Aggregations