|
|
@ -8,15 +8,15 @@ import kotlin.test.assertTrue |
|
|
|
|
|
|
|
|
|
|
|
class UniqueQueueTest { |
|
|
|
class UniqueQueueTest { |
|
|
|
@Test |
|
|
|
@Test |
|
|
|
fun testAddPoll() { |
|
|
|
fun testAddRemove() { |
|
|
|
val queue = UniqueQueue<String>() |
|
|
|
val queue = UniqueQueue<String>() |
|
|
|
assertTrue(queue.add("a")) |
|
|
|
assertTrue(queue.add("a")) |
|
|
|
assertTrue(queue.add("b")) |
|
|
|
assertTrue(queue.add("b")) |
|
|
|
assertFalse(queue.add("a")) |
|
|
|
assertFalse(queue.add("a")) |
|
|
|
|
|
|
|
|
|
|
|
assertEquals("a", queue.poll()) |
|
|
|
assertEquals("a", queue.removeFirstOrNull()) |
|
|
|
assertEquals("b", queue.poll()) |
|
|
|
assertEquals("b", queue.removeFirstOrNull()) |
|
|
|
assertNull(queue.poll()) |
|
|
|
assertNull(queue.removeFirstOrNull()) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
@ -24,9 +24,9 @@ class UniqueQueueTest { |
|
|
|
val queue = UniqueQueue<String>() |
|
|
|
val queue = UniqueQueue<String>() |
|
|
|
queue.addAll(listOf("a", "b", "a")) |
|
|
|
queue.addAll(listOf("a", "b", "a")) |
|
|
|
|
|
|
|
|
|
|
|
assertEquals("a", queue.poll()) |
|
|
|
assertEquals("a", queue.removeFirstOrNull()) |
|
|
|
assertEquals("b", queue.poll()) |
|
|
|
assertEquals("b", queue.removeFirstOrNull()) |
|
|
|
assertNull(queue.poll()) |
|
|
|
assertNull(queue.removeFirstOrNull()) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
@ -36,6 +36,6 @@ class UniqueQueueTest { |
|
|
|
|
|
|
|
|
|
|
|
queue.clear() |
|
|
|
queue.clear() |
|
|
|
|
|
|
|
|
|
|
|
assertNull(queue.poll()) |
|
|
|
assertNull(queue.removeFirstOrNull()) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|