use of org.cactoos.text.TextOf in project cactoos by yegor256.
the class BytesOfTest method readsFromReader.
@Test
void readsFromReader() throws Exception {
final String source = "hello, друг!";
new Assertion<>("must read string through a reader", new TextOf(new Sticky(new InputOf(new BytesOf(new StringReader(source), StandardCharsets.UTF_8, // @checkstyle MagicNumberCheck (1 line)
16 << 10)))), new IsText(source)).affirm();
}
use of org.cactoos.text.TextOf 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();
}
use of org.cactoos.text.TextOf in project cactoos by yegor256.
the class TeeInputFromTextTest method copiesFromTextWithCharsetToOutput.
@Test
public void copiesFromTextWithCharsetToOutput() throws Exception {
final String input = "Hello, товарищ output #2 äÄ üÜ öÖ and ß";
final File output = this.folder.newFile();
new LengthOf(new TeeInput(new TextOf(input), new OutputTo(output), StandardCharsets.UTF_8)).value();
new Assertion<>("text must be copied to the output with UTF_8 charset", new InputOf(output), new HasContent(input)).affirm();
}
use of org.cactoos.text.TextOf in project cactoos by yegor256.
the class TeeInputFromTextTest method copiesFromTextToOutput.
@Test
public void copiesFromTextToOutput() throws Exception {
final String input = "Hello, товарищ output #1 äÄ üÜ öÖ and ß";
final File output = this.folder.newFile();
new LengthOf(new TeeInput(new TextOf(input), new OutputTo(output))).value();
new Assertion<>("text must be copied to the output", new InputOf(output), new HasContent(input)).affirm();
}
use of org.cactoos.text.TextOf in project cactoos by yegor256.
the class TeeInputFromTextTest method copiesFromTextWithCharsetByNameToOutput.
@Test
public void copiesFromTextWithCharsetByNameToOutput() throws Exception {
final String input = "Hello, товарищ output #3 äÄ üÜ öÖ and ß";
final File output = this.folder.newFile();
new LengthOf(new TeeInput(new TextOf(input), new OutputTo(output), StandardCharsets.UTF_8.name())).value();
new Assertion<>("text must be copied to the output with UTF_8 charset's name", new InputOf(output), new HasContent(input)).affirm();
}
Aggregations