Skip to content

Commit

Permalink
Merge pull request #118 from suusan2go/issue_117
Browse files Browse the repository at this point in the history
fill CharSequence param as String
  • Loading branch information
oboenikui authored Jul 29, 2023
2 parents 6022031 + 9468a2e commit ecef6f9
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
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

0 comments on commit ecef6f9

Please sign in to comment.