use of org.cactoos.text.TextOf in project cactoos by yegor256.
the class TeeInputFromTextTest method copiesFromTextWithCharsetToPath.
@Test
public void copiesFromTextWithCharsetToPath() throws Exception {
final String input = "Hello, товарищ path #2 äÄ üÜ öÖ and ß";
final File output = this.folder.newFile();
new LengthOf(new TeeInput(new TextOf(input), output.toPath(), StandardCharsets.UTF_8)).value();
new Assertion<>("text must be copied to the path with UTF_8 charset", new InputOf(output), new HasContent(input)).affirm();
}
use of org.cactoos.text.TextOf in project cactoos by yegor256.
the class BytesOfTest method readsFromReader.
@Test
public void readsFromReader() throws IOException {
final String source = "hello, друг!";
MatcherAssert.assertThat("Can't read string through a reader", new TextOf(new BytesOf(new StringReader(source), StandardCharsets.UTF_8, // @checkstyle MagicNumberCheck (1 line)
16 << 10)).asString(), Matchers.equalTo(source));
}
use of org.cactoos.text.TextOf in project cactoos by yegor256.
the class TeeInputHasResultTest method failsIfInputDoesNotMatchExpectedValue.
@Test
public void failsIfInputDoesNotMatchExpectedValue() {
final TeeInput matchable = new TeeInput(new TextOf("input"), new OutputTo(new ByteArrayOutputStream()));
final String expected = "expected-1";
final TeeInputHasResult matcher = new TeeInputHasResult(expected, new TextOf(expected));
MatcherAssert.assertThat("Matcher does not compare input and expected values", matcher.matchesSafely(matchable), new IsEqual<>(false));
}
use of org.cactoos.text.TextOf in project cactoos by yegor256.
the class TeeInputHasResultTest method failsIfCopiedValueDoesNotMatchExpectedValue.
@Test
public void failsIfCopiedValueDoesNotMatchExpectedValue() {
final String expected = "expected-2";
final TeeInput matchable = new TeeInput(new TextOf(expected), new OutputTo(new ByteArrayOutputStream()));
final TeeInputHasResult matcher = new TeeInputHasResult(expected, new TextOf("incorrect"));
MatcherAssert.assertThat("Matcher does not compare copied and expected values", matcher.matchesSafely(matchable), new IsEqual<>(false));
}
use of org.cactoos.text.TextOf in project cactoos by yegor256.
the class TeeInputHasResultTest method describesMismatchOfInputAndExpected.
@Test
public void describesMismatchOfInputAndExpected() {
final TeeInput matchable = new TeeInput(new TextOf("i"), new OutputTo(new ByteArrayOutputStream()));
final TeeInputHasResult matcher = new TeeInputHasResult("e", new TextOf("e"));
final StringDescription description = new StringDescription();
matcher.matchesSafely(matchable);
matcher.describeMismatchSafely(matchable, description);
MatcherAssert.assertThat("Description of mismatch of input and expected incorrect", description.toString(), new IsEqual<>("TeeInput with result \"e\" and copied value \"e\""));
}
Aggregations