Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert parameterized test enums to CamelCase #584

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ class CachedPageEventFlowTest {
private val testScope = TestScope(UnconfinedTestDispatcher())

@Test
fun slowFastCollectors_CLOSE_UPSTREAM() = slowFastCollectors(TerminationType.CLOSE_UPSTREAM)
fun slowFastCollectors_CloseUpstream() = slowFastCollectors(TerminationType.CloseUpstream)

@Test
fun slowFastCollectors_CLOSE_CACHED_EVENT_FLOW() =
slowFastCollectors(TerminationType.CLOSE_CACHED_EVENT_FLOW)
fun slowFastCollectors_CloseCachedEventFlow() =
slowFastCollectors(TerminationType.CloseCachedEventFlow)

private fun slowFastCollectors(terminationType: TerminationType) = testScope.runTest {
val upstream = Channel<PageEvent<String>>(Channel.UNLIMITED)
Expand Down Expand Up @@ -115,8 +115,8 @@ class CachedPageEventFlowTest {
)
upstream.send(finalAppendEvent)
when (terminationType) {
TerminationType.CLOSE_UPSTREAM -> upstream.close()
TerminationType.CLOSE_CACHED_EVENT_FLOW -> subject.close()
TerminationType.CloseUpstream -> upstream.close()
TerminationType.CloseCachedEventFlow -> subject.close()
}
val fullList = listOf(
refreshEvent,
Expand Down Expand Up @@ -145,11 +145,11 @@ class CachedPageEventFlowTest {
}

@Test
fun ensureSharing_CLOSE_UPSTREAM() = ensureSharing(TerminationType.CLOSE_UPSTREAM)
fun ensureSharing_CloseUpstream() = ensureSharing(TerminationType.CloseUpstream)

@Test
fun ensureSharing_CLOSE_CACHED_EVENT_FLOW() =
ensureSharing(TerminationType.CLOSE_CACHED_EVENT_FLOW)
fun ensureSharing_CloseCachedEventFlow() =
ensureSharing(TerminationType.CloseCachedEventFlow)

private fun ensureSharing(terminationType: TerminationType) = testScope.runTest {
val refreshEvent = localRefresh(
Expand Down Expand Up @@ -236,8 +236,8 @@ class CachedPageEventFlowTest {
assertThat(collector2.isActive()).isTrue()
assertThat(collector3.isActive()).isTrue()
when (terminationType) {
TerminationType.CLOSE_UPSTREAM -> upstream.close()
TerminationType.CLOSE_CACHED_EVENT_FLOW -> subject.close()
TerminationType.CloseUpstream -> upstream.close()
TerminationType.CloseCachedEventFlow -> subject.close()
}
runCurrent()
assertThat(collector1.isActive()).isFalse()
Expand Down Expand Up @@ -352,7 +352,7 @@ class CachedPageEventFlowTest {
}

enum class TerminationType {
CLOSE_UPSTREAM,
CLOSE_CACHED_EVENT_FLOW
CloseUpstream,
CloseCachedEventFlow,
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ class SimpleChannelFlowTest {
val testScope = TestScope(UnconfinedTestDispatcher())

@Test
fun basic_CHANNEL_FLOW() = basic(Impl.CHANNEL_FLOW)
fun basic_ChannelFlow() = basic(Impl.ChannelFlow)

@Test
fun basic_SIMPLE_CHANNEL_FLOW() = basic(Impl.SIMPLE_CHANNEL_FLOW)
fun basic_SimpleChannelFlow() = basic(Impl.SimpleChannelFlow)

private fun basic(impl: Impl) {
val channelFlow = createFlow<Int>(impl) {
Expand All @@ -65,10 +65,10 @@ class SimpleChannelFlowTest {
}

@Test
fun emitWithLaunch_CHANNEL_FLOW() = emitWithLaunch(Impl.CHANNEL_FLOW)
fun emitWithLaunch_ChannelFlow() = emitWithLaunch(Impl.ChannelFlow)

@Test
fun emitWithLaunch_SIMPLE_CHANNEL_FLOW() = emitWithLaunch(Impl.SIMPLE_CHANNEL_FLOW)
fun emitWithLaunch_SimpleChannelFlow() = emitWithLaunch(Impl.SimpleChannelFlow)

private fun emitWithLaunch(impl: Impl) {
val channelFlow = createFlow<Int>(impl) {
Expand All @@ -86,10 +86,10 @@ class SimpleChannelFlowTest {
}

@Test
fun closedByCollector_CHANNEL_FLOW() = closedByCollector(Impl.CHANNEL_FLOW)
fun closedByCollector_ChannelFlow() = closedByCollector(Impl.ChannelFlow)

@Test
fun closedByCollector_SIMPLE_CHANNEL_FLOW() = closedByCollector(Impl.SIMPLE_CHANNEL_FLOW)
fun closedByCollector_SimpleChannelFlow() = closedByCollector(Impl.SimpleChannelFlow)

private fun closedByCollector(impl: Impl) {
val emittedValues = mutableListOf<Int>()
Expand All @@ -106,11 +106,11 @@ class SimpleChannelFlowTest {
}

@Test
fun closedByCollector_noBuffer_CHANNEL_FLOW() = closedByCollector_noBuffer(Impl.CHANNEL_FLOW)
fun closedByCollector_noBuffer_ChannelFlow() = closedByCollector_noBuffer(Impl.ChannelFlow)

@Test
fun closedByCollector_noBuffer_SIMPLE_CHANNEL_FLOW() =
closedByCollector_noBuffer(Impl.SIMPLE_CHANNEL_FLOW)
fun closedByCollector_noBuffer_SimpleChannelFlow() =
closedByCollector_noBuffer(Impl.SimpleChannelFlow)

private fun closedByCollector_noBuffer(impl: Impl) {
val emittedValues = mutableListOf<Int>()
Expand All @@ -123,7 +123,7 @@ class SimpleChannelFlowTest {
testScope.runTest {
assertThat(channelFlow.buffer(0).take(4).toList()).containsExactly(0, 1, 2, 3)
when (impl) {
Impl.CHANNEL_FLOW -> {
Impl.ChannelFlow -> {
assertThat(emittedValues).containsExactly(0, 1, 2, 3)
}
else -> {
Expand All @@ -135,10 +135,10 @@ class SimpleChannelFlowTest {
}

@Test
fun awaitClose_CHANNEL_FLOW() = awaitClose(Impl.CHANNEL_FLOW)
fun awaitClose_ChannelFlow() = awaitClose(Impl.ChannelFlow)

@Test
fun awaitClose_SIMPLE_CHANNEL_FLOW() = awaitClose(Impl.SIMPLE_CHANNEL_FLOW)
fun awaitClose_SimpleChannelFlow() = awaitClose(Impl.SimpleChannelFlow)

private fun awaitClose(impl: Impl) {
val lastDispatched = CompletableDeferred<Int>()
Expand All @@ -163,10 +163,10 @@ class SimpleChannelFlowTest {
}

@Test
fun scopeGetsCancelled_CHANNEL_FLOW() = scopeGetsCancelled(Impl.CHANNEL_FLOW)
fun scopeGetsCancelled_ChannelFlow() = scopeGetsCancelled(Impl.ChannelFlow)

@Test
fun scopeGetsCancelled_SIMPLE_CHANNEL_FLOW() = scopeGetsCancelled(Impl.SIMPLE_CHANNEL_FLOW)
fun scopeGetsCancelled_SimpleChannelFlow() = scopeGetsCancelled(Impl.SimpleChannelFlow)

private fun scopeGetsCancelled(impl: Impl) {
var producerException: Throwable? = null
Expand Down Expand Up @@ -197,10 +197,10 @@ class SimpleChannelFlowTest {
}

@Test
fun collectorThrows_CHANNEL_FLOW() = collectorThrows(Impl.CHANNEL_FLOW)
fun collectorThrows_ChannelFlow() = collectorThrows(Impl.ChannelFlow)

@Test
fun collectorThrows_SIMPLE_CHANNEL_FLOW() = collectorThrows(Impl.SIMPLE_CHANNEL_FLOW)
fun collectorThrows_SimpleChannelFlow() = collectorThrows(Impl.SimpleChannelFlow)

private fun collectorThrows(impl: Impl) {
var producerException: Throwable? = null
Expand All @@ -226,10 +226,10 @@ class SimpleChannelFlowTest {
}

@Test
fun upstreamThrows_CHANNEL_FLOW() = upstreamThrows(Impl.CHANNEL_FLOW)
fun upstreamThrows_ChannelFlow() = upstreamThrows(Impl.ChannelFlow)

@Test
fun upstreamThrows_SIMPLE_CHANNEL_FLOW() = upstreamThrows(Impl.SIMPLE_CHANNEL_FLOW)
fun upstreamThrows_SimpleChannelFlow() = upstreamThrows(Impl.SimpleChannelFlow)

private fun upstreamThrows(impl: Impl) {
var producerException: Throwable? = null
Expand Down Expand Up @@ -264,12 +264,12 @@ class SimpleChannelFlowTest {
}

@Test
fun cancelingChannelClosesTheFlow_CHANNEL_FLOW() =
cancelingChannelClosesTheFlow(Impl.CHANNEL_FLOW)
fun cancelingChannelClosesTheFlow_ChannelFlow() =
cancelingChannelClosesTheFlow(Impl.ChannelFlow)

@Test
fun cancelingChannelClosesTheFlow_SIMPLE_CHANNEL_FLOW() =
cancelingChannelClosesTheFlow(Impl.SIMPLE_CHANNEL_FLOW)
fun cancelingChannelClosesTheFlow_SimpleChannelFlow() =
cancelingChannelClosesTheFlow(Impl.SimpleChannelFlow)

private fun cancelingChannelClosesTheFlow(impl: Impl) {
val flow = createFlow<Int>(impl) {
Expand All @@ -287,10 +287,10 @@ class SimpleChannelFlowTest {
block: suspend TestProducerScope<T>.() -> Unit
): Flow<T> {
return when (impl) {
Impl.CHANNEL_FLOW -> channelFlow {
Impl.ChannelFlow -> channelFlow {
ChannelFlowTestProducerScope(this).block()
}
Impl.SIMPLE_CHANNEL_FLOW -> simpleChannelFlow {
Impl.SimpleChannelFlow -> simpleChannelFlow {
SimpleChannelFlowTestProducerScope(this).block()
}
}
Expand Down Expand Up @@ -319,7 +319,7 @@ class SimpleChannelFlowTest {
}

enum class Impl {
CHANNEL_FLOW,
SIMPLE_CHANNEL_FLOW
ChannelFlow,
SimpleChannelFlow,
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ class SimpleTransformLatestTest {
private val testScope = TestScope()

@Test
fun delayed_TRANSFORM_LATEST() = delayed(Impl.TRANSFORM_LATEST)
fun delayed_TransformLatest() = delayed(Impl.TransformLatest)

@Test
fun delayed_SIMPLE_TRANSFORM_LATEST() = delayed(Impl.SIMPLE_TRANSFORM_LATEST)
fun delayed_SimpleTransformLatest() = delayed(Impl.SimpleTransformLatest)

private fun delayed(impl: Impl) = testScope.runTest {
assertThat(
Expand All @@ -58,10 +58,10 @@ class SimpleTransformLatestTest {
}

@Test
fun allValues_TRANSFORM_LATEST() = allValues(Impl.TRANSFORM_LATEST)
fun allValues_TransformLatest() = allValues(Impl.TransformLatest)

@Test
fun allValues_SIMPLE_TRANSFORM_LATEST() = allValues(Impl.SIMPLE_TRANSFORM_LATEST)
fun allValues_SimpleTransformLatest() = allValues(Impl.SimpleTransformLatest)

private fun allValues(impl: Impl) = testScope.runTest {
assertThat(
Expand All @@ -78,11 +78,11 @@ class SimpleTransformLatestTest {
}

@Test
fun reusePreviousCollector_TRANSFORM_LATEST() = reusePreviousCollector(Impl.TRANSFORM_LATEST)
fun reusePreviousCollector_TransformLatest() = reusePreviousCollector(Impl.TransformLatest)

@Test
fun reusePreviousCollector_SIMPLE_TRANSFORM_LATEST() =
reusePreviousCollector(Impl.SIMPLE_TRANSFORM_LATEST)
fun reusePreviousCollector_SimpleTransformLatest() =
reusePreviousCollector(Impl.SimpleTransformLatest)

private fun reusePreviousCollector(impl: Impl) = testScope.runTest {
var prevCollector: FlowCollector<String>? = null
Expand All @@ -105,15 +105,15 @@ class SimpleTransformLatestTest {
transform: suspend FlowCollector<R>.(value: T) -> Unit
): Flow<R> {
return when (impl) {
Impl.TRANSFORM_LATEST ->
Impl.TransformLatest ->
this@testTransformLatest.transformLatest(transform)
Impl.SIMPLE_TRANSFORM_LATEST ->
Impl.SimpleTransformLatest ->
this@testTransformLatest.simpleTransformLatest(transform)
}
}

enum class Impl {
TRANSFORM_LATEST,
SIMPLE_TRANSFORM_LATEST
TransformLatest,
SimpleTransformLatest,
}
}
Loading