commit d00a28fe2d7d451b2c4e3d033e259e5c786294e6 Author: Karsten Loesing karsten.loesing@gmx.net Date: Fri Jul 14 11:19:45 2017 +0200
Add test for #22912. --- .../torproject/descriptor/impl/TorperfResultImplTest.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
diff --git a/src/test/java/org/torproject/descriptor/impl/TorperfResultImplTest.java b/src/test/java/org/torproject/descriptor/impl/TorperfResultImplTest.java index f648c7b..d9e134d 100644 --- a/src/test/java/org/torproject/descriptor/impl/TorperfResultImplTest.java +++ b/src/test/java/org/torproject/descriptor/impl/TorperfResultImplTest.java @@ -6,12 +6,14 @@ package org.torproject.descriptor.impl; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue;
import org.torproject.descriptor.Descriptor; import org.torproject.descriptor.DescriptorParseException;
import org.junit.Test;
+import java.nio.charset.StandardCharsets; import java.util.List;
public class TorperfResultImplTest { @@ -63,6 +65,19 @@ public class TorperfResultImplTest { ((TorperfResultImpl)(result.get(2))).getAnnotations().size()); }
+ @Test + public void testTrailingNewlinesRetained() throws Exception { + byte[] asciiBytes = (torperfAnnotation + input + + torperfAnnotation + input).getBytes("US-ASCII"); + List<Descriptor> result = TorperfResultImpl.parseTorperfResults( + asciiBytes, null); + for (Descriptor descriptor : result) { + assertTrue("Expected trailing newline.", + new String(descriptor.getRawDescriptorBytes(), + StandardCharsets.US_ASCII).endsWith("\n")); + } + } + private static long[] deciles = new long[] { 1441065602980L, 1441065603030L, 1441065603090L, 1441065603120L, 1441065603230L, 1441065603250L, 1441065603310L, 1441065603370L,