use of org.cactoos.text.TextOf in project cactoos by yegor256.
the class TeeInputHasResultTest method describesMismatchOfCopiedAndExpected.
@Test
public void describesMismatchOfCopiedAndExpected() {
final TeeInput matchable = new TeeInput(new TextOf("i"), new OutputTo(new ByteArrayOutputStream()));
final TeeInputHasResult matcher = new TeeInputHasResult("i", new TextOf("wrong"));
final StringDescription description = new StringDescription();
matcher.matchesSafely(matchable);
matcher.describeMismatchSafely(matchable, description);
MatcherAssert.assertThat("Description of mismatch of copied and expected incorrect", description.toString(), new IsEqual<>("TeeInput with result \"i\" and copied value \"i\""));
}
use of org.cactoos.text.TextOf in project cactoos by yegor256.
the class HeadInputStreamTest method testSkippingMoreThanTotal.
@Test
void testSkippingMoreThanTotal() throws Exception {
final HeadInputStream stream = new HeadInputStream(new InputOf("testSkippingMoreThanTotal").stream(), 5);
final long skipped = stream.skip(7L);
new Assertion<>("Incorrect number of bytes skipped", skipped, new IsEqual<>(5L)).affirm();
final String input = new TextOf(stream).asString();
new Assertion<>("The result text wasn't empty", new TextOf(input), new IsText("")).affirm();
}
use of org.cactoos.text.TextOf in project cactoos by yegor256.
the class InputStreamOfTest method readsFromTextWithCharset.
@Test
public void readsFromTextWithCharset() throws Exception {
final File file = this.folder.newFile("readTextWithCharset.txt-5");
final String content = "Content for reading text with charset";
new LengthOf(new TeeInput(content, file)).value();
new Assertion<>("Must read from text with charset", new TextOf(new InputStreamOf(new TextOf(file), StandardCharsets.UTF_8.name())), new IsText(content)).affirm();
}
use of org.cactoos.text.TextOf in project cactoos by yegor256.
the class InputStreamOfTest method readsFromUri.
@Test
public void readsFromUri() throws Exception {
final String content = "Content for reading through URI";
final File file = this.folder.newFile("readFromUri.txt-3");
new LengthOf(new TeeInput(content, file)).value();
new Assertion<>("Must read from URI", new TextOf(new InputStreamOf(file.toURI())), new IsText(content)).affirm();
}
use of org.cactoos.text.TextOf in project cactoos by yegor256.
the class HeadOfTest method readsHeadOfShorterInput.
@Test
void readsHeadOfShorterInput() throws Exception {
final String input = "readsHeadOfShorterInput";
new Assertion<>("must limit to at most the number of available bytes", new TextOf(new HeadOf(new InputOf(input), 35)), new HasString(input)).affirm();
}
Aggregations