use of org.cactoos.bytes.BytesOf in project cactoos by yegor256.
the class TeeInputFromBytesTest method copiesFromBytesToFile.
@Test
public void copiesFromBytesToFile() throws Exception {
final String message = "Hello, товарищ file äÄ üÜ öÖ and ß";
final File output = this.folder.newFile();
new LengthOf(new TeeInput(new BytesOf(message), output)).value();
new Assertion<>("Must copy bytes to file", new InputOf(output), new HasContent(message)).affirm();
}
use of org.cactoos.bytes.BytesOf in project cactoos by yegor256.
the class TeeInputFromBytesTest method copiesFromBytesToOutput.
@Test
public void copiesFromBytesToOutput() throws Exception {
final String message = "Hello, товарищ output äÄ üÜ öÖ and ß";
final File output = this.folder.newFile();
new LengthOf(new TeeInput(new BytesOf(message), new OutputTo(output))).value();
new Assertion<>("Must bytes to output", new InputOf(output), new HasContent(message)).affirm();
}
use of org.cactoos.bytes.BytesOf in project cactoos by yegor256.
the class InputOfTest method readsStringBuilder.
@Test
void readsStringBuilder() throws Exception {
final String starts = "Name it, ";
final String ends = "then it exists!";
new Assertion<>("must receive a string builder", new TextOf(new BytesOf(new InputOf(new StringBuilder(starts).append(ends)))), new AllOf<>(new StartsWith(starts), new EndsWith(ends))).affirm();
}
use of org.cactoos.bytes.BytesOf in project cactoos by yegor256.
the class InputOfTest method readsStringBuffer.
@Test
void readsStringBuffer() throws Exception {
final String starts = "The future ";
final String ends = "is now!";
new Assertion<>("must receive a string buffer", new TextOf(new BytesOf(new InputOf(new StringBuffer(starts).append(ends)))), new AllOf<>(new StartsWith(starts), new EndsWith(ends))).affirm();
}
use of org.cactoos.bytes.BytesOf in project cactoos by yegor256.
the class TailOfTest method tailsOnExactStreamAndBuffer.
@Test
public void tailsOnExactStreamAndBuffer() throws Exception {
final int size = 4;
final byte[] bytes = this.generate(size);
new Assertion<>("Can't tail exact stream and buffer", new BytesOf(new TailOf(new InputOf(new BytesOf(bytes)), size, size)).asBytes(), new IsEqual<>(bytes)).affirm();
}
Aggregations