예제 #1
0
        public virtual void  TestHugeFile()
        {
            DenseRAMFile f = new DenseRAMFile();
            // output part
            RAMOutputStream out_Renamed = new RAMOutputStream(f);

            byte[] b1 = new byte[RAMOutputStream.BUFFER_SIZE_ForNUnit];
            byte[] b2 = new byte[RAMOutputStream.BUFFER_SIZE_ForNUnit / 3];
            for (int i = 0; i < b1.Length; i++)
            {
                b1[i] = (byte)(i & 0x0007F);
            }
            for (int i = 0; i < b2.Length; i++)
            {
                b2[i] = (byte)(i & 0x0003F);
            }
            long n = 0;

            Assert.AreEqual(n, out_Renamed.Length(), "output length must match");
            while (n <= MAX_VALUE - b1.Length)
            {
                out_Renamed.WriteBytes(b1, 0, b1.Length);
                out_Renamed.Flush();
                n += b1.Length;
                Assert.AreEqual(n, out_Renamed.Length(), "output length must match");
            }
            //System.out.println("after writing b1's, length = "+out.length()+" (MAX_VALUE="+MAX_VALUE+")");
            int  m = b2.Length;
            long L = 12;

            for (int j = 0; j < L; j++)
            {
                for (int i = 0; i < b2.Length; i++)
                {
                    b2[i]++;
                }
                out_Renamed.WriteBytes(b2, 0, m);
                out_Renamed.Flush();
                n += m;
                Assert.AreEqual(n, out_Renamed.Length(), "output length must match");
            }
            out_Renamed.Close();
            // input part
            RAMInputStream in_Renamed = new RAMInputStream(f);

            Assert.AreEqual(n, in_Renamed.Length(), "input length must match");
            //System.out.println("input length = "+in.length()+" % 1024 = "+in.length()%1024);
            for (int j = 0; j < L; j++)
            {
                long loc = n - (L - j) * m;
                in_Renamed.Seek(loc / 3);
                in_Renamed.Seek(loc);
                for (int i = 0; i < m; i++)
                {
                    byte bt       = in_Renamed.ReadByte();
                    byte expected = (byte)(1 + j + (i & 0x0003F));
                    Assert.AreEqual(expected, bt, "must read same value that was written! j=" + j + " i=" + i);
                }
            }
        }
예제 #2
0
        public virtual void TestHugeFile()
        {
            var f = new DenseRAMFile();
            // output part
            var @out = new RAMOutputStream(f);
            var b1   = new byte[RAMOutputStream.BUFFER_SIZE];
            var b2   = new byte[RAMOutputStream.BUFFER_SIZE / 3];

            for (int i = 0; i < b1.Length; i++)
            {
                b1[i] = (byte)(sbyte)(i & 0x0007F);
            }
            for (int i = 0; i < b2.Length; i++)
            {
                b2[i] = (byte)(sbyte)(i & 0x0003F);
            }
            long n = 0;

            Assert.AreEqual(n, @out.Length, "output length must match");
            while (n <= MAX_VALUE - b1.Length)
            {
                @out.WriteBytes(b1, 0, b1.Length);
                @out.Flush();
                n += b1.Length;
                Assert.AreEqual(n, @out.Length, "output length must match");
            }
            //System.out.println("after writing b1's, length = "+out.Length()+" (MAX_VALUE="+MAX_VALUE+")");
            int  m = b2.Length;
            long L = 12;

            for (int j = 0; j < L; j++)
            {
                for (int i = 0; i < b2.Length; i++)
                {
                    b2[i]++;
                }
                @out.WriteBytes(b2, 0, m);
                @out.Flush();
                n += m;
                Assert.AreEqual(n, @out.Length, "output length must match");
            }
            @out.Dispose();
            // input part
            var @in = new RAMInputStream("testcase", f);

            Assert.AreEqual(n, @in.Length, "input length must match");
            //System.out.println("input length = "+in.Length()+" % 1024 = "+in.Length()%1024);
            for (int j = 0; j < L; j++)
            {
                long loc = n - (L - j) * m;
                @in.Seek(loc / 3);
                @in.Seek(loc);
                for (int i = 0; i < m; i++)
                {
                    var bt       = (sbyte)@in.ReadByte();
                    var expected = (sbyte)(1 + j + (i & 0x0003F));
                    Assert.AreEqual(expected, bt, "must read same value that was written! j=" + j + " i=" + i);
                }
            }
        }
