X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Ftest%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Ffreenet%2Fwot%2FTrustTest.java;h=93eebb8a35e9f80286f6898717c0cde667608ad7;hb=44dd5eaf89e1c6516e380b9c7f4c490d2816ffd5;hp=dfc25431be86f0d302e7972c3a042016d6c1a7f7;hpb=39efbde874d5caa9c12857cd76970b9cbcc17161;p=Sone.git diff --git a/src/test/java/net/pterodactylus/sone/freenet/wot/TrustTest.java b/src/test/java/net/pterodactylus/sone/freenet/wot/TrustTest.java index dfc2543..93eebb8 100644 --- a/src/test/java/net/pterodactylus/sone/freenet/wot/TrustTest.java +++ b/src/test/java/net/pterodactylus/sone/freenet/wot/TrustTest.java @@ -17,10 +17,15 @@ package net.pterodactylus.sone.freenet.wot; +import static java.util.regex.Pattern.compile; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.not; import static org.hamcrest.Matchers.nullValue; +import org.hamcrest.Description; +import org.hamcrest.Matcher; +import org.hamcrest.TypeSafeMatcher; import org.junit.Test; /** @@ -54,4 +59,32 @@ public class TrustTest { assertThat(trust1.hashCode(), is(trust2.hashCode())); } + @Test + public void nullDoesNotMatchTrust() { + Trust trust = new Trust(5, 17, 2); + assertThat(trust, not(is((Object) null))); + } + + @Test + public void toStringContainsTheThreeValues() { + String trustString = new Trust(5, 17, 2).toString(); + assertThat(trustString, matches("\\b5\\b")); + assertThat(trustString, matches("\\b17\\b")); + assertThat(trustString, matches("\\b2\\b")); + } + + private static Matcher matches(final String regex) { + return new TypeSafeMatcher() { + @Override + protected boolean matchesSafely(String item) { + return compile(regex).matcher(item).find(); + } + + @Override + public void describeTo(Description description) { + description.appendText("matches: ").appendValue(regex); + } + }; + } + }