⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 inflaterdeflatertests.cs

📁 全功能c#编译器
💻 CS
字号:
#if TEST
using System;
using System.IO;
using ICSharpCode.SharpZipLib.Zip.Compression;
using ICSharpCode.SharpZipLib.Zip.Compression.Streams;
using ICSharpCode.SharpZipLib.GZip;
using NUnit.Framework;

namespace ICSharpCode.SharpZipLib.Zip.Compression
{
	/// <summary>
	/// This class contains test cases for the Adler32 and Crc32 checksums
	/// </summary>
	[TestFixture]
	public class InflaterDeflaterTestSuite
	{
		/// <summary>
		/// Basic inflate/deflate test
		/// </summary>
		[Test]
		public void TestInflateDeflate()
		{
			MemoryStream ms = new MemoryStream();
			Deflater deflater = new Deflater(6);
			DeflaterOutputStream outStream = new DeflaterOutputStream(ms, deflater);
			
			byte[] buf = new byte[1000000];
			System.Random rnd = new Random();
			rnd.NextBytes(buf);
			
			outStream.Write(buf, 0, buf.Length);
			outStream.Flush();
			outStream.Finish();
			
			ms.Seek(0, SeekOrigin.Begin);
			
			InflaterInputStream inStream = new InflaterInputStream(ms);
			byte[] buf2 = new byte[buf.Length];
			int    pos  = 0;
			while (true) {
				int numRead = inStream.Read(buf2, pos, 4096);
				if (numRead <= 0) {
					break;
				}
				pos += numRead;
			}
			
			for (int i = 0; i < buf.Length; ++i) {
				Assertion.AssertEquals(buf2[i], buf[i]);
			}
		}
	}
}
#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -