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

fill CharSequence param as String #118

Merged
merged 2 commits into from
Jul 29, 2023
Merged
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 @@ -328,7 +328,9 @@ open class FillClassFix(

KotlinBuiltIns.isCollectionOrNullableCollection(type) -> "arrayOf()"
KotlinBuiltIns.isNullableAny(type) -> "null"
KotlinBuiltIns.isString(type) -> "\"\""
KotlinBuiltIns.isCharSequence(type) ||
KotlinBuiltIns.isString(type) -> "\"\""

KotlinBuiltIns.isListOrNullableList(type) -> "listOf()"
KotlinBuiltIns.isSetOrNullableSet(type) -> "setOf()"
KotlinBuiltIns.isMapOrNullableMap(type) -> "mapOf()"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ class FillDummyValueFix(
KotlinBuiltIns.isLong(type) ||
KotlinBuiltIns.isShort(type) -> "${ValueGenerator.randomNumFor(paramName)}"

KotlinBuiltIns.isString(type) -> "\"${ValueGenerator.randomStringFor(paramName)}\""
KotlinBuiltIns.isCharSequence(type) ||
KotlinBuiltIns.isString(type) -> "\"${ValueGenerator.randomStringFor(paramName)}\""

else -> super.fillValue(descriptor)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,18 @@ class FillDummyValueInspectionTest : BasePlatformTestCase() {
fun `test fill class constructor`() {
every { ValueGenerator.randomStringFor("name") } returns "John Smith"
every { ValueGenerator.randomNumFor("age") } returns 1234
every { ValueGenerator.randomStringFor("pass") } returns "password"
doAvailableTest(
"""
class User(val name: String, val age: Int)
class User(val name: String, val age: Int, val pass: CharSequence)
fun test() {
User(<caret>)
}
""",
"""
class User(val name: String, val age: Int)
class User(val name: String, val age: Int, val pass: CharSequence)
fun test() {
User(name = "John Smith", age = 1234)
User(name = "John Smith", age = 1234, pass = "password")
}
""",
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ class FillEmptyValueInspectionTest : BasePlatformTestCase() {
fun `test fill class constructor`() {
doAvailableTest(
"""
class User(val name: String, val age: Int)
class User(val name: String, val age: Int, val pass: CharSequence)
fun test() {
User(<caret>)
}
""",
"""
class User(val name: String, val age: Int)
class User(val name: String, val age: Int, val pass: CharSequence)
fun test() {
User(name = "", age = 0)
User(name = "", age = 0, pass = "")
}
""",
)
Expand Down