예제 #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());
        }
예제 #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));
        }
예제 #3
0
 public ZstandardCodec(ZstandardLevel level)
 {
     Level = level;
 }
예제 #4
0
        public void HashCode([Values] ZstandardLevel level)
        {
            ZstandardCodec codec = new ZstandardCodec(level);

            Assert.AreNotEqual(0, codec.GetHashCode());
        }
예제 #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));
                }
        }
예제 #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));
        }