From 1d7e3aae6a6a885a7492eb445988a5437c63cb0d Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Wed, 5 Oct 2016 19:15:13 +0200 Subject: [PATCH] Add test for FreenetLinkPart --- .../sone/text/FreenetLinkPartTest.java | 42 ++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 src/test/java/net/pterodactylus/sone/text/FreenetLinkPartTest.java diff --git a/src/test/java/net/pterodactylus/sone/text/FreenetLinkPartTest.java b/src/test/java/net/pterodactylus/sone/text/FreenetLinkPartTest.java new file mode 100644 index 0000000..57284bf --- /dev/null +++ b/src/test/java/net/pterodactylus/sone/text/FreenetLinkPartTest.java @@ -0,0 +1,42 @@ +package net.pterodactylus.sone.text; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; + +import org.junit.Test; + +/** + * Unit test for {@link FreenetLinkPart}. + * + * @author David ‘Bombe’ Roden + */ +public class FreenetLinkPartTest { + + private final FreenetLinkPart part = new FreenetLinkPart("link", "text", "title", true); + + @Test + public void linkIsRetainedCorrectly() { + assertThat(part.getLink(), is("link")); + } + + @Test + public void textIsRetainedCorrectly() { + assertThat(part.getText(), is("text")); + } + + @Test + public void titleIsRetainedCorrectly() { + assertThat(part.getTitle(), is("title")); + } + + @Test + public void trustedIsRetainedCorrectly() { + assertThat(part.isTrusted(), is(true)); + } + + @Test + public void textIsUsedAsTitleIfNoTextIsGiven() { + assertThat(new FreenetLinkPart("link", "text", true).getTitle(), is("text")); + } + +} -- 2.7.4