X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Ftest%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Fdata%2FReplyTest.kt;h=38b10770cef5398096a6906d69d94527297bd4c1;hb=067e4e19aad56f0c6de0d536f5de0bdefcf41b87;hp=3289b7d9c690c1a18732a276c2f067d54b1b97c8;hpb=f049280a40ddf05f02400e7f0d93a24dea4545c2;p=Sone.git diff --git a/src/test/kotlin/net/pterodactylus/sone/data/ReplyTest.kt b/src/test/kotlin/net/pterodactylus/sone/data/ReplyTest.kt index 3289b7d..38b1077 100644 --- a/src/test/kotlin/net/pterodactylus/sone/data/ReplyTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/data/ReplyTest.kt @@ -17,34 +17,47 @@ package net.pterodactylus.sone.data -import net.pterodactylus.sone.test.emptyPostReply +import net.pterodactylus.sone.test.createPostReply import org.hamcrest.MatcherAssert.assertThat import org.hamcrest.Matchers.equalTo import org.hamcrest.Matchers.greaterThan import org.hamcrest.Matchers.lessThan +import java.util.concurrent.TimeUnit.DAYS import kotlin.test.Test class ReplyTest { @Test fun `newestReplyFirst comparator returns less-than 0 is first reply is newer than second`() { - val newerReply = emptyPostReply(time = 2000) - val olderReply = emptyPostReply(time = 1000) + val newerReply = createPostReply(time = 2000) + val olderReply = createPostReply(time = 1000) assertThat(newestReplyFirst.compare(newerReply, olderReply), lessThan(0)) } @Test fun `newestReplyFirst comparator returns greater-than 0 is first reply is older than second`() { - val newerReply = emptyPostReply(time = 2000) - val olderReply = emptyPostReply(time = 1000) + val newerReply = createPostReply(time = 2000) + val olderReply = createPostReply(time = 1000) assertThat(newestReplyFirst.compare(olderReply, newerReply), greaterThan(0)) } @Test fun `newestReplyFirst comparator returns 0 is first and second reply have same age`() { - val reply1 = emptyPostReply(time = 1000) - val reply2 = emptyPostReply(time = 1000) + val reply1 = createPostReply(time = 1000) + val reply2 = createPostReply(time = 1000) assertThat(newestReplyFirst.compare(reply1, reply2), equalTo(0)) } + @Test + fun `noFutureReply filter recognizes reply from the future`() { + val futureReply = createPostReply(time = System.currentTimeMillis() + DAYS.toMillis(1)) + assertThat(noFutureReply(futureReply), equalTo(false)) + } + + @Test + fun `noFutureReply filter recognizes reply from the present`() { + val futureReply = createPostReply(time = System.currentTimeMillis()) + assertThat(noFutureReply(futureReply), equalTo(true)) + } + }