aboutsummaryrefslogtreecommitdiff
path: root/core/src/test/kotlin/ca/allanwang/kau/kotlin/StreamsTest.kt
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2017-08-05 14:49:47 -0700
committerGitHub <noreply@github.com>2017-08-05 14:49:47 -0700
commitc707d42b311f96cbabc1971f98598c8b8922ba16 (patch)
tree3c592c2a8bdd2fb759e3632adf038b5d7cecfabb /core/src/test/kotlin/ca/allanwang/kau/kotlin/StreamsTest.kt
parentbafc1996d803862d30a2c7d0c402d30c79c4f647 (diff)
downloadkau-c707d42b311f96cbabc1971f98598c8b8922ba16.tar.gz
kau-c707d42b311f96cbabc1971f98598c8b8922ba16.tar.bz2
kau-c707d42b311f96cbabc1971f98598c8b8922ba16.zip
Swipe (#24)
* Test emulator * Update readme * Update fastadapter and about listing * Make faq parser asynchronous * Modularize about panels * Add basis for faq * Test and finalize the faq panel * Update readme * Update changelog * Remove emulator for now * Update sample * Change back to manual versioning to avoid suggestion errors * Add awesome-kt banner * Fix faq background color * Fix merge conflicts 2 * Add waffle badge * Update readme * Fix lint * Create FileUtils and NotificationUtils * Remove frost hardcode * Fix simple date * Update swipe to use weak references * Initializing test dependencies * Update to gradle 4.1 * Fix lint warnings * Drop back down and fix errors * Finalize swipe with example * Finalize weak reference and ordering * Update test code * Make loggers inline
Diffstat (limited to 'core/src/test/kotlin/ca/allanwang/kau/kotlin/StreamsTest.kt')
-rw-r--r--core/src/test/kotlin/ca/allanwang/kau/kotlin/StreamsTest.kt42
1 files changed, 42 insertions, 0 deletions
diff --git a/core/src/test/kotlin/ca/allanwang/kau/kotlin/StreamsTest.kt b/core/src/test/kotlin/ca/allanwang/kau/kotlin/StreamsTest.kt
new file mode 100644
index 0000000..1c40f57
--- /dev/null
+++ b/core/src/test/kotlin/ca/allanwang/kau/kotlin/StreamsTest.kt
@@ -0,0 +1,42 @@
+package ca.allanwang.kau.kotlin
+
+import org.junit.Test
+import kotlin.test.assertEquals
+
+/**
+ * Created by Allan Wang on 2017-08-05.
+ *
+ * Test code for [kauRemoveIf]
+ */
+class StreamsTest {
+
+ @Test
+ fun basic() {
+ val items = mutableListOf(0, 1, 2, 3, 4, 5, 6, 7, 8, 9)
+ items.kauRemoveIf { it % 2 == 0 }
+ assertEquals(listOf(1, 3, 5, 7, 9), items)
+ }
+
+ @Test
+ fun objectReference() {
+ data class Potato(val id: Int)
+
+ val thePotato = Potato(9)
+ val items = mutableListOf<Potato>()
+ val result = mutableListOf<Potato>()
+ for (i in 0..11) {
+ val potato = Potato(i)
+ items.add(potato)
+ result.add(potato)
+ }
+ items.add(3, thePotato)
+ assertEquals(result.size + 1, items.size, "Invalid list addition")
+ assertEquals(2, items.filter { it.id == 9 }.size, "Invalid number of potatoes with id 9")
+ items.kauRemoveIf { it === thePotato } //removal by reference
+ assertEquals(result.size, items.size, "Invalid list size after removal")
+ assertEquals(result, items)
+ items.kauRemoveIf { it == thePotato } //removal by equality
+ assertEquals(result.size - 1, items.size, "Invalid list removal based on equality")
+ }
+
+} \ No newline at end of file