From: bdemsky Date: Thu, 26 Oct 2006 20:51:41 +0000 (+0000) Subject: Bug fix X-Git-Tag: preEdgeChange~803 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=310cd7f0149f9c2f7443336bebbf2b0d7acfb005;p=IRC.git Bug fix New test cases FileLength functionality in File.java --- diff --git a/Robust/src/ClassLibrary/File.java b/Robust/src/ClassLibrary/File.java new file mode 100644 index 00000000..af9ce815 --- /dev/null +++ b/Robust/src/ClassLibrary/File.java @@ -0,0 +1,17 @@ +public class File { + String path; + + public File(String path) { + this.path=path; + } + + String getPath() { + return path; + } + + long length() { + return nativeLength(path.getBytes()); + } + + private static native long nativeLength(byte[] pathname); +} diff --git a/Robust/src/ClassLibrary/FileInputStream.java b/Robust/src/ClassLibrary/FileInputStream.java index 0a17f998..2de45c83 100644 --- a/Robust/src/ClassLibrary/FileInputStream.java +++ b/Robust/src/ClassLibrary/FileInputStream.java @@ -5,6 +5,10 @@ public class FileInputStream { fd=nativeOpen(pathname.getBytes()); } + public FileInputStream(File path) { + fd=nativeOpen(path.getPath().getBytes()); + } + private static native int nativeOpen(byte[] filename); private static native int nativeRead(int fd, byte[] array, int numBytes); private static native void nativeClose(int fd); diff --git a/Robust/src/ClassLibrary/FileOutputStream.java b/Robust/src/ClassLibrary/FileOutputStream.java index eea7eef9..04c589c3 100644 --- a/Robust/src/ClassLibrary/FileOutputStream.java +++ b/Robust/src/ClassLibrary/FileOutputStream.java @@ -5,6 +5,10 @@ public class FileOutputStream { fd=nativeOpen(pathname.getBytes()); } + public FileOutputStream(File path) { + fd=nativeOpen(path.getPath().getBytes()); + } + private static native int nativeOpen(byte[] filename); private static native void nativeWrite(int fd, byte[] array); private static native void nativeClose(int fd); diff --git a/Robust/src/ClassLibrary/StringBuffer.java b/Robust/src/ClassLibrary/StringBuffer.java index e47a7e1e..b06fd706 100644 --- a/Robust/src/ClassLibrary/StringBuffer.java +++ b/Robust/src/ClassLibrary/StringBuffer.java @@ -5,7 +5,7 @@ public class StringBuffer { // private static final int DEFAULTSIZE=16; public StringBuffer(String str) { - value=new char[str.value+16];//16 is DEFAULTSIZE + value=new char[str.count+16];//16 is DEFAULTSIZE count=str.count; offset=0; for(int i=0;i___length___; + char* filename= (((char *)& ao->___length___)+sizeof(int)); + struct stat st; + stat(filename, &st); + return st.st_size; +} diff --git a/Robust/src/Tests/DoTests b/Robust/src/Tests/DoTests index 347206db..33233e51 100755 --- a/Robust/src/Tests/DoTests +++ b/Robust/src/Tests/DoTests @@ -12,3 +12,6 @@ dotest Test Test.java dotest virtualcalltest virtualcalltest.java dotest IncTest IncTest.java dotest CommandLineTest CommandLineTest.java hello hi +dotest WriteFile WriteFile.java +dotest ReadFile ReadFile.java +dotest FileLength FileLength.java diff --git a/Robust/src/Tests/FileLength.java b/Robust/src/Tests/FileLength.java new file mode 100644 index 00000000..de258cdb --- /dev/null +++ b/Robust/src/Tests/FileLength.java @@ -0,0 +1,10 @@ +public class FileLength { + public static void main(String []str) { + String filename="testfile000"; + File fi=new File(filename); + long length=fi.length(); + String st=String.valueOf((int)length); + System.printString(st); + } + +} diff --git a/Robust/src/Tests/WriteFile.java b/Robust/src/Tests/WriteFile.java new file mode 100644 index 00000000..d31430bf --- /dev/null +++ b/Robust/src/Tests/WriteFile.java @@ -0,0 +1,10 @@ +public class WriteFile { + public static void main(String []str) { + String filename="testfile000"; + FileOutputStream fos=new FileOutputStream(filename); + String st=new String("adsasdasd"); + fos.write(st.getBytes()); + fos.close(); + } + +} diff --git a/Robust/src/Tests/output/FileLength.output.goal b/Robust/src/Tests/output/FileLength.output.goal new file mode 100644 index 00000000..f11c82a4 --- /dev/null +++ b/Robust/src/Tests/output/FileLength.output.goal @@ -0,0 +1 @@ +9 \ No newline at end of file diff --git a/Robust/src/Tests/output/ReadFile.output.goal b/Robust/src/Tests/output/ReadFile.output.goal new file mode 100644 index 00000000..107d5f91 --- /dev/null +++ b/Robust/src/Tests/output/ReadFile.output.goal @@ -0,0 +1 @@ +adsasdasd \ No newline at end of file diff --git a/Robust/src/Tests/output/WriteFile.output.goal b/Robust/src/Tests/output/WriteFile.output.goal new file mode 100644 index 00000000..e69de29b