mirror of
https://github.com/claunia/cuetools.net.git
synced 2025-12-16 18:14:25 +00:00
- Substitute occurrences of "2.1.7" with "2.1.8" using:
git grep -I -l -e '2\.1\.7' -- ':(exclude)*.bat' | xargs \
sed -b -i -e 's/2\.1\.7/2\.1\.8/g'
- Update some outdated version entries:
2.1.4 in CUETools.CTDB.EACPlugin.Installer.vdproj
git grep -I -l -e '2\.1\.4' | xargs \
sed -b -i -e 's/2\.1\.4/2\.1\.8/g'
2.0.7 in
CUEPlayer/Properties/DataSources/Output.datasource
CUEPlayer/Properties/DataSources/frmCUEPlayer.datasource
git grep -I -l -e '2\.0\.7' | xargs \
sed -b -i -e 's/2\.0\.7/2\.1\.8/g'
1.9.4 in CUETools.Processor.CUEConfig.datasource
git grep -I -l -e '1\.9\.4' | xargs \
sed -b -i -e 's/1\.9\.4/2\.1\.8/g'
1.9.0 in frmCUERipper.datasource
git grep -I -l -e '1\.9\.0' | xargs \
sed -b -i -e 's/1\.9\.0/2\.1\.8/g'
349 lines
16 KiB
C#
349 lines
16 KiB
C#
// The following code was generated by Microsoft Visual Studio 2005.
|
|
// The test owner should check each test for validity.
|
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
|
using System;
|
|
using System.Text;
|
|
using System.Collections.Generic;
|
|
using CUETools.CDImage;
|
|
using CUETools.AccurateRip;
|
|
using CUETools.Codecs;
|
|
using CUETools.TestHelpers;
|
|
namespace CUETools.TestCodecs
|
|
{
|
|
/// <summary>
|
|
///This is a test class for CUETools.AccurateRip.AccurateRipVerify and is intended
|
|
///to contain all CUETools.AccurateRip.AccurateRipVerify Unit Tests
|
|
///</summary>
|
|
[TestClass()]
|
|
public class AccurateRipVerifyTest
|
|
{
|
|
|
|
|
|
private TestContext testContextInstance;
|
|
private AccurateRipVerify ar;
|
|
private AccurateRipVerify ar2;
|
|
|
|
/// <summary>
|
|
///Gets or sets the test context which provides
|
|
///information about and functionality for the current test run.
|
|
///</summary>
|
|
public TestContext TestContext
|
|
{
|
|
get
|
|
{
|
|
return testContextInstance;
|
|
}
|
|
set
|
|
{
|
|
testContextInstance = value;
|
|
}
|
|
}
|
|
|
|
#region Additional test attributes
|
|
//
|
|
//You can use the following additional attributes as you write your tests:
|
|
//
|
|
//Use ClassInitialize to run code before running the first test in the class
|
|
//
|
|
//[ClassInitialize()]
|
|
//public static void MyClassInitialize(TestContext testContext)
|
|
//{
|
|
//}
|
|
//
|
|
//Use ClassCleanup to run code after all tests in a class have run
|
|
//
|
|
//[ClassCleanup()]
|
|
//public static void MyClassCleanup()
|
|
//{
|
|
//}
|
|
//
|
|
//Use TestInitialize to run code before running each test
|
|
//
|
|
[TestInitialize()]
|
|
public void MyTestInitialize()
|
|
{
|
|
ar = TestImageGenerator.CreateAccurateRipVerify("13 68 99 136", 2314, 0);
|
|
ar2 = TestImageGenerator.CreateAccurateRipVerify("0 136 886", 2314, 0);
|
|
}
|
|
|
|
//Use TestCleanup to run code after each test has run
|
|
//
|
|
//[TestCleanup()]
|
|
//public void MyTestCleanup()
|
|
//{
|
|
//}
|
|
//
|
|
#endregion
|
|
|
|
|
|
/// <summary>
|
|
///A test for CRC32
|
|
///</summary>
|
|
[TestMethod()]
|
|
public void CRC32Test()
|
|
{
|
|
Assert.AreEqual<uint>(3791227907, ar.CRC32(0), "CRC32[0] was not set correctly.");
|
|
Assert.AreEqual<uint>(0321342250, ar.CRC32(1), "CRC32[1] was not set correctly.");
|
|
Assert.AreEqual<uint>(0037001035, ar.CRC32(2), "CRC32[2] was not set correctly.");
|
|
Assert.AreEqual<uint>(0516255430, ar.CRC32(3), "CRC32[3] was not set correctly.");
|
|
|
|
Assert.AreEqual<uint>(3791227907, ar2.CRC32(1), "CRC32[1](2) was not set correctly.");
|
|
}
|
|
|
|
/// <summary>
|
|
///A test for CRC32 with offset
|
|
///</summary>
|
|
[TestMethod()]
|
|
public void CRC32TestOffset()
|
|
{
|
|
Assert.AreEqual<uint>(2953798997, ar.CRC32(0, 13), "CRC32[0][13] was not set correctly.");
|
|
Assert.AreEqual<uint>(0480843614, ar.CRC32(0, -7), "CRC32[0][-7] was not set correctly.");
|
|
Assert.AreEqual<uint>(1228729415, ar.CRC32(1, 13), "CRC32[1][13] was not set correctly.");
|
|
Assert.AreEqual<uint>(3364131728, ar.CRC32(1, -7), "CRC32[1][-7] was not set correctly.");
|
|
Assert.AreEqual<uint>(1905873074, ar.CRC32(2, 15), "CRC32[2][15] was not set correctly.");
|
|
Assert.AreEqual<uint>(0611805314, ar.CRC32(2, -1), "CRC32[2][-1] was not set correctly.");
|
|
Assert.AreEqual<uint>(4242272536, ar.CRC32(3, 15), "CRC32[3][15] was not set correctly.");
|
|
Assert.AreEqual<uint>(4236330757, ar.CRC32(3, -1), "CRC32[3][-1] was not set correctly.");
|
|
|
|
Assert.AreEqual<uint>(0480843614, ar2.CRC32(1, -7), "CRC32[1,13](2) was not set correctly.");
|
|
}
|
|
|
|
/// <summary>
|
|
///A test for CTDBCRC
|
|
///</summary>
|
|
[TestMethod()]
|
|
public void CTDBCRCTest()
|
|
{
|
|
Assert.AreEqual<uint>(4209773141, ar.CTDBCRC(1, 0, 5 * 588, 5 * 588), "CTDBCRC[1] was not set correctly.");
|
|
Assert.AreEqual<uint>(0037001035, ar.CTDBCRC(2, 0, 5 * 588, 5 * 588), "CTDBCRC[2] was not set correctly.");
|
|
Assert.AreEqual<uint>(1024656428, ar.CTDBCRC(3, 0, 5 * 588, 5 * 588), "CTDBCRC[3] was not set correctly.");
|
|
|
|
Assert.AreEqual<uint>(ar.CRC32(2), ar.CTDBCRC(2, 0, 5 * 588, 5 * 588), "CTDBCRC[2] was not set correctly.");
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
///A test for ARV1 CRC
|
|
///</summary>
|
|
[TestMethod()]
|
|
public void CRCTest()
|
|
{
|
|
Assert.AreEqual<uint>(3727147246, ar.CRC(0), "CRC[0] was not set correctly.");
|
|
Assert.AreEqual<uint>(2202235240, ar.CRC(1), "CRC[1] was not set correctly.");
|
|
Assert.AreEqual<uint>(3752629998, ar.CRC(2), "CRC[2] was not set correctly.");
|
|
}
|
|
|
|
/// <summary>
|
|
///A test for ARV1 CRC with offset
|
|
///</summary>
|
|
[TestMethod()]
|
|
public void CRCTest1()
|
|
{
|
|
Assert.AreEqual<uint>(0123722587, ar.CRC(0, -1), "CRC[0][-1] was not set correctly.");
|
|
Assert.AreEqual<uint>(1975220196, ar.CRC(0, 99), "CRC[0][99] was not set correctly.");
|
|
Assert.AreEqual<uint>(1519928474, ar.CRC(1, -3), "CRC[1][-3] was not set correctly.");
|
|
Assert.AreEqual<uint>(2114385036, ar.CRC(1, 11), "CRC[1][11] was not set correctly.");
|
|
Assert.AreEqual<uint>(1521167728, ar.CRC(2, -4), "CRC[2][-4] was not set correctly.");
|
|
Assert.AreEqual<uint>(0301435197, ar.CRC(2, 55), "CRC[2][55] was not set correctly.");
|
|
}
|
|
|
|
/// <summary>
|
|
///A test for CRCV2
|
|
///</summary>
|
|
[TestMethod()]
|
|
public void CRCV2Test()
|
|
{
|
|
Assert.AreEqual<uint>(3988391122, ar.CRCV2(0), "CRCV2[0] was not set correctly.");
|
|
Assert.AreEqual<uint>(2284845104, ar.CRCV2(1), "CRCV2[1] was not set correctly.");
|
|
Assert.AreEqual<uint>(3841231027, ar.CRCV2(2), "CRCV2[2] was not set correctly.");
|
|
}
|
|
|
|
/// <summary>
|
|
///A test for CRCWONULL
|
|
///</summary>
|
|
[TestMethod()]
|
|
public void CRCWONULLTest()
|
|
{
|
|
Assert.AreEqual<uint>(0812984565, ar.CRCWONULL(2, 19), "CRC32WONULL[2][19] was not set correctly.");
|
|
Assert.AreEqual<uint>(2390392664, ar.CRCWONULL(2, -2), "CRC32WONULL[2][-2] was not set correctly.");
|
|
}
|
|
|
|
/// <summary>
|
|
///A test for CRCWONULL with offset
|
|
///</summary>
|
|
[TestMethod()]
|
|
public void CRCWONULLTestOffset()
|
|
{
|
|
Assert.AreEqual<uint>(0404551290, ar.CRCWONULL(0), "CRC32WONULL[0] was not set correctly.");
|
|
Assert.AreEqual<uint>(0224527589, ar.CRCWONULL(1), "CRC32WONULL[1] was not set correctly.");
|
|
Assert.AreEqual<uint>(0557159190, ar.CRCWONULL(2), "CRC32WONULL[2] was not set correctly.");
|
|
Assert.AreEqual<uint>(0516255430, ar.CRCWONULL(3), "CRC32WONULL[3] was not set correctly.");
|
|
Assert.AreEqual<uint>(0404551290, ar2.CRCWONULL(1), "CRC32WONULL[1](2) was not set correctly.");
|
|
}
|
|
|
|
/// <summary>
|
|
///A test for CRC450
|
|
///</summary>
|
|
[TestMethod()]
|
|
public void CRC450Test()
|
|
{
|
|
Assert.AreEqual<uint>(2224430043, ar2.CRC450(1, 00), "CRC450[1,00] was not set correctly.");
|
|
Assert.AreEqual<uint>(1912726337, ar2.CRC450(1, 55), "CRC450[1,55] was not set correctly.");
|
|
Assert.AreEqual<uint>(1251460151, ar2.CRC450(1, -3), "CRC450[1,-3] was not set correctly.");
|
|
}
|
|
|
|
/// <summary>
|
|
///A test for ARCRC offset
|
|
///</summary>
|
|
[TestMethod()]
|
|
public void CRCTestOffset()
|
|
{
|
|
var ar0 = TestImageGenerator.CreateAccurateRipVerify("13 68 99 136", 723722, 0);
|
|
var offsets = new int[] { 1, 2, 3, 4, 11, 256, 588, 588 * 5 - 1 };
|
|
foreach (int offs in offsets)
|
|
{
|
|
var ar1 = TestImageGenerator.CreateAccurateRipVerify("13 68 99 136", 723722, offs);
|
|
for (int track = 0; track < 3; track++)
|
|
{
|
|
Assert.AreEqual<uint>(ar0.CRC(track, offs), ar1.CRC(track), "CRC with offset " + offs + " was not set correctly.");
|
|
Assert.AreEqual<uint>(ar0.CRC(track), ar1.CRC(track, -offs), "CRC with offset " + (-offs) + " was not set correctly.");
|
|
Assert.AreEqual<uint>(ar0.CRC450(track, offs), ar1.CRC450(track, 0), "CRC450 with offset " + offs + " was not set correctly.");
|
|
Assert.AreEqual<uint>(ar0.CRC450(track, 0), ar1.CRC450(track, -offs), "CRC450 with offset " + (-offs) + " was not set correctly.");
|
|
Assert.AreEqual<uint>(ar0.CTDBCRC(track + 1, offs, 588 * 5, 588 * 5), ar1.CTDBCRC(track + 1, 0, 588 * 5, 588 * 5), "CTDBCRC with offset " + offs + " was not set correctly.");
|
|
Assert.AreEqual<uint>(ar1.CTDBCRC(track + 1, -offs, 588 * 5, 588 * 5), ar0.CTDBCRC(track + 1, 0, 588 * 5, 588 * 5), "CTDBCRC with offset " + (-offs) + " was not set correctly.");
|
|
if (track != 2)
|
|
{
|
|
Assert.AreEqual<uint>(ar0.CRC32(track + 1, offs), ar1.CRC32(track + 1), "CRC32 with offset " + (offs) + " was not set correctly.");
|
|
Assert.AreEqual<uint>(ar0.CRCWONULL(track + 1, offs), ar1.CRCWONULL(track + 1), "CRCWONULL with offset " + (offs) + " was not set correctly.");
|
|
}
|
|
//if (track != 0)
|
|
{
|
|
Assert.AreEqual<uint>(ar0.CRC32(track + 1), ar1.CRC32(track + 1, -offs), "CRC32 with offset " + (-offs) + " was not set correctly.");
|
|
Assert.AreEqual<uint>(ar0.CRCWONULL(track + 1), ar1.CRCWONULL(track + 1, -offs), "CRCWONULL with offset " + (-offs) + " was not set correctly.");
|
|
}
|
|
}
|
|
Assert.AreEqual<uint>(ar0.CTDBCRC(0, offs, 588 * 5, 588 * 5), ar1.CTDBCRC(0, 0, 588 * 5, 588 * 5), "CTDBCRC with offset " + offs + " was not set correctly.");
|
|
Assert.AreEqual<uint>(ar1.CTDBCRC(0, -offs, 588 * 5, 588 * 5), ar0.CTDBCRC(0, 0, 588 * 5, 588 * 5), "CTDBCRC with offset " + (-offs) + " was not set correctly.");
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
///A test for CRC parralelism
|
|
///</summary>
|
|
[TestMethod()]
|
|
public void CRCTestSplit()
|
|
{
|
|
var ar0 = TestImageGenerator.CreateAccurateRipVerify("13 68 99 136", 723722, 0);
|
|
var splits = new int[] { 1, 13 * 588 - 1, 13 * 588, 13 * 588 + 1, 30 * 588, 68 * 588 - 1, 68 * 588, 68 * 588 + 1 };
|
|
foreach (int split in splits)
|
|
{
|
|
var ar1 = TestImageGenerator.CreateAccurateRipVerify("13 68 99 136", 723722, 0, 0, split);
|
|
var ar2 = TestImageGenerator.CreateAccurateRipVerify("13 68 99 136", 723722, 0, split, (int)ar0.FinalSampleCount);
|
|
ar1.Combine(ar2, split, (int)ar0.FinalSampleCount);
|
|
var offsets = new int[] { 0, -1, 1, -2, 2, -3, 3, -4, 4, -11, 11, -256, 256, -588, 588, 1 - 588 * 5, 588 * 5 - 1 };
|
|
foreach (int offs in offsets)
|
|
{
|
|
for (int track = 0; track < 3; track++)
|
|
{
|
|
string message = "split = " + CDImageLayout.TimeToString((uint)split/588) + "." + (split%588).ToString() + ", offset = " + offs.ToString() + ", track = " + (track + 1).ToString();
|
|
Assert.AreEqual<uint>(ar0.CRC(track, offs), ar1.CRC(track, offs), "CRC was not set correctly, " + message);
|
|
Assert.AreEqual<uint>(ar0.CTDBCRC(track, offs, 5 * 588, 5 * 588), ar1.CTDBCRC(track, offs, 5 * 588, 5 * 588), "CTDBCRC was not set correctly, " + message);
|
|
//CRC450 is zero here :( too small tracks
|
|
//Assert.AreEqual<uint>(ar0.CRC450(track, offs), ar1.CRC450(track, offs), "CRC450 was not set correctly, " + message);
|
|
if ((track != 2 || offs <= 0))// && (track != 0 || offs >= 0))
|
|
{
|
|
Assert.AreEqual<uint>(ar0.CRC32(track + 1, offs), ar1.CRC32(track + 1, offs), "CRC32 was not set correctly, " + message);
|
|
Assert.AreEqual<uint>(ar0.CRCWONULL(track + 1, offs), ar1.CRCWONULL(track + 1, offs), "CRCWONULL was not set correctly, " + message);
|
|
}
|
|
if (offs == 0)
|
|
{
|
|
Assert.AreEqual<uint>(ar0.CRCV2(track), ar1.CRCV2(track), "CRCV2 was not set correctly, " + message);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
///OffsetSafeCRCRecord
|
|
///</summary>
|
|
[TestMethod()]
|
|
public void OffsetSafeCRCRecordTest()
|
|
{
|
|
//OffsetSafeCRCRecord[] records = new OffsetSafeCRCRecord[5000];
|
|
var record0 = TestImageGenerator.CreateAccurateRipVerify("13 68 99 136", 2314, 0).OffsetSafeCRC;
|
|
|
|
Assert.AreEqual(
|
|
"xNabCDhnBPt45+ciq03CeqXDvZipuO5umMAVs6MWnHquaAQPCNK5p6aFqUwYn9pg\r\n" +
|
|
"JRwA7N7y56iFkAAGocLf1W5WHb7+FZqfNpwFdbdDs+yRGAeUIvOoA+wiwPupDCAA\r\n" +
|
|
"oA/rwLNMdbHStlNj4x85VCsLIp5OpLY96gEM9dBtralauYpI1bMne+Iz0PZQYMOf\r\n" +
|
|
"ZR+siqD+PSKcB4ZVXUOFsLdnaE9PK2Nt+23eaCWz7Xb7DIk3y3N5/a/fpJKeI+wA\r\n" +
|
|
"Z9VQKoi8ZrovomELWl5qkggU729uIY1o/2qXBMWJ6DwS67sNe10bBt1MdqqkNdV7\r\n" +
|
|
"rmuw1evdP80ABMX8wDjxH3gIdozrGABX+st9/En+fiubdEtkhKdo96eI4Cqa41nW\r\n" +
|
|
"4TvvD1UO5UrXS+gedLpa337w449cUVK3Yk7zDb5oAoJgK7jBHeetCdj/b30THmSA\r\n" +
|
|
"pv30LKAcXgUpc602FPDH7m7GvsRrtiQ1r9ZHMyQ9NCBt2oWCv2Hac7jDW7N4vQgv\r\n" +
|
|
"DJwm4nnn7H4WMZ/WziDfUVYYLVPlt/R/DXYnAlsVAj+kBHNlLojQG5A/bRqjDObN\r\n" +
|
|
"NsNjdI3IgVOQZHP1bkaKGQKQHAdeOGkU+HgaPVe0zKO+r2b5AwKCc66imdS6GGGk\r\n" +
|
|
"v5xwtNiLb6aJhmuASiOZL8oFHT+W7MPFTVb7hQEg7Ck=\r\n",
|
|
//"8+lTDqEZidfayuC0LoxnL9Oluf4ywo1muFBu115XBgf254fKIdfVWZOcsQraS4eI\r\n" +
|
|
//"NoLn7W3t0a16i745nEvikfw27ZsMR7gWPrXgXdsI2OdtjWTRL2Vra2dLe3WOl/Ru\r\n" +
|
|
//"wFa1jqbB3+xHiB8XNi+5VKRh3fj1o5RSXS6tOZUvBUFFqoyuZK/DkeIyZ4gkotYO\r\n" +
|
|
//"MZSsx2JBr2tdBzHZMssUmfvWUrfJZAQD8wMv1epy7q0Mk3W/QetVz6cZZ+6rRctf\r\n" +
|
|
//"PGqvWBgNfS/+e7LBo/49KYd16kEofaX8LuuNB/7YJ85a3W71soQovwWLkjm32Xqo\r\n" +
|
|
//"KpaUagu9QED1WEx7frfu95vYsQLV+vq6zULP6QOznUpU6n6LuMPQa5WNA4+chigC\r\n" +
|
|
//"71GFeKTSO3bnS3xg8FMMqRtcTJleWF/7Bs3DkUZnxbkp4g8iZYZ3eMDc7A04AiYx\r\n" +
|
|
//"3tYvDi9WiEZMRWpvuHfoBzWU7HbfOk5+32yg8TyNyVlPq1cfFn/jwQrfNyztTyav\r\n" +
|
|
//"96ZJS2aBroYAw2We5RC2oekmi+N75L6+eQB/4iZOxB9aGP1sALd/UZaJqZP8FcmW\r\n" +
|
|
//"FJOXlBi/KW68TJvujz+2w/P7EaZ0L7llQAtoHwoJniuNN5WYXBlescGc+vyYr5df\r\n" +
|
|
//"jrul+QMmQ4xMi10mglq7CMLVfZZFFgBdvGBrn1tL9bg=\r\n",
|
|
TestImageGenerator.CreateAccurateRipVerify("13 68 99 136", 2314, 13).OffsetSafeCRC.Base64);
|
|
|
|
var offsets = new int[] { 1, 2, 3, 4, 8, 11, 15, 16, 31, 32, 255, 256, 597, 588, 588 * 5 - 1, 588 * 5, 4095, 4096, 4097, 5000 };
|
|
foreach (int offset in offsets)
|
|
{
|
|
var record = TestImageGenerator.CreateAccurateRipVerify("13 68 99 136", 2314, offset).OffsetSafeCRC;
|
|
|
|
int real_off = -offset;
|
|
int off;
|
|
bool found = record0.FindOffset(record, out off);
|
|
if (real_off > 4096 || real_off < -4096)
|
|
{
|
|
Assert.IsFalse(found, string.Format("FindOffset found offset where it shouldn't have, real offset {0}", real_off));
|
|
}
|
|
else
|
|
{
|
|
Assert.IsTrue(found, string.Format("FindOffset failed to detect offset, real offset {0}", real_off));
|
|
Assert.AreEqual(real_off, off, string.Format("FindOffset returned {0}, should be {1}", off, real_off));
|
|
}
|
|
real_off = offset;
|
|
found = record.FindOffset(record0, out off);
|
|
if (real_off > 4096 || real_off < -4096)
|
|
{
|
|
Assert.IsFalse(found, string.Format("FindOffset found offset where it shouldn't have, real offset {0}", real_off));
|
|
}
|
|
else
|
|
{
|
|
Assert.IsTrue(found, string.Format("FindOffset failed to detect offset, real offset {0}", real_off));
|
|
Assert.AreEqual(real_off, off, string.Format("FindOffset returned {0}, should be {1}", off, real_off));
|
|
}
|
|
}
|
|
}
|
|
|
|
[TestMethod()]
|
|
[Ignore]
|
|
public void asdaTest()
|
|
{
|
|
//var tempPath = @"C:\Users\user\Downloads\CUETools_2.1.2a\CUE Tools\LocalDB.xml";
|
|
var tempPath = @"C:\Users\user\Downloads\CUETools_2.1.8\CUE Tools\LocalDB.xml";
|
|
var path = tempPath + @".z";
|
|
//using (var fileStream = new System.IO.FileStream(tempPath, System.IO.FileMode.CreateNew))
|
|
//using (var deflateStream = new System.IO.Compression.DeflateStream(fileStream, System.IO.Compression.CompressionMode.Compress))
|
|
using (var fileStream1 = new System.IO.FileStream(tempPath, System.IO.FileMode.CreateNew))
|
|
using (var fileStream2 = new System.IO.FileStream(path, System.IO.FileMode.Open))
|
|
using (var deflateStream = new System.IO.Compression.DeflateStream(fileStream2, System.IO.Compression.CompressionMode.Decompress))
|
|
deflateStream.CopyTo(fileStream1);
|
|
}
|
|
}
|
|
|
|
}
|