예제 #1
0
 /// <summary>
 /// Resets this to an empty file. </summary>
 public virtual void Reset()
 {
     currentBuffer      = null;
     currentBufferIndex = -1;
     bufferPosition     = 0;
     bufferStart        = 0;
     bufferLength       = 0;
     file.Length        = 0;
     crc.Reset();
 }
예제 #2
0
 /// <summary>
 /// Resets this to an empty file. </summary>
 public virtual void Reset()
 {
     CurrentBuffer      = null;
     CurrentBufferIndex = -1;
     BufferPosition     = 0;
     BufferStart        = 0;
     BufferLength       = 0;
     File.Length        = 0;
     Crc.Reset();
 }
예제 #3
0
        public virtual void TestRandom()
        {
            IChecksum c1         = new CRC32();
            IChecksum c2         = new BufferedChecksum(new CRC32());
            int       iterations = AtLeast(10000);

            for (int i = 0; i < iterations; i++)
            {
                switch (Random.Next(4))
                {
                case 0:
                    // update(byte[], int, int)
                    int    length = Random.Next(1024);
                    byte[] bytes  = new byte[length];
                    Random.NextBytes(bytes);
                    c1.Update(bytes, 0, bytes.Length);
                    c2.Update(bytes, 0, bytes.Length);
                    break;

                case 1:
                    // update(int)
                    int b = Random.Next(256);
                    c1.Update(b);
                    c2.Update(b);
                    break;

                case 2:
                    // reset()
                    c1.Reset();
                    c2.Reset();
                    break;

                case 3:
                    // getValue()
                    Assert.AreEqual(c1.Value, c2.Value);
                    break;
                }
            }
            Assert.AreEqual(c1.Value, c2.Value);
        }
예제 #4
0
        public virtual void TestRandom()
        {
            IChecksum c1 = new CRC32();
            IChecksum c2 = new BufferedChecksum(new CRC32());
            int iterations = AtLeast(10000);
            for (int i = 0; i < iterations; i++)
            {
                switch (Random().Next(4))
                {
                    case 0:
                        // update(byte[], int, int)
                        int length = Random().Next(1024);
                        byte[] bytes = new byte[length];
                        Random().NextBytes(bytes);
                        c1.Update(bytes, 0, bytes.Length);
                        c2.Update(bytes, 0, bytes.Length);
                        break;

                    case 1:
                        // update(int)
                        int b = Random().Next(256);
                        c1.Update(b);
                        c2.Update(b);
                        break;

                    case 2:
                        // reset()
                        c1.Reset();
                        c2.Reset();
                        break;

                    case 3:
                        // getValue()
                        Assert.AreEqual(c1.Value, c2.Value);
                        break;
                }
            }
            Assert.AreEqual(c1.Value, c2.Value);
        }