mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Added tests for checksums.
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
// The Disc Image Chef
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : CRC16.cs
|
||||
// Filename : CRC64.cs
|
||||
// Version : 1.0
|
||||
// Author(s) : Natalia Portillo
|
||||
//
|
||||
@@ -43,39 +43,39 @@ using System.IO;
|
||||
namespace DiscImageChef.Tests.Checksums
|
||||
{
|
||||
[TestFixture]
|
||||
public class CRC16
|
||||
public class CRC64
|
||||
{
|
||||
static readonly byte[] ExpectedEmpty = { 0x00, 0x00 };
|
||||
static readonly byte[] ExpectedRandom = { 0x2d, 0x6d };
|
||||
static readonly byte[] ExpectedEmpty = { 0x60, 0x6b, 0x70, 0xa2, 0x3e, 0xba, 0xf6, 0xc2 };
|
||||
static readonly byte[] ExpectedRandom = { 0xbf, 0x09, 0x99, 0x2c, 0xc5, 0xed, 0xe3, 0x8e };
|
||||
|
||||
[Test]
|
||||
public void CRC16EmptyFile()
|
||||
public void CRC64EmptyFile()
|
||||
{
|
||||
byte[] result = CRC16Context.File(Path.Combine(Consts.TestFilesRoot, "checksums", "empty"));
|
||||
byte[] result = CRC64Context.File(Path.Combine(Consts.TestFilesRoot, "checksums", "empty"));
|
||||
Assert.AreEqual(ExpectedEmpty, result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CRC16EmptyData()
|
||||
public void CRC64EmptyData()
|
||||
{
|
||||
byte[] data = new byte[1048576];
|
||||
FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "empty"), FileMode.Open, FileAccess.Read);
|
||||
fs.Read(data, 0, 1048576);
|
||||
fs.Close();
|
||||
fs.Dispose();
|
||||
CRC16Context.Data(data, out byte[] result);
|
||||
CRC64Context.Data(data, out byte[] result);
|
||||
Assert.AreEqual(ExpectedEmpty, result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CRC16EmptyInstance()
|
||||
public void CRC64EmptyInstance()
|
||||
{
|
||||
byte[] data = new byte[1048576];
|
||||
FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "empty"), FileMode.Open, FileAccess.Read);
|
||||
fs.Read(data, 0, 1048576);
|
||||
fs.Close();
|
||||
fs.Dispose();
|
||||
CRC16Context ctx = new CRC16Context();
|
||||
CRC64Context ctx = new CRC64Context();
|
||||
ctx.Init();
|
||||
ctx.Update(data);
|
||||
byte[] result = ctx.Final();
|
||||
@@ -83,33 +83,33 @@ namespace DiscImageChef.Tests.Checksums
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CRC16RandomFile()
|
||||
public void CRC64RandomFile()
|
||||
{
|
||||
byte[] result = CRC16Context.File(Path.Combine(Consts.TestFilesRoot, "checksums", "random"));
|
||||
byte[] result = CRC64Context.File(Path.Combine(Consts.TestFilesRoot, "checksums", "random"));
|
||||
Assert.AreEqual(ExpectedRandom, result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CRC16RandomData()
|
||||
public void CRC64RandomData()
|
||||
{
|
||||
byte[] data = new byte[1048576];
|
||||
FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "random"), FileMode.Open, FileAccess.Read);
|
||||
fs.Read(data, 0, 1048576);
|
||||
fs.Close();
|
||||
fs.Dispose();
|
||||
CRC16Context.Data(data, out byte[] result);
|
||||
CRC64Context.Data(data, out byte[] result);
|
||||
Assert.AreEqual(ExpectedRandom, result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CRC16RandomInstance()
|
||||
public void CRC64RandomInstance()
|
||||
{
|
||||
byte[] data = new byte[1048576];
|
||||
FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "random"), FileMode.Open, FileAccess.Read);
|
||||
fs.Read(data, 0, 1048576);
|
||||
fs.Close();
|
||||
fs.Dispose();
|
||||
CRC16Context ctx = new CRC16Context();
|
||||
CRC64Context ctx = new CRC64Context();
|
||||
ctx.Init();
|
||||
ctx.Update(data);
|
||||
byte[] result = ctx.Final();
|
||||
|
||||
Reference in New Issue
Block a user