-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
♻️ [REFACTOR] 코드 결과 Input, Output 수정
- Loading branch information
Showing
6 changed files
with
13 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 0 additions & 75 deletions
75
src/test/java/swm_nm/morandi/domain/testDuring/service/RunCodeServiceTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,81 +1,6 @@ | ||
package swm_nm.morandi.domain.testDuring.service; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.transaction.annotation.Transactional; | ||
import swm_nm.morandi.domain.testDuring.dto.OutputDto; | ||
import swm_nm.morandi.domain.testDuring.dto.TestInputData; | ||
|
||
import java.io.BufferedReader; | ||
import java.io.FileNotFoundException; | ||
import java.io.FileReader; | ||
import java.io.IOException; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
@SpringBootTest | ||
class RunCodeServiceTest { | ||
|
||
@Autowired | ||
private RunCodeService runCodeService; | ||
@Test | ||
@Transactional | ||
void pythonRunCodeTest() throws Exception { | ||
// given | ||
TestInputData testInputData = new TestInputData(); | ||
testInputData.setCode(readFileContent("temp.py")); | ||
testInputData.setInput(null); | ||
testInputData.setLanguage("Python"); | ||
|
||
// when | ||
OutputDto outputDto = runCodeService.runCode(testInputData); | ||
|
||
// then | ||
assertThat(outputDto.getOutput()).isEqualTo("168\n"); | ||
} | ||
|
||
@Test | ||
@Transactional | ||
void cppRunCodeTest() throws Exception { | ||
// given | ||
TestInputData testInputData = new TestInputData(); | ||
testInputData.setCode(readFileContent("temp.cpp")); | ||
testInputData.setInput("1 2"); | ||
testInputData.setLanguage("Cpp"); | ||
|
||
// when | ||
OutputDto outputDto = runCodeService.runCode(testInputData); | ||
|
||
// then | ||
assertThat(outputDto.getOutput()).isEqualTo("3\n"); | ||
} | ||
|
||
@Test | ||
@Transactional | ||
void javaRunCodeTest() throws Exception { | ||
// given | ||
TestInputData testInputData = new TestInputData(); | ||
testInputData.setCode(readFileContent("Main.java")); | ||
testInputData.setInput("1 2"); | ||
testInputData.setLanguage("Java"); | ||
|
||
// when | ||
OutputDto outputDto = runCodeService.runCode(testInputData); | ||
|
||
// then | ||
assertThat(outputDto.getOutput()).isEqualTo("3\n"); | ||
} | ||
|
||
private String readFileContent(String filePath) throws IOException { | ||
try (BufferedReader br = new BufferedReader(new FileReader(filePath))) { | ||
StringBuilder content = new StringBuilder(); | ||
String line; | ||
while ((line = br.readLine()) != null) { | ||
content.append(line).append("\n"); | ||
} | ||
return content.toString(); | ||
} | ||
} | ||
} |