Skip to content

Commit

Permalink
Fix string bug.
Browse files Browse the repository at this point in the history
  • Loading branch information
gchallen committed Jun 9, 2021
1 parent 07abcf2 commit e572a53
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .idea/detekt.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ tasks.withType<JavaCompile> {
tasks.withType<Test> {
useJUnitPlatform()
enableAssertions = true
jvmArgs("-ea", "-Xmx1G", "-Xss256k")
jvmArgs("-ea", "-Xmx1G", "-Xss256k", "-Dfile.encoding=UTF-8")
}
tasks.dependencyUpdates {
fun String.isNonStable() = !(
Expand Down
3 changes: 2 additions & 1 deletion src/main/kotlin/generators/Type.kt
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,8 @@ class CharGenerator(random: Random) : TypeGenerators<Char>(random) {

class StringGenerator(random: Random) : TypeGenerators<String>(random) {

override val simple = setOf("t", "gwa", "8 circle", "").values(ZeroComplexity)
override val simple =
setOf("t", "gwa", "8 circle", "").map { it.toCharArray() }.map { String(it) }.toSet().values(ZeroComplexity)
override val edge = listOf<String?>(null).values(ZeroComplexity)
override fun random(complexity: Complexity, runner: TestRunner?) = random(complexity, random).value(complexity)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,9 @@ class TestJavaExamples : StringSpec(
examples.java.receiver.actuallystatic.Correct::class.java.also {
"${it.testName()}" { it.test() }
}
examples.java.noreceiver.twostringequality.Correct::class.java.also {
"${it.testName()}" { it.test() }
}
examples.java.receiver.timeouttest.Correct::class.java.also {
"${it.testName()}" {
val runnable = object : Runnable {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package examples.java.noreceiver.twostringequality;

public class Correct {
public static boolean equals(String first, String second) {
assert first != null;
assert second != null;
return first.equals(second);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package examples.java.noreceiver.twostringequality;

@SuppressWarnings("StringEquality")
public class Incorrect0 {
public static boolean equals(String first, String second) {
assert first != null;
assert second != null;
return first == second;
}
}

0 comments on commit e572a53

Please sign in to comment.