🎨 Replace reply comparator with Kotlin version
[Sone.git] / src / test / kotlin / net / pterodactylus / sone / data / ReplyTest.kt
1 /**
2  * Sone - ReplyTest.kt - Copyright Â© 2020 David â€˜Bombe’ Roden
3  *
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.
8  *
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.
13  *
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/>.
16  */
17
18 package net.pterodactylus.sone.data
19
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
26
27 class ReplyTest {
28
29         @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))
34         }
35
36         @Test
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))
41         }
42
43         @Test
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))
48         }
49
50 }