From ec18c5eb43c935537ed6080f5146477aa1e741bd Mon Sep 17 00:00:00 2001 From: Michael Langowski Date: Sat, 28 Sep 2024 14:14:11 +0200 Subject: [PATCH] enhancement: add newline when writing strings to output stream --- .../core/actions/AbstractActionImplementationProvider.java | 3 +-- .../src/test/java/at/ac/tuwien/kr/alpha/ActionsTest.java | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/alpha-core/src/main/java/at/ac/tuwien/kr/alpha/core/actions/AbstractActionImplementationProvider.java b/alpha-core/src/main/java/at/ac/tuwien/kr/alpha/core/actions/AbstractActionImplementationProvider.java index c23352dbd..aac6d0504 100644 --- a/alpha-core/src/main/java/at/ac/tuwien/kr/alpha/core/actions/AbstractActionImplementationProvider.java +++ b/alpha-core/src/main/java/at/ac/tuwien/kr/alpha/core/actions/AbstractActionImplementationProvider.java @@ -113,8 +113,7 @@ private ActionResultTerm> outputStreamWriteAction(List) input.get(1)).getObject(); - // TODO this needs some built-in conversion function - byte[] data = str.getBytes(); + byte[] data = (str + "\n").getBytes(); OutputStream dst = dstHandle.getStream(); try { dst.write(data); diff --git a/alpha-solver/src/test/java/at/ac/tuwien/kr/alpha/ActionsTest.java b/alpha-solver/src/test/java/at/ac/tuwien/kr/alpha/ActionsTest.java index c954bfb46..cf9d627f7 100644 --- a/alpha-solver/src/test/java/at/ac/tuwien/kr/alpha/ActionsTest.java +++ b/alpha-solver/src/test/java/at/ac/tuwien/kr/alpha/ActionsTest.java @@ -48,7 +48,7 @@ public void helloWorld() { Alpha alpha = alphaFactory.buildInstance(new SystemConfig()); InputProgram program = alpha.readProgramString(HELLO_WORLD); alpha.solve(program); - assertEquals("Hello World!", alphaFactory.getActionImplementationMock().getStdoutContent()); + assertEquals("Hello World!\n", alphaFactory.getActionImplementationMock().getStdoutContent()); } @Test @@ -100,7 +100,7 @@ public void writeToFile() { return funcTerm.getTerms().get(0) instanceof ConstantTerm && ((ConstantTerm) funcTerm.getTerms().get(0)).getObject().equals("ok"); }) ).size()); - assertEquals("Foo bar!", dummyFileContent.toString()); + assertEquals("Foo bar!\n", dummyFileContent.toString()); } }