🔀 Merge branch 'release/v82'
[Sone.git] / src / test / kotlin / net / pterodactylus / sone / template / UniqueElementFilterTest.kt
1 package net.pterodactylus.sone.template
2
3 import org.hamcrest.MatcherAssert.assertThat
4 import org.hamcrest.Matchers.equalTo
5 import org.junit.Test
6
7 /**
8  * Unit test for [UniqueElementFilter].
9  */
10 class UniqueElementFilterTest {
11
12         private val filter = UniqueElementFilter()
13
14         @Test
15         fun `filter returns object if object is not a collection`() {
16                 val someObject = Any()
17                 assertThat(filter.format(null, someObject, null), equalTo<Any>(someObject))
18         }
19
20         @Test
21         fun `filter returns a set containing all unique elements of a given collection`() {
22                 val objects = listOf(Any(), Any(), Any())
23                 val collection = listOf(objects[0], objects[1], objects[2], objects[0], objects[1])
24                 assertThat(filter.format(null, collection, null), equalTo<Any>(objects.toSet()))
25         }
26
27 }