Best Kotest code snippet using io.kotest.property.arbitrary.locale.Arb.Companion.locale
CustomGen.kt
Source:CustomGen.kt
1package com.thejuki.kformmaster2import android.R3import android.widget.ArrayAdapter4import com.thejuki.kformmaster.helper.FormLayouts5import com.thejuki.kformmaster.model.*6import io.kotest.property.Arb7import io.kotest.property.arbitrary.*8import io.mockk.mockk9import org.threeten.bp.ZoneId10import org.threeten.bp.format.DateTimeFormatter11import java.text.SimpleDateFormat12import java.util.*13/**14 * Custom Gen15 *16 * Custom Generators for the Great Form Unit Tests17 *18 * @author **TheJuki** ([GitHub](https://github.com/TheJuki))19 * @version 1.020 */21interface CustomGen {22 companion object {23 /**24 * Generates a FormLayouts object25 */26 val formLayouts = arbitrary {27 FormLayouts(28 Arb.int(-100, 100).next() // header29 , Arb.int(-100, 100).next() // text30 , Arb.int(-100, 100).next() // textArea31 , Arb.int(-100, 100).next() // number32 , Arb.int(-100, 100).next() // email33 , Arb.int(-100, 100).next() // password34 , Arb.int(-100, 100).next() // phone35 , Arb.int(-100, 100).next() // autoComplete36 , Arb.int(-100, 100).next() // autoCompleteToken37 , Arb.int(-100, 100).next() // button38 , Arb.int(-100, 100).next() // date39 , Arb.int(-100, 100).next() // time40 , Arb.int(-100, 100).next() // dateTime41 , Arb.int(-100, 100).next() // dropDown42 , Arb.int(-100, 100).next() // multiCheckBox43 , Arb.int(-100, 100).next() // switch44 , Arb.int(-100, 100).next() // checkBox45 , Arb.int(-100, 100).next() // slider46 , Arb.int(-100, 100).next() // label47 , Arb.int(-100, 100).next() // textView48 , Arb.int(-100, 100).next() // segmented49 , Arb.int(-100, 100).next() // segmentedInlineTitle50 , Arb.int(-100, 100).next() // progress51 , Arb.int(-100, 100).next() // image52 , Arb.int(-100, 100).next() // inlineDateTimePicker53 )54 }55 /**56 * Generates a BaseFormElement57 */58 val baseFormElement = arbitrary {59 generateBaseFields(BaseFormElement())60 }61 /**62 * Generates a FormHeader63 */64 val formHeader = arbitrary {65 FormHeader().apply { title = Arb.string().next() }66 }67 /**68 * Generates a FormSingleLineEditTextElement69 */70 val formSingleLineEditTextElement = arbitrary {71 generateBaseFields(FormSingleLineEditTextElement()) as FormSingleLineEditTextElement72 }73 /**74 * Generates a FormMultiLineEditTextElement75 */76 val formMultiLineEditTextElement = arbitrary {77 generateBaseFields(FormMultiLineEditTextElement()) as FormMultiLineEditTextElement78 }79 /**80 * Generates a FormEmailEditTextElement81 */82 val formEmailEditTextElement = arbitrary {83 val element = generateBaseFields(FormEmailEditTextElement()) as FormEmailEditTextElement84 element.value = Arb.shuffle(85 listOf(86 "test@example.com",87 "test.tester@example2.org",88 "email@example.test.edu"89 )90 ).next()[0]91 element.validityCheck = {92 ("[a-zA-Z0-9\\+\\.\\_\\%\\-\\+]{1,256}" +93 "\\@" +94 "[a-zA-Z0-9][a-zA-Z0-9\\-]{0,64}" +95 "(" +96 "\\." +97 "[a-zA-Z0-9][a-zA-Z0-9\\-]{0,25}" +98 ")+").toRegex().matches(element.value ?: "")99 }100 element101 }102 /**103 * Generates a FormPasswordEditTextElement104 */105 val formPasswordEditTextElement = arbitrary {106 generateBaseFields(FormPasswordEditTextElement()) as FormPasswordEditTextElement107 }108 /**109 * Generates a FormPhoneEditTextElement110 */111 val formPhoneEditTextElement = arbitrary {112 generateBaseFields(FormPhoneEditTextElement()) as FormPhoneEditTextElement113 }114 /**115 * Generates a FormNumberEditTextElement116 */117 val formNumberEditTextElement = arbitrary {118 generateBaseFields(FormNumberEditTextElement()) as FormNumberEditTextElement119 }120 /**121 * Generates a FormTextViewElement122 */123 val formTextViewElement = arbitrary {124 FormTextViewElement().apply {125 title = Arb.string().next()126 value = Arb.string().next()127 }128 }129 /**130 * Generates a formLabelElement131 */132 val formLabelElement = arbitrary {133 FormLabelElement().apply {134 title = Arb.string().next()135 }136 }137 /**138 * Generates a FormSegmentedElement139 */140 val formSegmentedElement = arbitrary {141 val element = generateBaseFields(FormSegmentedElement()) as FormSegmentedElement<String>142 element.horizontal = Arb.boolean().next()143 element.options = Arb.list(Arb.string()).next()144 element.drawableDirection =145 Arb.shuffle(FormSegmentedElement.DrawableDirection.values().asList()).next()[0]146 element147 }148 /**149 * Generates a FormPickerDropDownElement150 */151 val formPickerDropDownElement = arbitrary {152 val element =153 generateBaseFields(FormPickerDropDownElement()) as FormPickerDropDownElement<String>154 element.dialogTitle = Arb.string().next()155 element.arrayAdapter = null156 element.options = Arb.list(Arb.string()).next()157 element.theme = Random().nextInt(100)158 element.displayValueFor = {159 element.value ?: ""160 }161 element162 }163 /**164 * Generates a FormPickerMultiCheckBoxElement165 */166 val formPickerMultiCheckBoxElement = arbitrary {167 @Suppress("UNCHECKED_CAST")168 val element =169 generateBaseFieldsWithList(FormPickerMultiCheckBoxElement()) as FormPickerMultiCheckBoxElement<String, List<String>>170 element.dialogTitle = Arb.string().next()171 element.options = Arb.list(Arb.string()).next()172 element.theme = Random().nextInt(100)173 element174 }175 /**176 * Generates a FormAutoCompleteElement177 */178 val formAutoCompleteElement = arbitrary {179 val element =180 generateBaseFields(FormAutoCompleteElement()) as FormAutoCompleteElement<String>181 element.typedString = element.valueAsString182 element.dropdownWidth = Arb.int().next()183 val listOfOptions = Arb.list(Arb.string()).next()184 element.options = listOfOptions185 element.arrayAdapter = ArrayAdapter(mockk(), R.layout.simple_list_item_1, listOfOptions)186 element187 }188 /**189 * Generates a FormTokenAutoCompleteElement190 */191 val formTokenAutoCompleteElement = arbitrary {192 val element =193 generateBaseFieldsWithList(FormTokenAutoCompleteElement()) as FormTokenAutoCompleteElement<List<String>>194 element.dropdownWidth = Arb.int().next()195 val listOfOptions = Arb.list(Arb.string()).next()196 element.options = listOfOptions197 element.arrayAdapter = ArrayAdapter(mockk(), R.layout.simple_list_item_1, listOfOptions)198 element199 }200 /**201 * Generates a FormCheckBoxElement202 */203 val formCheckBoxElement = arbitrary {204 val element = generateBaseFields(FormCheckBoxElement()) as FormCheckBoxElement<String>205 element.checkedValue = element.valueAsString206 element.unCheckedValue = Arb.string().next()207 element208 }209 /**210 * Generates a FormSwitchElement211 */212 val formSwitchElement = arbitrary {213 val element = generateBaseFields(FormSwitchElement()) as FormSwitchElement<String>214 element.onValue = element.valueAsString215 element.offValue = Arb.string().next()216 element217 }218 /**219 * Generates a FormSliderElement220 */221 val formSliderElement = arbitrary {222 val element = FormSliderElement()223 element.title = Arb.string().next()224 element.max = Random().nextInt(100)225 element.min = Random().nextInt(element.max)226 element.value = Random().nextInt(element.max - element.min) + element.min227 element.steps = Random().nextInt(element.max - element.min + 1) + element.min228 element229 }230 /**231 * Generates a FormProgressElement232 */233 val formProgressElement = arbitrary {234 val element = FormProgressElement()235 element.title = Arb.string().next()236 element.max = Random().nextInt(100)237 element.min = Random().nextInt(element.max)238 element.progress = Random().nextInt(element.max - element.min) + element.min239 element.secondaryProgress = Random().nextInt(element.max - element.min) + element.min240 element.indeterminate = Arb.boolean().next()241 element.progressBarStyle =242 Arb.shuffle(FormProgressElement.ProgressBarStyle.values().asList()).next()[0]243 element244 }245 /**246 * Generates a FormImageElement247 */248 val formImageElement = arbitrary {249 val element = FormImageElement()250 element.value = "https://example.com/image.jpg"251 element.applyCircleCrop = false252 element.theme = Random().nextInt(100)253 element.defaultImage = Random().nextInt(100)254 element.imagePickerOptions = {255 it.cropX = Random().nextFloat()256 it.cropY = Random().nextFloat()257 it.maxWidth = Random().nextInt(100)258 it.maxHeight = Random().nextInt(100)259 it.maxSize = Random().nextInt(100)260 }261 element.onSelectImage = { uri, _ ->262 println("\nNew Image = ${uri?.path}")263 }264 element265 }266 /**267 * Generates a FormPickerDateElement268 */269 val formPickerDateElement = arbitrary {270 val dateFormat = SimpleDateFormat("MM/dd/yyyy", Locale.US)271 val element = FormPickerDateElement()272 element.title = Arb.string().next()273 element.hint = Arb.string().next()274 element.value = FormPickerDateElement.DateHolder(Date(), dateFormat)275 element.minimumDate = dateFormat.parse("01/01/2018")276 element.maximumDate = dateFormat.parse("12/15/2025")277 element.theme = Random().nextInt(100)278 element279 }280 /**281 * Generates a FormPickerTimeElement282 */283 val formPickerTimeElement = arbitrary {284 val dateFormat = SimpleDateFormat("hh:mm a", Locale.US)285 val element = FormPickerTimeElement()286 element.title = Arb.string().next()287 element.hint = Arb.string().next()288 element.value = FormPickerTimeElement.TimeHolder(Date(), dateFormat)289 element.theme = Random().nextInt(100)290 element291 }292 /**293 * Generates a FormPickerDateTimeElement294 */295 val formPickerDateTimeElement = arbitrary {296 val dateFormat = SimpleDateFormat("MM/dd/yyyy hh:mm a", Locale.US)297 val element = FormPickerDateTimeElement()298 element.title = Arb.string().next()299 element.hint = Arb.string().next()300 element.value = FormPickerDateTimeElement.DateTimeHolder(Date(), dateFormat)301 element.minimumDate = dateFormat.parse("01/01/2018 12:00 AM")302 element.maximumDate = dateFormat.parse("12/15/2025 12:00 PM")303 element.theme = Random().nextInt(100)304 element305 }306 /**307 * Generates a FormInlineDatePickerElement308 */309 val formInlineDatePickerElement = arbitrary {310 val element = FormInlineDatePickerElement()311 element.title = Arb.string().next()312 element.hint = Arb.string().next()313 element.value = org.threeten.bp.LocalDateTime.now(ZoneId.of("UTC"))314 element.dateTimeFormatter = DateTimeFormatter.ISO_DATE_TIME315 element.dateTimePickerFormatter = DateTimeFormatter.ISO_DATE316 element.startDate = org.threeten.bp.LocalDateTime.now(ZoneId.of("UTC")).toLocalDate()317 element.allDay = Arb.boolean().next()318 element.pickerType =319 Arb.shuffle(FormInlineDatePickerElement.PickerType.values().asList()).next()[0]320 element.linkedPicker = FormInlineDatePickerElement()321 element322 }323 /**324 * Generates a FormButtonElement325 */326 val formButtonElement = arbitrary {327 FormButtonElement().setValue(Arb.string().next()) as FormButtonElement328 }329 /**330 * Generates base form field values331 */332 private fun generateBaseFields(element: BaseFormElement<String>) =333 element.apply {334 title = Arb.string().next()335 value = Arb.string().next()336 tag = Arb.int().next()337 hint = Arb.string().next()338 visible = Arb.boolean().next()339 enabled = Arb.boolean().next()340 editViewGravity = Arb.int().next()341 maxLines = Arb.int(1, 100).next()342 error = if (Arb.boolean().next()) Arb.string().next() else null343 valueObservers.add { newValue, elementRef -> println("New Value = $newValue {$elementRef}") }344 }345 private fun generateBaseFieldsWithList(element: BaseFormElement<List<String>>) =346 element.apply {347 title = Arb.string().next()348 value = Arb.list(Arb.string()).next()349 tag = Arb.int().next()350 hint = Arb.string().next()351 visible = Arb.boolean().next()352 enabled = Arb.boolean().next()353 editViewGravity = Arb.int().next()354 maxLines = Arb.int(1, 100).next()355 error = if (Arb.boolean().next()) Arb.string().next() else null356 valueObservers.add { newValue, elementRef -> println("\nNew Value = $newValue {$elementRef}") }357 }358 /**359 * Verifies some base form fields360 */361 fun verifyBaseFormElement(element: BaseFormElement<*>) =362 (element.value != null) &&363 (element.hint != null) &&364 element.valueObservers.isNotEmpty()365 }366}...
NodeGen.kt
Source:NodeGen.kt
1package ru.dimsuz.way.generator2import io.kotest.property.Arb3import io.kotest.property.Shrinker4import io.kotest.property.arbitrary.ListShrinker5import io.kotest.property.arbitrary.arbitrary6import io.kotest.property.arbitrary.az7import io.kotest.property.arbitrary.element8import io.kotest.property.arbitrary.map9import io.kotest.property.arbitrary.next10import io.kotest.property.arbitrary.single11import io.kotest.property.arbitrary.string12import io.kotest.property.arbitrary.take13import ru.dimsuz.way.Event14import ru.dimsuz.way.NodeKey15import ru.dimsuz.way.entity.NodeScheme16import ru.dimsuz.way.entity.SchemeNode17import ru.dimsuz.way.entity.fold18import java.util.Locale19import kotlin.random.nextInt20fun Arb.Companion.scheme(maxLevel: Int = 2): Arb<NodeScheme> {21 return arbitrary(shrinker = SchemeShrinker()) { rs ->22 val nodes = Arb.schemeNodes(maxLevel).next(rs)23 NodeScheme(24 initial = Arb.element(nodes.keys).next(rs),25 nodes = nodes26 )27 }28}29fun Arb.Companion.schemeWithEventSequence(maxLevel: Int = 2): Arb<Pair<NodeScheme, List<Event>>> {30 return arbitrary(shrinker = SchemeWithEventShrinker()) { rs ->31 val scheme = Arb.scheme(maxLevel).single(rs)32 val eventSequence = Arb.eventSequence(scheme).single(rs)33 scheme to eventSequence34 }35}36private class SchemeWithEventShrinker : Shrinker<Pair<NodeScheme, List<Event>>> {37 private val eventShrinker = ListShrinker<Event>(GEN_EVENTS_MIN..GEN_EVENTS_MAX)38 override fun shrink(value: Pair<NodeScheme, List<Event>>): List<Pair<NodeScheme, List<Event>>> {39 val events = value.second40 val scheme = value.first41 return listOf(42 scheme.filterNodesWithEvents(events, scheme.findNodesTargetedByEvents(events)) to events43 ).plus(44 eventShrinker.shrink(events).map {45 scheme.filterNodesWithEvents(it, scheme.findNodesTargetedByEvents(it)) to it46 }47 )48 }49 private fun NodeScheme.findNodesTargetedByEvents(events: List<Event>): List<String> {50 return this.fold { schemeNode, states ->51 val s = when (schemeNode) {52 is SchemeNode.Atomic -> {53 schemeNode.transitions.filterKeys { events.any { e -> e.name == it } }.map { it.value.key }54 }55 is SchemeNode.Compound -> emptyList()56 }57 states.plusElement(s).flatten()58 }59 }60 // TODO rewrite this at least to be extension on SchemeNode.Compound (wrap root NodeScheme in it)61 // or using fold62 private fun NodeScheme.filterNodesWithEvents(events: List<Event>, targets: List<String>): NodeScheme {63 if (events.isEmpty()) return this64 // TODO also filter unneeded transitions65 return NodeScheme(66 initial = initial,67 nodes = this.nodes.entries.mapNotNull { (key, node) ->68 when (node) {69 is SchemeNode.Atomic -> {70 val transitions = node.transitions.filter { (event, _) -> events.any { it.name == event } }71 if (transitions.isNotEmpty() || targets.contains(key))72 key to node.copy(transitions = transitions) else null73 }74 is SchemeNode.Compound -> {75 val mappedNodes = node.scheme.filterNodesWithEvents(events, targets).nodes.toMutableMap()76 if (mappedNodes.isNotEmpty() || targets.contains(key)) {77 if (!mappedNodes.containsKey(node.scheme.initial)) {78 // if initial was filtered out, add it back it's required79 mappedNodes[node.scheme.initial] = node.scheme.nodes[node.scheme.initial]!!80 }81 key to SchemeNode.Compound(NodeScheme(node.scheme.initial, mappedNodes))82 } else null83 }84 }85 }86 .toMap()87 .let { if (it.isNotEmpty() && !it.containsKey(initial)) it.plus(initial to this.nodes[initial]!!) else it }88 )89 }90}91/**92 * Generates a sequence of events which represent a valid set of transitions.93 * Events are selected so that each of them will be valid for the node which is reached94 * by sending a sequence of events preceding the current one.95 * That implies that each event will transition to a new node, never staying on the same one.96 */97fun Arb.Companion.eventSequence(scheme: NodeScheme): Arb<List<Event>> {98 return arbitrary(shrinker = ListShrinker(GEN_EVENTS_MIN..GEN_EVENTS_MAX)) { rs ->99 val count = rs.random.nextInt(GEN_EVENTS_MIN..GEN_EVENTS_MAX)100 val events = mutableListOf<Event>()101 var containingNode = SchemeNode.Compound(scheme)102 var currentNode = scheme.nodes[scheme.initial]103 while (events.size < count) {104 when (currentNode) {105 is SchemeNode.Atomic -> {106 if (currentNode.transitions.isEmpty()) {107 break108 }109 val transition = Arb.element(currentNode.transitions.entries).next(rs)110 events.add(Event(name = transition.key))111 currentNode = containingNode.scheme.nodes[transition.value.key]112 ?: error("failed to find node '${transition.value.key}' in the containing node")113 }114 is SchemeNode.Compound -> {115 containingNode = currentNode116 currentNode = currentNode.scheme.nodes[currentNode.scheme.initial]117 ?: error("no initial node definition found for '${currentNode.scheme.initial}'")118 }119 }120 }121 events122 }123}124private fun Arb.Companion.schemeNodes(maxLevel: Int): Arb<Map<String, SchemeNode>> {125 return arbitrary { rs ->126 val nodeKeys = Arb.nodeKeyName().take(rs.random.nextInt(1..30), rs).toList()127 val atomicNodes = mutableMapOf<String, NodeTransitions>()128 val compoundNodeKeys = if (maxLevel > 0 && nodeKeys.size >= 3) {129 nodeKeys.take(rs.random.nextInt(0, nodeKeys.size / 3))130 } else emptyList()131 val atomicNodeKeys = nodeKeys.minus(compoundNodeKeys)132 atomicNodeKeys.forEach { nodeKey ->133 if (ENABLE_SCHEME_GEN_DEBUG) {134 println("generating transitions for node $nodeKey")135 }136 // better have more states than events, otherwise it would be hard to137 // find a combination of transitions which doesn't introduce a cycle138 val events = Arb.eventName().take(rs.random.nextInt(0..nodeKeys.size / 2), rs)139 val potentialTargets = nodeKeys.minus(nodeKey)140 val transitions = mutableMapOf<String, String>()141 var attemptsRemaining = 15142 for (event in events) {143 while (attemptsRemaining > 0) {144 val target = potentialTargets.random(rs.random)145 transitions[event] = target146 if (hasCycle(atomicNodes, nodeKey, transitions)) {147 transitions.remove(event)148 attemptsRemaining -= 1149 } else break150 }151 if (attemptsRemaining <= 0) {152 if (ENABLE_SCHEME_GEN_DEBUG) {153 println("attempts exhausted while trying to find non-cycling targets for node $nodeKey, moving on")154 }155 break156 }157 }158 atomicNodes[nodeKey] = transitions159 }160 val scheme = HashMap<String, SchemeNode>(atomicNodes.size + compoundNodeKeys.size)161 atomicNodes.forEach { (key, transitions) ->162 scheme[key] = SchemeNode.Atomic(transitions.entries.associate { Event.Name(it.key) to NodeKey(it.value) })163 }164 compoundNodeKeys.forEach { key ->165 scheme[key] = SchemeNode.Compound(Arb.scheme(maxLevel - 1).next(rs))166 }167 scheme168 }169}170typealias NodeTransitions = Map<String, String>171private fun hasCycle(nodes: Map<String, NodeTransitions>, newKey: String, newKeyTransitions: NodeTransitions): Boolean {172 val adjacent = HashMap<String, Collection<String>>(nodes.size + 1)173 nodes.forEach { (s, map) -> adjacent[s] = map.values }174 adjacent[newKey] = newKeyTransitions.values175 val cycle = dfsCycleSearch(adjacent)176 return if (cycle != null) {177 if (ENABLE_SCHEME_GEN_DEBUG) {178 println("cycle detected in nodes ${cycle.first} â ${cycle.second}")179 }180 true181 } else false182}183private fun dfsCycleSearch(adjacent: Map<String, Collection<String>>): Pair<String, String>? {184 val discovered = HashSet<String>(adjacent.size)185 val finished = HashSet<String>(adjacent.size)186 fun dfsVisit(key: String): Pair<String, String>? {187 discovered.add(key)188 adjacent[key].orEmpty().forEach { key1 ->189 if (key1 in discovered) {190 return key to key1191 }192 if (key1 !in finished) {193 dfsVisit(key1)194 }195 }196 discovered.remove(key)197 finished.add(key)198 return null199 }200 adjacent.keys.forEach { key ->201 if (key !in discovered && key !in finished) {202 val cycle = dfsVisit(key)203 if (cycle != null) {204 return cycle205 }206 }207 }208 return null209}210private fun Arb.Companion.nodeKeyName() = Arb.string(5..8, Arb.az())211private fun Arb.Companion.eventName() = Arb.string(5..8, Arb.az()).map { it.uppercase(Locale.getDefault()) }212fun Arb.Companion.nodeKey(): Arb<NodeKey> {213 return Arb.nodeKeyName().map { NodeKey(it) }214}215fun Arb.Companion.event(): Arb<Event> {216 return Arb.eventName().map { Event(Event.Name(it)) }217}218private class SchemeShrinker : Shrinker<NodeScheme> {219 override fun shrink(value: NodeScheme): List<NodeScheme> {220 return when {221 value.nodes.isEmpty() -> emptyList()222 value.nodes.size == 1 -> emptyList()223 else -> {224 listOfNotNull(225 // only the initial226 value.nodes.filter { it.key == value.initial },227 // first non-initial dropped228 value.nodes.minus(value.nodes.keys.first { it != value.initial }),229 // last non-initial dropped230 value.nodes.minus(value.nodes.keys.last { it != value.initial }),231 // half of the nodes232 value.nodes.minus(value.nodes.keys.toList().filter { it != value.initial }.dropLast(value.nodes.size / 2)),233 ).map { NodeScheme(value.initial, it) }234 }235 }236 }237}238private const val ENABLE_SCHEME_GEN_DEBUG = false239private const val GEN_EVENTS_MIN = 1240private const val GEN_EVENTS_MAX = 50...
locale.kt
Source:locale.kt
1package io.kotest.property.arbitrary2import io.kotest.property.Arb3// this is a dump of some locales built into the java.util.Locale class on JDK11, executed on a linux ubuntu os4val locales = listOf(5 "af",6 "af_NA",7 "af_ZA",8 "agq",9 "agq_CM",10 "ak",11 "ak_GH",12 "am",13 "am_ET",14 "ar",15 "ar_001",16 "ar_AE",17 "ar_BH",18 "ar_DJ",19 "ar_DZ",20 "ar_EG",21 "ar_EH",22 "ar_ER",23 "ar_IL",24 "ar_IQ",25 "ar_JO",26 "ar_KM",27 "ar_KW",28 "ar_LB",29 "ar_LY",30 "ar_MA",31 "ar_MR",32 "ar_OM",33 "ar_PS",34 "ar_QA",35 "ar_SA",36 "ar_SD",37 "ar_SO",38 "ar_SS",39 "ar_SY",40 "ar_TD",41 "ar_TN",42 "ar_YE",43 "as",44 "as_IN",45 "asa",46 "asa_TZ",47 "ast",48 "ast_ES",49 "az",50 "bas",51 "bas_CM",52 "be",53 "be_BY",54 "bem",55 "bem_ZM",56 "bez",57 "bez_TZ",58 "bg",59 "bg_BG",60 "bm",61 "bm_ML",62 "bn",63 "bn_BD",64 "bn_IN",65 "bo",66 "bo_CN",67 "bo_IN",68 "br",69 "br_FR",70 "brx",71 "brx_IN",72 "bs",73 "ca",74 "ca_AD",75 "ca_ES",76 "ca_ES_VALENCIA",77 "ca_FR",78 "ca_IT",79 "ccp",80 "ccp_BD",81 "ccp_IN",82 "ce",83 "ce_RU",84 "cgg",85 "cgg_UG",86 "chr",87 "chr_US",88 "ckb",89 "ckb_IQ",90 "ckb_IR",91 "cs",92 "cs_CZ",93 "cu",94 "cu_RU",95 "cy",96 "cy_GB",97 "da",98 "da_DK",99 "da_GL",100 "dav",101 "dav_KE",102 "de",103 "de_AT",104 "de_BE",105 "de_CH",106 "de_DE",107 "de_IT",108 "de_LI",109 "de_LU",110 "dje",111 "dje_NE",112 "dsb",113 "dsb_DE",114 "dua",115 "dua_CM",116 "dyo",117 "dyo_SN",118 "dz",119 "dz_BT",120 "ebu",121 "ebu_KE",122 "ee",123 "ee_GH",124 "ee_TG",125 "el",126 "el_CY",127 "el_GR",128 "en",129 "en_001",130 "en_150",131 "en_AG",132 "en_AI",133 "en_AS",134 "en_AT",135 "en_AU",136 "en_BB",137 "en_BE",138 "en_BI",139 "en_BM",140 "en_BS",141 "en_BW",142 "en_BZ",143 "en_CA",144 "en_CC",145 "en_CH",146 "en_CK",147 "en_CM",148 "en_CX",149 "en_CY",150 "en_DE",151 "en_DG",152 "en_DK",153 "en_DM",154 "en_ER",155 "en_FI",156 "en_FJ",157 "en_FK",158 "en_FM",159 "en_GB",160 "en_GD",161 "en_GG",162 "en_GH",163 "en_GI",164 "en_GM",165 "en_GU",166 "en_GY",167 "en_HK",168 "en_IE",169 "en_IL",170 "en_IM",171 "en_IN",172 "en_IO",173 "en_JE",174 "en_JM",175 "en_KE",176 "en_KI",177 "en_KN",178 "en_KY",179 "en_LC",180 "en_LR",181 "en_LS",182 "en_MG",183 "en_MH",184 "en_MO",185 "en_MP",186 "en_MS",187 "en_MT",188 "en_MU",189 "en_MW",190 "en_MY",191 "en_NA",192 "en_NF",193 "en_NG",194 "en_NL",195 "en_NR",196 "en_NU",197 "en_NZ",198 "en_PG",199 "en_PH",200 "en_PK",201 "en_PN",202 "en_PR",203 "en_PW",204 "en_RW",205 "en_SB",206 "en_SC",207 "en_SD",208 "en_SE",209 "en_SG",210 "en_SH",211 "en_SI",212 "en_SL",213 "en_SS",214 "en_SX",215 "en_SZ",216 "en_TC",217 "en_TK",218 "en_TO",219 "en_TT",220 "en_TV",221 "en_TZ",222 "en_UG",223 "en_UM",224 "en_US",225 "en_US_POSIX",226 "en_VC",227 "en_VG",228 "en_VI",229 "en_VU",230 "en_WS",231 "en_ZA",232 "en_ZM",233 "en_ZW",234 "eo",235 "eo_001",236 "es",237 "es_419",238 "es_AR",239 "es_BO",240 "es_BR",241 "es_BZ",242 "es_CL",243 "es_CO",244 "es_CR",245 "es_CU",246 "es_DO",247 "es_EA",248 "es_EC",249 "es_ES",250 "es_GQ",251 "es_GT",252 "es_HN",253 "es_IC",254 "es_MX",255 "es_NI",256 "es_PA",257 "es_PE",258 "es_PH",259 "es_PR",260 "es_PY",261 "es_SV",262 "es_US",263 "es_UY",264 "es_VE",265 "et",266 "et_EE",267 "eu",268 "eu_ES",269 "ewo",270 "ewo_CM",271 "fa",272 "fa_AF",273 "fa_IR",274 "ff",275 "ff_CM",276 "ff_GN",277 "ff_MR",278 "ff_SN",279 "fi",280 "fi_FI",281 "fil",282 "fil_PH",283 "fo",284 "fo_DK",285 "fo_FO",286 "fr",287 "fr_BE",288 "fr_BF",289 "fr_BI",290 "fr_BJ",291 "fr_BL",292 "fr_CA",293 "fr_CD",294 "fr_CF",295 "fr_CG",296 "fr_CH",297 "fr_CI",298 "fr_CM",299 "fr_DJ",300 "fr_DZ",301 "fr_FR",302 "fr_GA",303 "fr_GF",304 "fr_GN",305 "fr_GP",306 "fr_GQ",307 "fr_HT",308 "fr_KM",309 "fr_LU",310 "fr_MA",311 "fr_MC",312 "fr_MF",313 "fr_MG",314 "fr_ML",315 "fr_MQ",316 "fr_MR",317 "fr_MU",318 "fr_NC",319 "fr_NE",320 "fr_PF",321 "fr_PM",322 "fr_RE",323 "fr_RW",324 "fr_SC",325 "fr_SN",326 "fr_SY",327 "fr_TD",328 "fr_TG",329 "fr_TN",330 "fr_VU",331 "fr_WF",332 "fr_YT",333 "fur",334 "fur_IT",335 "fy",336 "fy_NL",337 "ga",338 "ga_IE",339 "gd",340 "gd_GB",341 "gl",342 "gl_ES",343 "gsw",344 "gsw_CH",345 "gsw_FR",346 "gsw_LI",347 "gu",348 "gu_IN",349 "guz",350 "guz_KE",351 "gv",352 "gv_IM",353 "ha",354 "ha_GH",355 "ha_NE",356 "ha_NG",357 "haw",358 "haw_US",359 "hi",360 "hi_IN",361 "hr",362 "hr_BA",363 "hr_HR",364 "hsb",365 "hsb_DE",366 "hu",367 "hu_HU",368 "hy",369 "hy_AM",370 "ig",371 "ig_NG",372 "ii",373 "ii_CN",374 "in",375 "in_ID",376 "is",377 "is_IS",378 "it",379 "it_CH",380 "it_IT",381 "it_SM",382 "it_VA",383 "iw",384 "iw_IL",385 "ja",386 "ja_JP",387 "jgo",388 "jgo_CM",389 "ji",390 "ji_001",391 "jmc",392 "jmc_TZ",393 "ka",394 "ka_GE",395 "kab",396 "kab_DZ",397 "kam",398 "kam_KE",399 "kde",400 "kde_TZ",401 "kea",402 "kea_CV",403 "khq",404 "khq_ML",405 "ki",406 "ki_KE",407 "kk",408 "kk_KZ",409 "kkj",410 "kkj_CM",411 "kl",412 "kl_GL",413 "kln",414 "kln_KE",415 "km",416 "km_KH",417 "kn",418 "kn_IN",419 "ko",420 "ko_KP",421 "ko_KR",422 "kok",423 "kok_IN",424 "ks",425 "ks_IN",426 "ksb",427 "ksb_TZ",428 "ksf",429 "ksf_CM",430 "ksh",431 "ksh_DE",432 "kw",433 "kw_GB",434 "ky",435 "ky_KG",436 "lag",437 "lag_TZ",438 "lb",439 "lb_LU",440 "lg",441 "lg_UG",442 "lkt",443 "lkt_US",444 "ln",445 "ln_AO",446 "ln_CD",447 "ln_CF",448 "ln_CG",449 "lo",450 "lo_LA",451 "lrc",452 "lrc_IQ",453 "lrc_IR",454 "lt",455 "lt_LT",456 "lu",457 "lu_CD",458 "luo",459 "luo_KE",460 "luy",461 "luy_KE",462 "lv",463 "lv_LV",464 "mas",465 "mas_KE",466 "mas_TZ",467 "mer",468 "mer_KE",469 "mfe",470 "mfe_MU",471 "mg",472 "mg_MG",473 "mgh",474 "mgh_MZ",475 "mgo",476 "mgo_CM",477 "mk",478 "mk_MK",479 "ml",480 "ml_IN",481 "mn",482 "mn_MN",483 "mr",484 "mr_IN",485 "ms",486 "ms_BN",487 "ms_MY",488 "ms_SG",489 "mt",490 "mt_MT",491 "mua",492 "mua_CM",493 "my",494 "my_MM",495 "mzn",496 "mzn_IR",497 "naq",498 "naq_NA",499 "nb",500 "nb_NO",501 "nb_SJ",502 "nd",503 "nd_ZW",504 "nds",505 "nds_DE",506 "nds_NL",507 "ne",508 "ne_IN",509 "ne_NP",510 "nl",511 "nl_AW",512 "nl_BE",513 "nl_BQ",514 "nl_CW",515 "nl_NL",516 "nl_SR",517 "nl_SX",518 "nmg",519 "nmg_CM",520 "nn_NO",521 "nnh",522 "nnh_CM",523 "no",524 "no_NO",525 "no_NO_NY",526 "nus",527 "nus_SS",528 "nyn",529 "nyn_UG",530 "om",531 "om_ET",532 "om_KE",533 "or",534 "or_IN",535 "os",536 "os_GE",537 "os_RU",538 "pa",539 "pl",540 "pl_PL",541 "prg",542 "prg_001",543 "ps",544 "ps_AF",545 "pt",546 "pt_AO",547 "pt_BR",548 "pt_CH",549 "pt_CV",550 "pt_GQ",551 "pt_GW",552 "pt_LU",553 "pt_MO",554 "pt_MZ",555 "pt_PT",556 "pt_ST",557 "pt_TL",558 "qu",559 "qu_BO",560 "qu_EC",561 "qu_PE",562 "rm",563 "rm_CH",564 "rn",565 "rn_BI",566 "ro",567 "ro_MD",568 "ro_RO",569 "rof",570 "rof_TZ",571 "ru",572 "ru_BY",573 "ru_KG",574 "ru_KZ",575 "ru_MD",576 "ru_RU",577 "ru_UA",578 "rw",579 "rw_RW",580 "rwk",581 "rwk_TZ",582 "sah",583 "sah_RU",584 "saq",585 "saq_KE",586 "sbp",587 "sbp_TZ",588 "sd",589 "sd_PK",590 "se",591 "se_FI",592 "se_NO",593 "se_SE",594 "seh",595 "seh_MZ",596 "ses",597 "ses_ML",598 "sg",599 "sg_CF",600 "shi",601 "si",602 "si_LK",603 "sk",604 "sk_SK",605 "sl",606 "sl_SI",607 "smn",608 "smn_FI",609 "sn",610 "sn_ZW",611 "so",612 "so_DJ",613 "so_ET",614 "so_KE",615 "so_SO",616 "sq",617 "sq_AL",618 "sq_MK",619 "sq_XK",620 "sr",621 "sr_BA",622 "sr_CS",623 "sr_ME",624 "sr_RS",625 "sv",626 "sv_AX",627 "sv_FI",628 "sv_SE",629 "sw",630 "sw_CD",631 "sw_KE",632 "sw_TZ",633 "sw_UG",634 "ta",635 "ta_IN",636 "ta_LK",637 "ta_MY",638 "ta_SG",639 "te",640 "te_IN",641 "teo",642 "teo_KE",643 "teo_UG",644 "tg",645 "tg_TJ",646 "th",647 "th_TH",648 "ti",649 "ti_ER",650 "ti_ET",651 "tk",652 "tk_TM",653 "to",654 "to_TO",655 "tr",656 "tr_CY",657 "tr_TR",658 "tt",659 "tt_RU",660 "twq",661 "twq_NE",662 "tzm",663 "tzm_MA",664 "ug",665 "ug_CN",666 "uk",667 "uk_UA",668 "ur",669 "ur_IN",670 "ur_PK",671 "uz",672 "vai",673 "vi",674 "vi_VN",675 "vo",676 "vo_001",677 "vun",678 "vun_TZ",679 "wae",680 "wae_CH",681 "wo",682 "wo_SN",683 "xog",684 "xog_UG",685 "yav",686 "yav_CM",687 "yo",688 "yo_BJ",689 "yo_NG",690 "yue",691 "zgh",692 "zgh_MA",693 "zh",694 "zh_CN",695 "zh_HK",696 "zh_SG",697 "zh_TW",698 "zu",699 "zu_ZA",700)701/**702 * Returns an Arb that generates locales.703 *704 * Edgecases include a locale that only has a language (without country) and a locale705 * that has a variant.706 */707fun Arb.Companion.locale() = arbitrary(listOf("en", "ca_ES_VALENCIA")) { locales.random(it.random) }...
Arb.Companion.locale
Using AI Code Generation
1import io.kotest.property.arbitrary.locale2import io.kotest.property.arbitrary.localDate3import io.kotest.property.arbitrary.localDateTime4import io.kotest.property.arbitrary.localTime5import io.kotest.property.arbitrary.localTime6import io.kotest.property.arbitrary.monthDay7import io.kotest.property.arbitrary.monthDay8import io.kotest.property.arbitrary.nanosOfDay9import io.kotest.property.arbitrary.nanosOfSecond10import io.kotest.property.arbitrary.nanosOfSecond11import io.kotest.property
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!