예제 #3
0
		public virtual void  TestHugeFile()
		{
			DenseRAMFile f = new DenseRAMFile();
			// output part
			RAMOutputStream out_Renamed = new RAMOutputStream(f);
			byte[] b1 = new byte[RAMOutputStream.BUFFER_SIZE_ForNUnitTest];
			byte[] b2 = new byte[RAMOutputStream.BUFFER_SIZE_ForNUnitTest / 3];
			for (int i = 0; i < b1.Length; i++)
			{
				b1[i] = (byte) (i & 0x0007F);
			}
			for (int i = 0; i < b2.Length; i++)
			{
				b2[i] = (byte) (i & 0x0003F);
			}
			long n = 0;
			Assert.AreEqual(n, out_Renamed.Length(), "output length must match");
			while (n <= MAX_VALUE - b1.Length)
			{
				out_Renamed.WriteBytes(b1, 0, b1.Length);
				out_Renamed.Flush();
				n += b1.Length;
				Assert.AreEqual(n, out_Renamed.Length(), "output length must match");
			}
			//System.out.println("after writing b1's, length = "+out.length()+" (MAX_VALUE="+MAX_VALUE+")");
			int m = b2.Length;
			long L = 12;
			for (int j = 0; j < L; j++)
			{
				for (int i = 0; i < b2.Length; i++)
				{
					b2[i]++;
				}
				out_Renamed.WriteBytes(b2, 0, m);
				out_Renamed.Flush();
				n += m;
				Assert.AreEqual(n, out_Renamed.Length(), "output length must match");
			}
			out_Renamed.Close();
			// input part
			RAMInputStream in_Renamed = RAMInputStream.RAMInputStream_ForNUnitTest(f);
			Assert.AreEqual(n, in_Renamed.Length(), "input length must match");
			//System.out.println("input length = "+in.length()+" % 1024 = "+in.length()%1024);
			for (int j = 0; j < L; j++)
			{
				long loc = n - (L - j) * m;
				in_Renamed.Seek(loc / 3);
				in_Renamed.Seek(loc);
				for (int i = 0; i < m; i++)
				{
					byte bt = in_Renamed.ReadByte();
					byte expected = (byte) (1 + j + (i & 0x0003F));
					Assert.AreEqual(expected, bt, "must read same value that was written! j=" + j + " i=" + i);
				}
			}
		}
예제 #4
0
 public virtual void TestHugeFile()
 {
     var f = new DenseRAMFile();
     // output part
     var @out = new RAMOutputStream(f);
     var b1 = new byte[RAMOutputStream.BUFFER_SIZE];
     var b2 = new byte[RAMOutputStream.BUFFER_SIZE / 3];
     for (int i = 0; i < b1.Length; i++)
     {
         b1[i] = (byte)(sbyte)(i & 0x0007F);
     }
     for (int i = 0; i < b2.Length; i++)
     {
         b2[i] = (byte)(sbyte)(i & 0x0003F);
     }
     long n = 0;
     Assert.AreEqual(n, @out.Length, "output length must match");
     while (n <= MAX_VALUE - b1.Length)
     {
         @out.WriteBytes(b1, 0, b1.Length);
         @out.Flush();
         n += b1.Length;
         Assert.AreEqual(n, @out.Length, "output length must match");
     }
     //System.out.println("after writing b1's, length = "+out.Length()+" (MAX_VALUE="+MAX_VALUE+")");
     int m = b2.Length;
     long L = 12;
     for (int j = 0; j < L; j++)
     {
         for (int i = 0; i < b2.Length; i++)
         {
             b2[i]++;
         }
         @out.WriteBytes(b2, 0, m);
         @out.Flush();
         n += m;
         Assert.AreEqual(n, @out.Length, "output length must match");
     }
     @out.Dispose();
     // input part
     var @in = new RAMInputStream("testcase", f);
     Assert.AreEqual(n, @in.Length(), "input length must match");
     //System.out.println("input length = "+in.Length()+" % 1024 = "+in.Length()%1024);
     for (int j = 0; j < L; j++)
     {
         long loc = n - (L - j) * m;
         @in.Seek(loc / 3);
         @in.Seek(loc);
         for (int i = 0; i < m; i++)
         {
             var bt = (sbyte)@in.ReadByte();
             var expected = (sbyte)(1 + j + (i & 0x0003F));
             Assert.AreEqual(expected, bt, "must read same value that was written! j=" + j + " i=" + i);
         }
     }
 }