* Patch for java.io tests
@ 2007-09-06 0:35 Steve McKay☄
0 siblings, 0 replies; only message in thread
From: Steve McKay☄ @ 2007-09-06 0:35 UTC (permalink / raw)
To: mauve-discuss; +Cc: Dan Kegel
[-- Attachment #1: Type: text/plain, Size: 270 bytes --]
Hi All,
Here's a patch for java.io related tests.
- A fix for java.io.BufferedWriter
The test was failing on windows and wine, the patch fixes that.
- A new test java.io.File.getAbsolutePath.
Feedback and comments are welcome.
--
Steve McKay <smckay@google.com>
[-- Attachment #2: java-io-00.patch --]
[-- Type: text/x-patch, Size: 5486 bytes --]
Index: gnu/testlet/java/io/BufferedWriter/Test.java
===================================================================
RCS file: /cvs/mauve/mauve/gnu/testlet/java/io/BufferedWriter/Test.java,v
retrieving revision 1.1
diff -u -r1.1 Test.java
--- gnu/testlet/java/io/BufferedWriter/Test.java 21 Nov 2002 20:48:21 -0000 1.1
+++ gnu/testlet/java/io/BufferedWriter/Test.java 6 Sep 2007 00:20:14 -0000
@@ -38,22 +38,37 @@
CharArrayWriter caw = new CharArrayWriter(24);
BufferedWriter bw = new BufferedWriter(caw, 12);
- String str = "I used to live right behind this super-cool bar in\n" +
- "Chicago called Lounge Ax. They have the best music of pretty\n" +
- "much anyplace in town with a great atmosphere and $1 Huber\n" +
- "on tap. I go to tons of shows there, even though I moved.\n";
+ String ls = System.getProperty("line.separator");
+
+ String str = "I used to live right behind this super-cool bar in" + ls +
+ "Chicago called Lounge Ax. They have the best music of pretty" + ls +
+ "much anyplace in town with a great atmosphere and $1 Huber" + ls +
+ "on tap. I go to tons of shows there, even though I moved." + ls;
char[] buf = new char[str.length()];
str.getChars(0, str.length(), buf, 0);
+
+ // "I use"
bw.write(str.substring(0, 5)); // write(String)
+
+ // check that the buffering is indeed happening, before we proceed
harness.check(caw.toCharArray().length, 0, "buffering/toCharArray");
+
+ // "d to liv"
bw.write(buf, 5, 8);
+
+ // "e right behi"
bw.write(buf, 13, 12);
+
+ // "n"
bw.write(buf[25]);
- bw.write(buf, 26, buf.length - 27);
- bw.newLine(); // newLine()
- bw.flush();
+
+ // rest of the string, minus the last EOL stuff
+ bw.write(buf, 26, buf.length - (26 + ls.length()));
+
+ bw.newLine(); // should write same value "line.separator" property
+ bw.flush();
bw.close();
String str2 = new String(caw.toCharArray());
Index: ChangeLog
===================================================================
RCS file: /cvs/mauve/mauve/ChangeLog,v
retrieving revision 1.2081
diff -u -r1.2081 ChangeLog
--- ChangeLog 24 Jul 2007 19:38:31 -0000 1.2081
+++ ChangeLog 6 Sep 2007 00:20:14 -0000
@@ -1,3 +1,9 @@
+2007-09-05 Steve McKay <smckay@google.com>
+
+ * gnu/testlet/java/io/BufferedWriter/Test.java:
+ Fix windows EOL handling.
+ * gnu/testlet/java/io/File/getAbsolutePath.java: Added
+
2007-07-24 Joshua Sumali <jsumali@redhat.com>
* gnu/testlet/java/util/logging/XMLFormatter/formatMessage.java:
Index: gnu/testlet/java/io/File/getAbsolutePath.java
===================================================================
RCS file: gnu/testlet/java/io/File/getAbsolutePath.java
diff -N gnu/testlet/java/io/File/getAbsolutePath.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/java/io/File/getAbsolutePath.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,79 @@
+// Copyright 2007 Google Inc. All Rights Reserved.
+// Written by Steve McKay <smckay@google.com>
+
+// This file is part of Mauve.
+
+// Mauve is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// Mauve is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with Mauve; see the file COPYING. If not, write to
+// the Free Software Foundation, 59 Temple Place - Suite 330,
+// Boston, MA 02111-1307, USA. */
+
+package gnu.testlet.java.io.File;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.io.File;
+
+public class getAbsolutePath implements Testlet
+{
+
+ public void test(TestHarness harness)
+ {
+ harness.checkPoint("Absolute path is returned unchanged.");
+ String dir = getAbsoluteTestPath();
+ File path = new File(dir);
+ harness.check(dir.equals(path.getAbsolutePath()));
+
+ harness.checkPoint("Empty path resolves to the current directory.");
+ String userDir = getCurrentDirectory();
+ dir = "";
+ path = new File(dir);
+ harness.check(userDir.equalsIgnoreCase(path.getAbsolutePath()));
+
+ harness.checkPoint("Relative path resolves against the current directory.");
+ userDir = getCurrentDirectory();
+ dir = getRelativeTestPath();
+ path = new File(dir);
+ String expected = userDir + File.separator + dir;
+ harness.check(expected.equalsIgnoreCase(path.getAbsolutePath()));
+ }
+
+ private static String getAbsoluteTestPath()
+ {
+
+ // TODO(smckay): a better way to handle this would be to return the first
+ // directory found under the first root file system (or the user.dir).
+ if (isWindows())
+ return "C:\\windows";
+
+ // "/etc" exists on most unices (Linux, BSD, OS X, et. al.)
+ return "/etc";
+ }
+
+ private static String getRelativeTestPath()
+ {
+ return "snarky";
+ }
+
+ private static String getCurrentDirectory()
+ {
+ return System.getProperty("user.dir");
+ }
+
+ private static boolean isWindows()
+ {
+ return System.getProperty("os.name").toLowerCase().contains("win");
+ }
+
+}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2007-09-06 0:35 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-09-06 0:35 Patch for java.io tests Steve McKay☄
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).