This is the mail archive of the mailing list for the Mauve project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Unicode test fix.

I found some bugs in the gnu/testlet/java/io/Utf8Encoding/

Currently it tests decoding a bunch of illegal characters and expects a
CharConversionException. This is wrong. 

The decoding is done by an InputStreamReader, the read() method of which
is only declared to throw IOException. It could not be expected to throw
CharConversionException, since that's a NIO exception.

Looking at the JDK, it does neither; It doesn't seem to be specified,
but the JDK InputStreamReader defaults to replacing invalid characters.
(And that does seem like the better thing to do) So we shouldn't expect
an exception here, but rather a replacement character. (0xFFFD)

Here's a patch which changes this. Then the Sun JDK only fails on 3
tests. In those cases it returns 0 and not the replacement char. I fail
to see how that could be considered to be correct behaviour though, so
I'm leaving those in.

--- ../../mauve/mauve/gnu/testlet/java/io/Utf8Encoding/	1999-07-05 13:43:02.000000000 +0200
+++ gnu/testlet/java/io/Utf8Encoding/	2005-04-07 04:46:02.718902144 +0200
@@ -131,9 +131,7 @@
 	    reader = new InputStreamReader (in, "UTF8");
 	    c = ();
-	} catch (CharConversionException e) {
-	    flag = true;
+	    flag = (c == 0xFFFD); // Should be replacement char
 	} catch (Throwable t) {
 	    harness.debug (label + ": failed, threw "
 			   + t.getClass ().getName ()

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]