mirror of
https://github.com/esp8266/Arduino.git
synced 2025-07-30 16:24:09 +03:00
Adding some test cases for the pre-processor. (Total hack, requires copying and pasting code from the actual app source into another file and running a shell script, but it's better than nothing.)
This commit is contained in:
44
app/preproc/test/test_PdePreprocessor.java
Normal file
44
app/preproc/test/test_PdePreprocessor.java
Normal file
@ -0,0 +1,44 @@
|
||||
import java.io.Reader;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.oroinc.text.regex.*;
|
||||
|
||||
public class test_PdePreprocessor {
|
||||
/************************************************************************
|
||||
Paste from PdePreprocessor.java: strip(), collapseBraces(), prototypes()
|
||||
************************************************************************/
|
||||
|
||||
public static void main(String[] args) {
|
||||
if (args.length < 2) {
|
||||
System.err.println("Usage: PreProc [strip|prototypes] <file>");
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
test_PdePreprocessor preproc = new test_PdePreprocessor();
|
||||
Reader reader = new FileReader(new File(args[1]));
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
char[] buf = new char[1024];
|
||||
int n;
|
||||
|
||||
while ((n = reader.read(buf, 0, 1024)) != -1) {
|
||||
buffer.append(buf, 0, n);
|
||||
}
|
||||
|
||||
if (args[0].equals("strip")) {
|
||||
System.out.print(preproc.strip(buffer.toString()));
|
||||
} else {
|
||||
List prototypes = preproc.prototypes(buffer.toString());
|
||||
for (int i = 0; i < prototypes.size(); i++) {
|
||||
System.out.println((String) prototypes.get(i));
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.err.println(e);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user