public void TestCheckArrayIsNotCompressed()
        {
            var data = new byte[100];

            new Random().NextBytes(data);

            Assert.IsFalse(CachedQlz.IsCompressed(data, 100));
        }
Example #2
0
 public static void ThreadSafeCompress(object lockObj, ref byte[] data, ref int numBytes)
 {
     lock (lockObj)
     {
         if (!CachedQlz.IsCompressed(data, numBytes))
         {
             CachedQlz.Compress(ref data, ref numBytes);
         }
     }
 }
        public void TestCheckArrayIsCompressed_NoIssues()
        {
            var numBytes = 5000;

            var text = Encoding.ASCII.GetBytes(TestCommon.RandomString(numBytes));

            CachedQlz.Compress(ref text, ref numBytes);

            Assert.IsTrue(CachedQlz.IsCompressed(text, numBytes));
        }
        public void TestCheckArrayIsCompressed_ImpossibleToCompress()
        {
            var numBytes = 100;

            var data = new byte[numBytes];

            new Random().NextBytes(data);
            CachedQlz.Compress(ref data, ref numBytes);

            Assert.IsTrue(CachedQlz.IsCompressed(data, numBytes));
        }
Example #5
0
 public static void ThreadSafeDecompress(object lockObj, ref byte[] data, int length, out int numBytes)
 {
     lock (lockObj)
     {
         if (CachedQlz.IsCompressed(data, length))
         {
             CachedQlz.Decompress(ref data, out numBytes);
         }
         else
         {
             numBytes = length;
         }
     }
 }