Esempio n. 1
0
        public virtual void TestSkip()
        {
            Init(32, 15);
            Copy(2, 2);
            Insert("ab");
            Insert("cd");
            Copy(4, 4);
            Copy(0, 2);
            Insert("efg");
            AssertValidState();
            for (int p = 0; p < data.Length; p++)
            {
                byte[] act = new byte[data.Length];
                System.Array.Copy(data, 0, act, 0, p);
                DeltaStream @in = Open();
                IOUtil.SkipFully(@in, p);
                NUnit.Framework.Assert.AreEqual(data.Length - p, @in.Read(act, p, data.Length - p
                                                                          ));
                NUnit.Framework.Assert.AreEqual(-1, @in.Read());
                NUnit.Framework.Assert.IsTrue(Arrays.Equals(data, act), "skipping " + p);
            }
            // Skip all the way to the end should still recognize EOF.
            DeltaStream in_1 = Open();

            IOUtil.SkipFully(in_1, data.Length);
            NUnit.Framework.Assert.AreEqual(-1, in_1.Read());
            NUnit.Framework.Assert.AreEqual(0, in_1.Skip(1));
            // Skip should not open the base as we move past it, but it
            // will open when we need to start copying data from it.
            bool[] opened = new bool[1];
            in_1 = new _DeltaStream_180(this, opened, new ByteArrayInputStream(delta));
            IOUtil.SkipFully(in_1, 7);
            NUnit.Framework.Assert.IsFalse(opened[0], "not yet open");
            NUnit.Framework.Assert.AreEqual(data[7], in_1.Read());
            NUnit.Framework.Assert.IsTrue(opened[0], "now open");
        }
Esempio n. 2
0
		public virtual void TestSkip()
		{
			Init(32, 15);
			Copy(2, 2);
			Insert("ab");
			Insert("cd");
			Copy(4, 4);
			Copy(0, 2);
			Insert("efg");
			AssertValidState();
			for (int p = 0; p < data.Length; p++)
			{
				byte[] act = new byte[data.Length];
				System.Array.Copy(data, 0, act, 0, p);
				DeltaStream @in = Open();
				IOUtil.SkipFully(@in, p);
				NUnit.Framework.Assert.AreEqual(data.Length - p, @in.Read(act, p, data.Length - p
					));
				NUnit.Framework.Assert.AreEqual(-1, @in.Read());
				NUnit.Framework.Assert.IsTrue(Arrays.Equals(data, act), "skipping " + p);
			}
			// Skip all the way to the end should still recognize EOF.
			DeltaStream in_1 = Open();
			IOUtil.SkipFully(in_1, data.Length);
			NUnit.Framework.Assert.AreEqual(-1, in_1.Read());
			NUnit.Framework.Assert.AreEqual(0, in_1.Skip(1));
			// Skip should not open the base as we move past it, but it
			// will open when we need to start copying data from it.
			bool[] opened = new bool[1];
			in_1 = new _DeltaStream_180(this, opened, new ByteArrayInputStream(delta));
			IOUtil.SkipFully(in_1, 7);
			NUnit.Framework.Assert.IsFalse(opened[0], "not yet open");
			NUnit.Framework.Assert.AreEqual(data[7], in_1.Read());
			NUnit.Framework.Assert.IsTrue(opened[0], "now open");
		}