Esempio n. 1
0
        public virtual void TestEOF()
        {
            MyBufferedIndexInput input = new MyBufferedIndexInput(1024);

            // see that we can read all the bytes at one go:
            CheckReadBytes(input, (int)input.Length, 0);
            // go back and see that we can't read more than that, for small and
            // large overflows:
            int pos = (int)input.Length - 10;

            input.Seek(pos);
            CheckReadBytes(input, 10, pos);
            input.Seek(pos);
            try
            {
                CheckReadBytes(input, 11, pos);
                Assert.Fail("Block read past end of file");
            }
#pragma warning disable 168
            catch (IOException e)
#pragma warning restore 168
            {
                /* success */
            }
            input.Seek(pos);
            try
            {
                CheckReadBytes(input, 50, pos);
                Assert.Fail("Block read past end of file");
            }
#pragma warning disable 168
            catch (IOException e)
#pragma warning restore 168
            {
                /* success */
            }
            input.Seek(pos);
            try
            {
                CheckReadBytes(input, 100000, pos);
                Assert.Fail("Block read past end of file");
            }
#pragma warning disable 168
            catch (IOException e)
#pragma warning restore 168
            {
                /* success */
            }
        }
Esempio n. 2
0
        public virtual void  TestEOF()
        {
            MyBufferedIndexInput input = new MyBufferedIndexInput(1024);

            // see that we can read all the bytes at one go:
            CheckReadBytes(input, (int)input.Length(), 0);
            // go back and see that we can't read more than that, for small and
            // large overflows:
            int pos = (int)input.Length() - 10;

            input.Seek(pos);
            CheckReadBytes(input, 10, pos);

            input.Seek(pos);
            Assert.Throws <System.IO.IOException>(() => CheckReadBytes(input, 11, pos), "Block read past end of file");

            input.Seek(pos);
            Assert.Throws <System.IO.IOException>(() => CheckReadBytes(input, 50, pos), "Block read past end of file");

            input.Seek(pos);
            Assert.Throws <System.IO.IOException>(() => CheckReadBytes(input, 100000, pos), "Block read past end of file");
        }
		public virtual void  TestEOF()
		{
			MyBufferedIndexInput input = new MyBufferedIndexInput(1024);
			// see that we can read all the bytes at one go:
			CheckReadBytes(input, (int) input.Length(), 0);
			// go back and see that we can't read more than that, for small and
			// large overflows:
			int pos = (int) input.Length() - 10;
			input.Seek(pos);
			CheckReadBytes(input, 10, pos);
			input.Seek(pos);
			try
			{
				CheckReadBytes(input, 11, pos);
				Assert.Fail("Block read past end of file");
			}
			catch (System.IO.IOException)
			{
				/* success */
			}
			input.Seek(pos);
			try
			{
				CheckReadBytes(input, 50, pos);
				Assert.Fail("Block read past end of file");
			}
			catch (System.IO.IOException)
			{
				/* success */
			}
			input.Seek(pos);
			try
			{
				CheckReadBytes(input, 100000, pos);
				Assert.Fail("Block read past end of file");
			}
			catch (System.IO.IOException)
			{
				/* success */
			}
		}