Skip to content

Commit

Permalink
Merge pull request #86 from privat/test-force-utf8
Browse files Browse the repository at this point in the history
Tests: force utf8
  • Loading branch information
dullin authored Aug 22, 2024
2 parents 6e0541e + c8f74d9 commit a94fdec
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
13 changes: 11 additions & 2 deletions src/rars/api/Program.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;

/**
Expand Down Expand Up @@ -203,14 +204,22 @@ public Simulator.Reason simulate() throws SimulationException {
* @return converts the bytes sent to stdout into a string (resets to "" when setup is called)
*/
public String getSTDOUT(){
return stdout.toString();
try {
return stdout.toString("UTF-8");
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
}

/**
* @return converts the bytes sent to stderr into a string (resets to "" when setup is called)
*/
public String getSTDERR(){
return stderr.toString();
try {
return stderr.toString("UTF-8");
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
}

/**
Expand Down
2 changes: 1 addition & 1 deletion test/RarsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public static String run(String path, Program p){
// This is just a temporary solution that should work for the tests I want to write
p.getOptions().selfModifyingCode = false;
try {
BufferedReader br = new BufferedReader(new FileReader(path));
BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(path), "UTF-8"));
String line = br.readLine();
while(line != null){
if (line.startsWith("#error on lines:")) {
Expand Down

0 comments on commit a94fdec

Please sign in to comment.