Ejemplo n.º 1
0
        public void ToStringAndName([Values] ZstandardLevel level)
        {
            ZstandardCodec codec = new ZstandardCodec(level);

            Assert.AreEqual("zstandard", codec.GetName());
            Assert.AreEqual($"zstandard[{(int)level}]", codec.ToString());
        }
Ejemplo n.º 2
0
        public void Equal([Values] ZstandardLevel level)
        {
            ZstandardCodec codec1 = new ZstandardCodec(level);
            ZstandardCodec codec2 = new ZstandardCodec(level);

            Assert.IsTrue(codec1.Equals(codec1));
            Assert.IsTrue(codec2.Equals(codec2));
            Assert.IsTrue(codec1.Equals(codec2));
            Assert.IsTrue(codec2.Equals(codec1));
        }
Ejemplo n.º 3
0
 public ZstandardCodec(ZstandardLevel level)
 {
     Level = level;
 }
Ejemplo n.º 4
0
        public void HashCode([Values] ZstandardLevel level)
        {
            ZstandardCodec codec = new ZstandardCodec(level);

            Assert.AreNotEqual(0, codec.GetHashCode());
        }
Ejemplo n.º 5
0
        public void CompressDecompressStream([ValueSource(nameof(_testLengths))] int length, [Values] ZstandardLevel level)
        {
            byte[] data = Enumerable.Range(0, length).Select(x => (byte)x).ToArray();

            ZstandardCodec codec = new ZstandardCodec(level);

            using (MemoryStream inputStream = new MemoryStream(data))
                using (MemoryStream outputStream = new MemoryStream())
                {
                    codec.Compress(inputStream, outputStream);

                    byte[] compressed   = outputStream.ToArray();
                    byte[] uncompressed = codec.Decompress(compressed, compressed.Length);

                    Assert.IsTrue(Enumerable.SequenceEqual(data, uncompressed));
                }
        }
Ejemplo n.º 6
0
        public void CompressDecompress([ValueSource(nameof(_testLengths))] int length, [Values] ZstandardLevel level)
        {
            byte[] data = Enumerable.Range(0, length).Select(x => (byte)x).ToArray();

            ZstandardCodec codec = new ZstandardCodec(level);

            byte[] compressed   = codec.Compress(data);
            byte[] uncompressed = codec.Decompress(compressed, compressed.Length);

            Assert.IsTrue(Enumerable.SequenceEqual(data, uncompressed));
        }