diff --git a/src/test/java/com/cottagesystems/convert/ConvertJavaToPythonTest.java b/src/test/java/com/cottagesystems/convert/ConvertJavaToPythonTest.java index e79129e..9cb3fbb 100644 --- a/src/test/java/com/cottagesystems/convert/ConvertJavaToPythonTest.java +++ b/src/test/java/com/cottagesystems/convert/ConvertJavaToPythonTest.java @@ -32,6 +32,11 @@ void testComments() throws ParseException { assertEquals("# bye ", converter.doConvert("/* bye */").replace("\n", "")); } + @Test + void testSlashSlashInString() throws ParseException { + assertEquals("x = 'https://autoplog.org/'", converter.doConvert("String x = \"https://autoplog.org/\";")); + } + @Test void testArithmeticOps() throws ParseException { assertEquals("-x * y + z / 2 - 5", converter.doConvert("-x*y+z/2-5")); @@ -119,5 +124,24 @@ void testSwitch() throws ParseException { " return result"); assertLinesMatch(expectedPython, Arrays.asList(converter.doConvert(javaProgram).split("\n+"))); } + + @Test + void testFullClassWithSlashSlashInString() throws ParseException { + String javaProgram = "package test;\n" + + "public class TestServletPWD {\n" + + " public static void main( String[] args ) {\n" + + " String vapurl= \"https://github.com/autoplot/dev/blob/master/demos/2024/20240907/kodalith.vap\";\n" + + " System.out.println(vapurl);\n" + + " }\n" + + "}"; + // Currently strips the class definition + List expectedPython = Arrays.asList("", + "def main(args):", + " vapurl = 'https://github.com/autoplot/dev/blob/master/demos/2024/20240907/kodalith.vap'", + " print(vapurl)", + "if __name__ == '__main__':", + " main([])"); + assertLinesMatch(expectedPython, Arrays.asList(converter.doConvert(javaProgram).split("\n+"))); + } }