From c707d42b311f96cbabc1971f98598c8b8922ba16 Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Sat, 5 Aug 2017 14:49:47 -0700 Subject: 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 --- .../ca/allanwang/kau/kotlin/LazyResettableTest.kt | 2 ++ .../kotlin/ca/allanwang/kau/kotlin/StreamsTest.kt | 42 ++++++++++++++++++++++ .../kotlin/ca/allanwang/kau/utils/UtilsTest.kt | 2 ++ 3 files changed, 46 insertions(+) create mode 100644 core/src/test/kotlin/ca/allanwang/kau/kotlin/StreamsTest.kt (limited to 'core/src/test/kotlin/ca') 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() + val result = mutableListOf() + 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 { -- cgit v1.2.3