Author: nextgens
Date: 2008-08-17 15:56:16 +0000 (Sun, 17 Aug 2008)
New Revision: 21971
Modified:
trunk/freenet/test/freenet/support/io/LineReadingInputStreamTest.java
Log:
bug #2501: probably off by one in between both implementations: add a
regression test
Modified: trunk/freenet/test/freenet/support/io/LineReadingInputStreamTest.java
===================================================================
--- trunk/freenet/test/freenet/support/io/LineReadingInputStreamTest.java
2008-08-17 15:54:31 UTC (rev 21970)
+++ trunk/freenet/test/freenet/support/io/LineReadingInputStreamTest.java
2008-08-17 15:56:16 UTC (rev 21971)
@@ -21,6 +21,8 @@
};
public static final String STRESSED_LINE = "\n\u0114\n";
+ public static final String LENGTH_CHECKING_LINE = "a\u0000a\n";
+ public static final int LENGTH_CHECKING_LINE_LF = 3;
public static final int MAX_LENGTH = 128;
public static final int BUFFER_SIZE = 128;
@@ -47,10 +49,10 @@
assertNull(instance.readLineWithoutMarking(0, BUFFER_SIZE,
false));
// is it throwing?
- is = new ByteArrayInputStream("aaa\na\n".getBytes());
+ is = new ByteArrayInputStream(LENGTH_CHECKING_LINE.getBytes());
instance = new LineReadingInputStream(is);
try {
- instance.readLineWithoutMarking(2, BUFFER_SIZE, true);
+ instance.readLineWithoutMarking(LENGTH_CHECKING_LINE_LF
- 1, BUFFER_SIZE, true);
fail();
} catch (TooLongException e) {}
}
@@ -77,10 +79,10 @@
assertNull(instance.readLine(0, BUFFER_SIZE, false));
// is it throwing?
- is = new ByteArrayInputStream("aaa\na\n".getBytes());
+ is = new ByteArrayInputStream(LENGTH_CHECKING_LINE.getBytes());
instance = new LineReadingInputStream(is);
try {
- instance.readLine(2, BUFFER_SIZE, true);
+ instance.readLine(LENGTH_CHECKING_LINE_LF - 1,
BUFFER_SIZE, true);
fail();
} catch (TooLongException e) {}
}