public override void Reset() { input.Reset(); buffer.reset(input); replacement = null; inputOff = 0; }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public void test() throws Exception public virtual void test() { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final int ITERS = atLeast(1000); int ITERS = atLeast(1000); RollingCharBuffer buffer = new RollingCharBuffer(); Random random = random(); for (int iter = 0; iter < ITERS; iter++) { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final int stringLen = random.nextBoolean() ? random.nextInt(50) : random.nextInt(20000); int stringLen = random.nextBoolean() ? random.Next(50) : random.Next(20000); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final String s; string s; if (stringLen == 0) { s = ""; } else { s = TestUtil.randomUnicodeString(random, stringLen); } if (VERBOSE) { Console.WriteLine("\nTEST: iter=" + iter + " s.length()=" + s.Length); } buffer.reset(new StringReader(s)); int nextRead = 0; int availCount = 0; while (nextRead < s.Length) { if (VERBOSE) { Console.WriteLine(" cycle nextRead=" + nextRead + " avail=" + availCount); } if (availCount == 0 || random.nextBoolean()) { // Read next char if (VERBOSE) { Console.WriteLine(" new char"); } assertEquals(s[nextRead], buffer.get(nextRead)); nextRead++; availCount++; } else if (random.nextBoolean()) { // Read previous char int pos = TestUtil.Next(random, nextRead - availCount, nextRead - 1); if (VERBOSE) { Console.WriteLine(" old char pos=" + pos); } assertEquals(s[pos], buffer.get(pos)); } else { // Read slice int length; if (availCount == 1) { length = 1; } else { length = TestUtil.Next(random, 1, availCount); } int start; if (length == availCount) { start = nextRead - availCount; } else { start = nextRead - availCount + random.Next(availCount - length); } if (VERBOSE) { Console.WriteLine(" slice start=" + start + " length=" + length); } assertEquals(s.Substring(start, length), new string(buffer.get(start, length))); } if (availCount > 0 && random.Next(20) == 17) { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final int toFree = random.nextInt(availCount); int toFree = random.Next(availCount); if (VERBOSE) { Console.WriteLine(" free " + toFree + " (avail=" + (availCount - toFree) + ")"); } buffer.freeBefore(nextRead - (availCount - toFree)); availCount -= toFree; } } } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public void test() throws Exception public virtual void test() { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final int ITERS = atLeast(1000); int ITERS = atLeast(1000); RollingCharBuffer buffer = new RollingCharBuffer(); Random random = random(); for (int iter = 0;iter < ITERS;iter++) { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final int stringLen = random.nextBoolean() ? random.nextInt(50) : random.nextInt(20000); int stringLen = random.nextBoolean() ? random.Next(50) : random.Next(20000); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final String s; string s; if (stringLen == 0) { s = ""; } else { s = TestUtil.randomUnicodeString(random, stringLen); } if (VERBOSE) { Console.WriteLine("\nTEST: iter=" + iter + " s.length()=" + s.Length); } buffer.reset(new StringReader(s)); int nextRead = 0; int availCount = 0; while (nextRead < s.Length) { if (VERBOSE) { Console.WriteLine(" cycle nextRead=" + nextRead + " avail=" + availCount); } if (availCount == 0 || random.nextBoolean()) { // Read next char if (VERBOSE) { Console.WriteLine(" new char"); } assertEquals(s[nextRead], buffer.get(nextRead)); nextRead++; availCount++; } else if (random.nextBoolean()) { // Read previous char int pos = TestUtil.Next(random, nextRead - availCount, nextRead - 1); if (VERBOSE) { Console.WriteLine(" old char pos=" + pos); } assertEquals(s[pos], buffer.get(pos)); } else { // Read slice int length; if (availCount == 1) { length = 1; } else { length = TestUtil.Next(random, 1, availCount); } int start; if (length == availCount) { start = nextRead - availCount; } else { start = nextRead - availCount + random.Next(availCount - length); } if (VERBOSE) { Console.WriteLine(" slice start=" + start + " length=" + length); } assertEquals(s.Substring(start, length), new string(buffer.get(start, length))); } if (availCount > 0 && random.Next(20) == 17) { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final int toFree = random.nextInt(availCount); int toFree = random.Next(availCount); if (VERBOSE) { Console.WriteLine(" free " + toFree + " (avail=" + (availCount - toFree) + ")"); } buffer.freeBefore(nextRead - (availCount - toFree)); availCount -= toFree; } } } }