2 * Sone - ReplyTest.kt - Copyright © 2020 David ‘Bombe’ Roden
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 package net.pterodactylus.sone.data
20 import net.pterodactylus.sone.test.emptyPostReply
21 import org.hamcrest.MatcherAssert.assertThat
22 import org.hamcrest.Matchers.equalTo
23 import org.hamcrest.Matchers.greaterThan
24 import org.hamcrest.Matchers.lessThan
25 import kotlin.test.Test
30 fun `newestReplyFirst comparator returns less-than 0 is first reply is newer than second`() {
31 val newerReply = emptyPostReply(time = 2000)
32 val olderReply = emptyPostReply(time = 1000)
33 assertThat(newestReplyFirst.compare(newerReply, olderReply), lessThan(0))
37 fun `newestReplyFirst comparator returns greater-than 0 is first reply is older than second`() {
38 val newerReply = emptyPostReply(time = 2000)
39 val olderReply = emptyPostReply(time = 1000)
40 assertThat(newestReplyFirst.compare(olderReply, newerReply), greaterThan(0))
44 fun `newestReplyFirst comparator returns 0 is first and second reply have same age`() {
45 val reply1 = emptyPostReply(time = 1000)
46 val reply2 = emptyPostReply(time = 1000)
47 assertThat(newestReplyFirst.compare(reply1, reply2), equalTo(0))