mirror of
https://github.com/claunia/cuetools.net.git
synced 2025-12-16 18:14:25 +00:00
misc tests
This commit is contained in:
@@ -54,6 +54,7 @@
|
||||
<Compile Include="ALACWriterTest.cs" />
|
||||
<Compile Include="CodecsTest.cs" />
|
||||
<Compile Include="Crc32Test.cs" />
|
||||
<Compile Include="FlacWriterTest.cs" />
|
||||
<Compile Include="FlakeWriterTest.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="SOXResamplerTest.cs" />
|
||||
@@ -72,6 +73,10 @@
|
||||
<Name>CUETools.Codecs.ALAC</Name>
|
||||
<Private>True</Private>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\CUETools.Codecs.FLAC\CUETools.Codecs.FLAC.vcproj">
|
||||
<Project>{E70FA90A-7012-4A52-86B5-362B699D1540}</Project>
|
||||
<Name>CUETools.Codecs.FLAC</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\CUETools.Codecs.FLAKE\CUETools.Codecs.FLAKE.csproj">
|
||||
<Project>{082D6B9E-326E-4D15-9798-EDAE9EDE70A6}</Project>
|
||||
<Name>CUETools.Codecs.FLAKE</Name>
|
||||
|
||||
70
CUETools/CUETools.TestCodecs/FlacWriterTest.cs
Normal file
70
CUETools/CUETools.TestCodecs/FlacWriterTest.cs
Normal file
@@ -0,0 +1,70 @@
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using CUETools.Codecs;
|
||||
using CUETools.Codecs.FLAC;
|
||||
|
||||
namespace CUETools.TestCodecs
|
||||
{
|
||||
[TestClass()]
|
||||
public class FlacWriterTest
|
||||
{
|
||||
private TestContext testContextInstance;
|
||||
|
||||
/// <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;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///A test for FlacWriter (string, int, int, int, Stream)
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void ConstructorTest()
|
||||
{
|
||||
AudioBuffer buff = WAVReader.ReadAllSamples("test.wav", null);
|
||||
FLACWriter target;
|
||||
|
||||
target = new FLACWriter("flacwriter2.flac", buff.PCM);
|
||||
target.Padding = 1;
|
||||
target.BlockSize = 32;
|
||||
//target.Vendor = "CUETools";
|
||||
//target.CreationTime = DateTime.Parse("15 Aug 1976");
|
||||
target.FinalSampleCount = buff.Length;
|
||||
target.Write(buff);
|
||||
target.Close();
|
||||
CollectionAssert.AreEqual(File.ReadAllBytes("flacwriter1.flac"), File.ReadAllBytes("flacwriter2.flac"), "flacwriter2.flac doesn't match.");
|
||||
}
|
||||
|
||||
[TestMethod()]
|
||||
public void SeekTest()
|
||||
{
|
||||
var r = new FLACReader("test.flac", null);
|
||||
var buff1 = new AudioBuffer(r, 16536);
|
||||
var buff2 = new AudioBuffer(r, 16536);
|
||||
r.Read(buff1, 7777);
|
||||
r.Position = 0;
|
||||
r.Read(buff2, 7777);
|
||||
r.Close();
|
||||
Assert.AreEqual(buff1.ByteLength, buff2.ByteLength);
|
||||
var bytes1 = new byte[buff1.ByteLength];
|
||||
var bytes2 = new byte[buff2.ByteLength];
|
||||
Array.Copy(buff1.Bytes, bytes1, buff1.ByteLength);
|
||||
Array.Copy(buff2.Bytes, bytes2, buff2.ByteLength);
|
||||
CollectionAssert.AreEqual(bytes1, bytes2);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -149,5 +149,23 @@ namespace CUETools.TestCodecs
|
||||
lpc.compute_lpc_coefs(8, reff, lpcs);
|
||||
Assert.IsTrue(lpcs[7 * lpc.MAX_LPC_ORDER] < 3000);
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod()]
|
||||
public void SeekTest()
|
||||
{
|
||||
var r = new FlakeReader("test.flac", null);
|
||||
var buff1 = new AudioBuffer(r, 16536);
|
||||
var buff2 = new AudioBuffer(r, 16536);
|
||||
r.Read(buff1, 7777);
|
||||
r.Position = 0;
|
||||
r.Read(buff2, 7777);
|
||||
r.Close();
|
||||
Assert.AreEqual(buff1.ByteLength, buff2.ByteLength);
|
||||
var bytes1 = new byte[buff1.ByteLength];
|
||||
var bytes2 = new byte[buff2.ByteLength];
|
||||
Array.Copy(buff1.Bytes, bytes1, buff1.ByteLength);
|
||||
Array.Copy(buff2.Bytes, bytes2, buff2.ByteLength);
|
||||
CollectionAssert.AreEqual(bytes1, bytes2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BIN
CUETools/CUETools.TestCodecs/flacwriter1.flac
Normal file
BIN
CUETools/CUETools.TestCodecs/flacwriter1.flac
Normal file
Binary file not shown.
BIN
CUETools/CUETools.TestCodecs/test.flac
Normal file
BIN
CUETools/CUETools.TestCodecs/test.flac
Normal file
Binary file not shown.
Reference in New Issue
Block a user