-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
153 additions
and
131 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
kmock-processor/src/test/kotlin/tech/antibytes/kmock/fixture/StringAlphaGenerator.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Copyright (c) 2022 Matthias Geisler (bitPogo) / All rights reserved. | ||
* | ||
* Use of this source code is governed by Apache v2.0 | ||
*/ | ||
|
||
package tech.antibytes.kmock.fixture | ||
|
||
import co.touchlab.stately.isolate.IsolateState | ||
import tech.antibytes.util.test.fixture.PublicApi | ||
import kotlin.random.Random | ||
|
||
internal class StringAlphaGenerator( | ||
val random: IsolateState<Random> | ||
) : PublicApi.Generator<String> { | ||
override fun generate(): String { | ||
val length = random.access { it.nextInt(1, 10) } | ||
val chars = ByteArray(length) | ||
|
||
for (idx in 0 until length) { | ||
val char = random.access { it.nextInt(65, 91) } | ||
chars[idx] = if (random.access { it.nextBoolean() }) { | ||
(char + 32).toByte() | ||
} else { | ||
char.toByte() | ||
} | ||
} | ||
|
||
return chars.decodeToString() | ||
} | ||
|
||
companion object : PublicApi.GeneratorFactory<String> { | ||
override fun getInstance(random: IsolateState<Random>): PublicApi.Generator<String> { | ||
return StringAlphaGenerator(random) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.