aboutsummaryrefslogtreecommitdiff
path: root/core/src/test/kotlin
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
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')
-rw-r--r--core/src/test/kotlin/ca/allanwang/kau/kotlin/LazyResettableTest.kt2
-rw-r--r--core/src/test/kotlin/ca/allanwang/kau/kotlin/StreamsTest.kt42
-rw-r--r--core/src/test/kotlin/ca/allanwang/kau/utils/UtilsTest.kt2
3 files changed, 46 insertions, 0 deletions
diff --git a/core/src/test/kotlin/ca/allanwang/kau/kotlin/LazyResettableTest.kt b/core/src/test/kotlin/ca/allanwang/kau/kotlin/LazyResettableTest.kt
index 1997bd1..2025422 100644
--- a/core/src/test/kotlin/ca/allanwang/kau/kotlin/LazyResettableTest.kt
+++ b/core/src/test/kotlin/ca/allanwang/kau/kotlin/LazyResettableTest.kt
@@ -7,6 +7,8 @@ import kotlin.test.assertNotEquals
/**
* Created by Allan Wang on 2017-07-29.
+ *
+ * Test code for [LazyResettable]
*/
class LazyResettableTest {
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
diff --git a/core/src/test/kotlin/ca/allanwang/kau/utils/UtilsTest.kt b/core/src/test/kotlin/ca/allanwang/kau/utils/UtilsTest.kt
index 071ee9c..ce2b757 100644
--- a/core/src/test/kotlin/ca/allanwang/kau/utils/UtilsTest.kt
+++ b/core/src/test/kotlin/ca/allanwang/kau/utils/UtilsTest.kt
@@ -6,6 +6,8 @@ import kotlin.test.assertEquals
/**
* Created by Allan Wang on 2017-06-23.
+ *
+ * Misc test code
*/
class UtilsTest {