Skip to content

Commit 31bf8c2

Browse files
committed
fix gpath in generated test
1 parent 3cbcce0 commit 31bf8c2

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

core/src/main/kotlin/org/evomaster/core/output/service/ApiTestCaseWriter.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,8 @@ abstract class ApiTestCaseWriter : TestCaseWriter() {
275275
TODO should do check for when there are spaces in the field name
276276
TODO also need more tests to check all these edge cases
277277
*/
278-
format.isJavaOrKotlin() -> if (fieldPath.isEmpty()) "" else if (fieldPath.startsWith("'")) "$fieldPath." else "'$fieldPath'."
278+
// field path starts with [ is an array index, do not need additional quote
279+
format.isJavaOrKotlin() -> if (fieldPath.isEmpty()) "" else if (fieldPath.startsWith("'") || fieldPath.startsWith("[")) "$fieldPath." else "'$fieldPath'."
279280
format.isJavaScript() -> if (fieldPath.isEmpty()) "" else "${if (fieldPath.startsWith("[") || fieldPath.startsWith(".")) "" else "."}$fieldPath"
280281
format.isCsharp() -> if (fieldPath.isEmpty()) "" else "${if (fieldPath.startsWith("[")) "" else "."}$fieldPath"
281282
format.isPython() -> if (fieldPath.isEmpty()) "" else "${if (fieldPath.startsWith("[") || fieldPath.startsWith(".")) "" else "."}$fieldPath"

0 commit comments

Comments
 (0)